ord icon indicating copy to clipboard operation
ord copied to clipboard

Trigger wallet rescan on wallet import/restore

Open windsok opened this issue 2 years ago • 5 comments

One user reported that after importing a wallet they originally created with Sparrow, ord was not showing any of the inscriptions they had received to the wallet. To fix the issue they initiated a manual rescan with rescanblockchain using bitcoin-cli.

Not sure if they did something weird when restoring the wallet, or if we need to add some logic to automatically trigger a rescan in bitcoin core when wallets are imported.

windsok avatar Feb 08 '23 16:02 windsok

Hmmm, interesting. If they ran ord wallet restore, and their outputs didn't show up, then we should look into that. If they imported descriptors manually, then maybe we can make sure the wallet is synced?

@raphjaph added a Wallet struct, and we can perform any initialization of the wallet, like making sure it's loaded and synced.

https://github.com/casey/ord/commit/a9f9e70b739a238471ee062906e7cb268e711be5

casey avatar Feb 08 '23 16:02 casey

Rescans can take quite a while so would be hesitant to call rescanblockchain for every wallet command. So probably own command or only on ord wallet restore.

raphjaph avatar Feb 08 '23 21:02 raphjaph

We can limit the rescan to start from the block containing the genesis inscription - 767340

I did a test restore and rescan and it took 51 seconds on my machine. This will obviously get slower as the chain get's longer though.

windsok avatar Feb 09 '23 03:02 windsok

I think the latest Bitcoin core release also uses compact block filters for rescanning. So if a user has blockfilterindex=1 and we start from first inscription height it will likely be single digit seconds.

andrewtoth avatar Feb 17 '23 04:02 andrewtoth

I had a wallet I restored that received inscriptions about a year ago.

When I restored it into ord, the Bitcoin Core logs returned that it has only rescanned back 23 blocks: [ord] RescanFromTime: Rescanning last 23 blocks

To remedy I had to kick off a manual rescan on the wallet: bitcoin-cli -rpcwallet=ord rescanblockchain 767430

kaloudis avatar Mar 28 '24 15:03 kaloudis