ord icon indicating copy to clipboard operation
ord copied to clipboard

Recover funds from an unspent reveal transaction (maxtxfee error)

Open StashMaker opened this issue 10 months ago • 19 comments

@raphjaph @casey

Is it possible to recover the funds from a reveal transaction that was never broadcasted to the mempool?

The commit transaction was send and successfully included in a block. The reveal transaction got stuck due to a maxtxfee error. When checking the ord wallet balance, the cardinals previously reserved for reveal transaction fees are still displayed, but can no longer be sent or otherwise spent (error: unable to sign transaction)

Manually creating and signing a transaction returns an error as well ("error": "Witness program was passed an empty witness").

StashMaker avatar Apr 22 '24 05:04 StashMaker

My situation is the same as yours, it also happened during etch, where due to the feerate being over 10000/vb, only the commit transaction succeeded and the reveal encountered an error(not broadcasted). Now, as the network's miner fees have significantly decreased, I hope to recover the funds from the input of reveal transaction, but I have tried multiple methods and failed. From what I understand, quite a few people have also encountered the same problem, hoping @casey @raphjaph could help us out.

Best regards.

huguojunsy avatar Apr 22 '24 15:04 huguojunsy

As far as I can tell, our funds are still there. The question is whether we can access them again or whether they are so tied to the commit transaction that we can no longer spend them.

StashMaker avatar Apr 22 '24 15:04 StashMaker

We've set it up in a way such that the commit output, should be seamlessly recoverable.

So you see the UTXO in your wallet but can't use it in a transaction?

raphjaph avatar Apr 22 '24 17:04 raphjaph

I have ~0.65 BTC across several named wallets encountering this issue. I don't mind doxxing one if it helps or paying someone for their help due to the amount impacted by this.

ord --index-runes wallet --name e1 balance

{
  "cardinal": 10626819,
  "ordinal": 0,
  "runes": {},
  "runic": 0,
  "total": 10626819
}

ord --index-runes wallet --name e1 send 3Mji2mfaht1MdgwvD5ivLro7M5onAugdZY "10606719sat" --fee-rate 100 --dry-run

{
  "txid": "11fcfb43f048437c096de638ffa08dda98c704a72242d4c0c99c50fa7c7e068a",
  "psbt": "cHNidP8BAHwCAAAAAs/VqU96F0Js5+Sytu1xkgiCUkPRJNEr61/+8zB05otbAQAAAAD9////z9WpT3oXQmzn5LK27XGSCIJSQ9Ek0SvrX/7zMHTmi1sAAAAAAP3///8Bf9ihAAAAAAAXqRTb5NPZvHmupZSphnIlLNBo30QUb4cAAAAAAAEBKzYCAgAAAAAAIlEgh+x8eLDPhvbW7uGaEMJS/MwVaGOxHTIFsMwFyL8Ae3khFggKlgRpDMGJF6FbCLZ0uSTzu3+i876k0h3IRXjrk9Y9GQCHGA3qVgAAgAAAAIAAAACAAQAAADIAAAABFyAICpYEaQzBiRehWwi2dLkk87t/ovO+pNIdyEV465PWPQABASvNJKAAAAAAACJRIMBzYsVx7XnWYPhreo9Vz1TWWj8qHSfw1FB8H8apIlFdAAA=",
  "outgoing": "0.10606719 btc",
  "fee": 20100
}

ord --index-runes wallet --name e1 send 3Mji2mfaht1MdgwvD5ivLro7M5onAugdZY "10606719sat" --fee-rate 100

error: unable to sign transaction

ord --index-runes wallet --name e1 transactions

[
  {
    "transaction": "20f03267aeac2163f6dea66091f4bedf31135aab19c64129b5855ca32c1d225c",
    "confirmations": 751
  },
  {
    "transaction": "5b8be67430f3fe5feb2bd124d1435282089271edb6b2e4e76c42177a4fa9d5cf",
    "confirmations": 742
  },
  {
    "transaction": "5b8be67430f3fe5feb2bd124d1435282089271edb6b2e4e76c42177a4fa9d5cf",
    "confirmations": 742
  }
]

ord --index-runes wallet --name e1 outputs

