ordinals / ord

👁‍🗨 Rare and exotic sats
https://ordinals.com
Creative Commons Zero v1.0 Universal
3.85k stars 1.37k forks source link

sending cardinals leaves all inscriptions locked #1843

Open gmart7t2 opened 1 year ago

gmart7t2 commented 1 year ago

Sending a cardinal involves locking inscription outputs so that bitcoin's sendtoaddress RPC won't spend them. But they never get unlocked again. Here's an example:

I have an inscription:

$ ord wallet inscriptions | jq -cM
[{"inscription":"f5007194caab8fa729cec4bea1c2055e5bddadc116fc8508eab6c75da8b66358i0","location":"f5007194caab8fa729cec4bea1c2055e5bddadc116fc8508eab6c75da8b66358:0:0","explorer":"http://localhost/inscription/f5007194caab8fa729cec4bea1c2055e5bddadc116fc8508eab6c75da8b66358i0"}]

Nothing is locked:

$ bitcoin listlockunspent | jq -cM
[]

I send a cardinal away:

$ ord wallet send --fee-rate 1 bcrt1qh4vtf56l043z79938wta7qjhae3ye29qk4sp4p 89500sats
{
  "transaction": "878c0f54d961416d6cec6c4461b25d0182ac85c3ad5f802ac9eaeb58577c8c2a"
}

And now my inscription utxo is locked:

$ bitcoin listlockunspent | jq -cM
[{"txid":"f5007194caab8fa729cec4bea1c2055e5bddadc116fc8508eab6c75da8b66358","vout":0}]

I am now unable to send any more cardinals because the send command tries to lock my inscription but fails because it is already locked:

$ ord wallet send --fee-rate 1 bcrt1plpelsvnyy7qf6nrjdmdveat7krcy6mcr2ydl4pnftcz4qvgqpjysz79xgt 1000000sats
error: JSON-RPC error: RPC error response: RpcError { code: -8, message: "Invalid parameter, output already locked", data: None }

So I unlock it:

$ bitcoin lockunspent true
true

Now I can send cardinals again:

$ ord wallet send --fee-rate 1 bcrt1plpelsvnyy7qf6nrjdmdveat7krcy6mcr2ydl4pnftcz4qvgqpjysz79xgt 1000000sats
{
  "transaction": "09333af8d91af16b00db361ea8005908a12a10393efd54b794263547d7d11ad5"
}

Fix: unlock the locked inscriptions after calling sendtoaddress.

gmart7t2 commented 1 year ago

Attempting to do 2 sends from the same wallet fails since the first and locks the inscriptions and the 2nd and tries to lock the already locked inscriptions:

$ ord wallet send --fee-rate 1 bcrt1plpelsvnyy7qf6nrjdmdveat7krcy6mcr2ydl4pnftcz4qvgqpjysz79xgt 1000000sats
{
  "transaction": "09333af8d91af16b00db361ea8005908a12a10393efd54b794263547d7d11ad5"
}
$ ord wallet send --fee-rate 1 bcrt1plpelsvnyy7qf6nrjdmdveat7krcy6mcr2ydl4pnftcz4qvgqpjysz79xgt 1000000sats
error: JSON-RPC error: RPC error response: RpcError { code: -8, message: "Invalid parameter, output already locked", data: None }
$ 
bFanek commented 1 year ago

I have the same issue, unlocking my inscriptions and sending again fixed it.

BUT I noticed that it included one unconfirmed inscription (transaction was still in mempool) as an input to the new send transaction. It looks like the send function locked all confirmed inscriptions but ignored unconfirmed ones in mempool, which could result in losing that inscription as transaction fee. Be careful, don't use the send function if you have any unconfirmed inscriptions.

This should be fixed in ord as it poses a risk of losing inscriptions.

0xCrying commented 1 year ago

Incase the wallet is not found, providing the wallet path as below, the default wallet name is ord

$ bitcoin-cli -rpcwallet=ord lockunspent true