[
  {
    "output": "5b8be67430f3fe5feb2bd124d1435282089271edb6b2e4e76c42177a4fa9d5cf:0",
    "amount": 10495181
  },
  {
    "output": "5b8be67430f3fe5feb2bd124d1435282089271edb6b2e4e76c42177a4fa9d5cf:1",
    "amount": 131638
  }
]

droplister avatar Apr 22 '24 19:04 droplister

Also reported here: https://github.com/ordinals/ord/issues/3629

droplister avatar Apr 22 '24 19:04 droplister

Thank you @raphjaph for your quick response and for taking care of this issue:

  • the correct amount of sats is displayed as cardinals when checking with ord wallet balance,
  • the UTXO is listed when running bitcoin-cli -rpcwallet=walletName listunspent
  • gettransaction shows the correct transaction to the new address and
  • and decoderawtransaction looks good too.

When I check the new output address of these unspent funds with getaddressinfo, it returns: "ismine": true, "solvable": true, "iswatchonly": false, "isscript": true, "iswitness": true, "witness_version": 1, "ischange": false, "labels": ["commit tx recovery key"]

When I try to send the funds with ord wallet send I get: error: unable to sign transaction. The same happens when I construct a tx manually.

Ord version used: 0.18.2

When I dump the wallet in restore it on another system, none of the above is displayed anymore. The new output is no longer available there.

StashMaker avatar Apr 22 '24 19:04 StashMaker

Thanks for the details, I'll have a look at this.

What you can try now as well is loading the seed phrase for that wallet into Sparrow, then carefully selecting the correct UTXO and sending it out. When importing into sparrow make sure to select the Taproot descriptor on initialization.

raphjaph avatar Apr 22 '24 20:04 raphjaph

Thank you very much, @raphjaph. The thing is, the UTXO in question doesn't show up in Sparrow after importing the wallet. The same is true if I dump and restore the ord wallet on another system. I'm not sure if this is just a problem on my end.

StashMaker avatar Apr 22 '24 20:04 StashMaker

I tried scanning 2000 deep on Sparrow and it doesn't detect all the BTC. image

droplister avatar Apr 22 '24 20:04 droplister

Same here, mine looks almost identical.

StashMaker avatar Apr 22 '24 20:04 StashMaker

Ah yes, sorry I was wrong. Since the commit output is a custom output it won't show up in Sparrow. The backup key should be stored in the Bitcoin Core wallet though. I'll figure out what commands to run to recover.

raphjaph avatar Apr 22 '24 20:04 raphjaph

I was able to manually create a transaction. The commit output is locked because when you etch we don't want to accidentally spend the commitment. You have to be really careful when constructing transactions manually since the fee is implicit. Before trying to do that just try unlocking the locked commit output and then try sending with ord again. I'll continue trying to drill down.

> bitcoin-cli -datadir=env -rpcwallet=ord lockunspent true "[{\"txid\":\"33b61355d732a771465c991bbd0c4e7ca0b7b150ee2fac4f94f95adb244aa83f\",\"vout\":0}]"

true


> bitcoin-cli -datadir=env -rpcwallet=ord listunspent | jq '.[] | select(.address == "bcrt1pzrfzdzyzna2gutqw83sw3x0gjyvfuyqc666mgf3rdz2jde49mhvqf75gqh")'

{
  "txid": "33b61355d732a771465c991bbd0c4e7ca0b7b150ee2fac4f94f95adb244aa83f",
  "vout": 0,
  "address": "bcrt1pzrfzdzyzna2gutqw83sw3x0gjyvfuyqc666mgf3rdz2jde49mhvqf75gqh",
  "label": "commit tx recovery key",
  "scriptPubKey": "512010d22688829f548e2c0e3c60e899e891189e1018d6b5b42623689526e6a5ddd8",
  "amount": 0.00021159,
  "confirmations": 1,
  "spendable": true,
  "solvable": true,
  "desc": "rawtr([9adbd87e]10d22688829f548e2c0e3c60e899e891189e1018d6b5b42623689526e6a5ddd8)#f2k6008h",
  "parent_descs": [
    "rawtr(10d22688829f548e2c0e3c60e899e891189e1018d6b5b42623689526e6a5ddd8)#6p7wgsn0"
  ],
  "safe": true
}


> bitcoin-cli -datadir=env -rpcwallet=ord createrawtransaction "[{\"txid\":\"33b61355d732a771465c991bbd0c4e7ca0b7b150ee2fac4f94f95adb244aa83f\",\"vout\":0}]" "[{\"bcrt1ps09gd4jyg9u5kx0gg2clv0gxddtzmtujq3s99vaxaszkf6f8f96qv2exg0\":0.00021000}]"

02000000013fa84a24db5af9944fac2fee50b1b7a07c4e0cbd1b995c4671a732d75513b6330000000000fdffffff01085200000000000022512083ca86d64441794b19e842b1f63d066b562daf92046052b3a6ec0564e927497400000000


> bitcoin-cli -datadir=env -rpcwallet=ord signrawtransactionwithwallet 02000000013fa84a24db5af9944fac2fee50b1b7a07c4e0cbd1b995c4671a732d75513b6330000000000fdffffff01085200000000000022512083ca86d64441794b19e842b1f63d066b562daf92046052b3a6ec0564e927497400000000

{
  "hex": "020000000001013fa84a24db5af9944fac2fee50b1b7a07c4e0cbd1b995c4671a732d75513b6330000000000fdffffff01085200000000000022512083ca86d64441794b19e842b1f63d066b562daf92046052b3a6ec0564e927497401404f935f0a40a4e76dec6ad36080527e6957a37c737da2a1831073ee541b9dab6326ceedb3fd0cdcf57809d0cd06e89f5931d18677b71f6661978b26bcb4c01ba400000000",
  "complete": true
}


> bitcoin-cli -datadir=env -rpcwallet=ord sendrawtransaction 020000000001013fa84a24db5af9944fac2fee50b1b7a07c4e0cbd1b995c4671a732d75513b6330000000000fdffffff01085200000000000022512083ca86d64441794b19e842b1f63d066b562daf92046052b3a6ec0564e927497401404f935f0a40a4e76dec6ad36080527e6957a37c737da2a1831073ee541b9dab6326ceedb3fd0cdcf57809d0cd06e89f5931d18677b71f6661978b26bcb4c01ba400000000

1aac9491cdc24dd96cd60683d7301e5e599404f92874a207117343afa4e1fe9e

raphjaph avatar Apr 22 '24 22:04 raphjaph

If you do ord wallet dump the rawtr(.... is the descriptor of the backup key to the commit output. You could also try importing just that into a new wallet and spending from there.

raphjaph avatar Apr 22 '24 22:04 raphjaph

When I try to manually create the tx with bitcoin-cli, I get an error using the lockunspent command and an error when signing the tx...

bitcoin-cli -rpcwallet=etching2 lockunspent true "[{\"txid\":\"495e00dabe1ce6d1cfc0c83d83e756134f73037dad4fa60977be9955a03ffd94\",\"vout\":0}]"
error code: -8
error message:
Invalid parameter, expected locked output

bitcoin-cli -rpcwallet=etching2 createrawtransaction "[{\"txid\":\"495e00dabe1ce6d1cfc0c83d83e756134f73037dad4fa60977be9955a03ffd94\",\"vout\":0}]" "[{\"3NU5MVmiQuweKM6o3odkFfV1apkBFfqyQo\":0.0495}]"
020000000194fd3fa05599be7709a64fad7d03734f1356e7833dc8c0cfd1e61cbeda005e490000000000fdffffff01f0874b000000000017a914e3e818ece31f8bbf2cbb65aac6b22ea51d0ddb158700000000

bitcoin-cli -rpcwallet=etching2 signrawtransactionwithwallet 020000000194fd3fa05599be7709a64fad7d03734f1356e7833dc8c0cfd1e61cbeda005e490000000000fdffffff01f0874b000000000017a914e3e818ece31f8bbf2cbb65aac6b22ea51d0ddb158700000000
{
  "hex": "020000000194fd3fa05599be7709a64fad7d03734f1356e7833dc8c0cfd1e61cbeda005e490000000000fdffffff01f0874b000000000017a914e3e818ece31f8bbf2cbb65aac6b22ea51d0ddb158700000000",
  "complete": false,
  "errors": [
    {
      "txid": "495e00dabe1ce6d1cfc0c83d83e756134f73037dad4fa60977be9955a03ffd94",
      "vout": 0,
      "witness": [
      ],
      "scriptSig": "",
      "sequence": 4294967293,
      "error": "Witness program was passed an empty witness"
    }
  ]
}

loon3 avatar Apr 22 '24 23:04 loon3

If you do ord wallet dump the rawtr(.... is the descriptor of the backup key to the commit output. You could also try importing just that into a new wallet and spending from there.

This is useful. However, you need to use the 'ord.exe wallet dump' command instead of 'bitcoin-cli.exe listunspent' to obtain the rawtr, as the rawtr information obtained from these two methods is different. Once you have the rawtr, you can use 'bitcoin-cli.exe importdescriptors' to import it into the Bitcoin Core wallet and then send it.

Thanks to @raphjaph .

huguojunsy avatar Apr 23 '24 11:04 huguojunsy

This is useful. However, you need to use the 'ord.exe dump' command instead of 'bitcoin-cli.exe listunspent' to obtain the raw transaction, as the raw transaction information obtained from these two methods is different. Once you have the raw transaction, you can use 'bitcoin-cli.exe importdescriptors' to import it into the Bitcoin Core wallet and then send it.

This worked for me!

ord wallet dump then using the descriptors array from the dump bitcoin-cli importdescriptors "[{\"desc\": \"rawtr(... (if using Windows remember to escape the inner quotes)

Then I just created a simple transaction and was able to sign it no problem.

bitcoin-cli createrawtransaction "[{\"txid\":\"...

bitcoin-cli signrawtransactionwithwallet 02000...

bitcoin-cli sendrawtransaction 02000...

Thanks @raphjaph and @huguojunsy !

loon3 avatar Apr 23 '24 15:04 loon3

If you do ord wallet dump the rawtr(.... is the descriptor of the backup key to the commit output. You could also try importing just that into a new wallet and spending from there.

This works!

  • ord wallet dump to reveal the descriptors
  • copy/paste the one that contains the transaction you want to restore
  • create a new Bitcoin Core wallet with bitcoin-cli createwallet walletName or
  • load an exiting Bitcoin Core wallet with bitcoin-cli loadwallet walletName
  • construct the importdescriptor command like so:
bitcoin-cli -rpcwallet=walletName importdescriptors  '[
  {
    "desc": "the descriptor",
    "timestamp": 1713530220
  }
]'
  • check the balance with bitcoin-cli -rpcwallet=walletName getbalance
  • and then follow the steps described by Raph to manually construct, sign and send a new transaction to a new address of your choice.

Thanks to all of your guys for your engagement. @raphjaph @huguojunsy @loon3

StashMaker avatar Apr 23 '24 16:04 StashMaker

Thanks for the guide everyone!

A couple things: If you're struggling with mandatory-script-verify-flag-failed check if you are passing to sendrawtransaction the hex from signrawtransactionwithwallet and not from createrawtransaction.

In createrawtransaction put what you got in the output minus how much you want to spend on gas. Put too little and you will overspend, put too much and your transaction will be stuck.

big-soulja avatar Apr 23 '24 19:04 big-soulja

This is useful. However, you need to use the 'ord.exe dump' command instead of 'bitcoin-cli.exe listunspent' to obtain the raw transaction, as the raw transaction information obtained from these two methods is different. Once you have the raw transaction, you can use 'bitcoin-cli.exe importdescriptors' to import it into the Bitcoin Core wallet and then send it.

This worked for me!

ord wallet dump then using the descriptors array from the dump bitcoin-cli importdescriptors "[{\"desc\": \"rawtr(... (if using Windows remember to escape the inner quotes)

Then I just created a simple transaction and was able to sign it no problem.

bitcoin-cli createrawtransaction "[{\"txid\":\"...

bitcoin-cli signrawtransactionwithwallet 02000...

bitcoin-cli sendrawtransaction 02000...

Thanks @raphjaph and @huguojunsy !

I imported the descriptors using bitcoin-cli and was able to go back and use ord wallet --name walletName send without a hassle. No need to create the raw transaction or anything.

AryanJ-NYC avatar Apr 25 '24 15:04 AryanJ-NYC