THAMER
Sovereign Bitcoin Wallet

WALLET AI BITCOIN

Your Bitcoin Wallet. Your Keys. Your Engine.

Self-hosted Bitcoin software built for developers, applications, and AI agents.

CREATE WALLET

Bitcoin Wallet Recovery: Descriptor Coverage, Historical Scans, and Reconciliation

permalink THAMER
#bitcoin#descriptors#reconciliation#wallet-recovery

A robust Bitcoin wallet recovery process separates four concerns: identifying wallet scripts, discovering current unspent outputs, reconstructing historical transactions and synchronizing live state. A single successful RPC response cannot establish that all four are complete.

Establish script coverage

Recover the original wallet policy and derivation information. A seed alone may not specify the address type, account indexes, multisignature cosigners or custom script policy. Import or derive the correct external and change descriptors. Track the highest known used indexes and any issuance records available from backups. A fixed discovery range is not proof that no addresses exist beyond it.

Discover confirmed outputs

Use scantxoutset when a current confirmed UTXO inventory is needed independently of historical wallet import. Record each matching outpoint, amount, script and scan anchor. Store amounts as integer satoshis. Distinguish confirmed unspent outputs from outputs currently spent by mempool transactions and outputs that cannot yet be spent due to maturity or policy constraints.

Reconstruct history separately

Use a wallet rescan over available blocks or a filter-assisted search followed by full transaction inspection. A historical scan can reveal transactions whose outputs are no longer in the UTXO set. If required blocks are missing, report incomplete history rather than silently replacing it with the current balance.

A practical recovery record might contain descriptor coverage, scan start and stop heights, best block hash, missing block ranges and a separate history-complete flag. These are application-level fields, not standard Bitcoin Core RPC response fields.

Reconcile live changes

Blocks and mempool contents can change while recovery is running. Compare the recorded chain anchor against the active chain before committing the result. Process newly connected blocks, undo disconnected blocks and refresh relevant mempool state. If continuity cannot be established, repeat the affected discovery step.

Define readiness precisely

A watch-only wallet may be ready to display confirmed outputs but unable to sign. A recovered signing wallet may have correct keys but incomplete history. Expose these states independently. Test recovery on a controlled network with both receive and change outputs, a spent historical deposit and an interrupted scan. The objective is reproducible state recovery, not merely a nonzero balance.

Primary references

https://github.com/bitcoin/bips/blob/master/bip-0380.mediawiki

https://bitcoincore.org/en/doc/28.0.0/rpc/wallet/importdescriptors/

Questions & Answers

Explore all questions →

Latest from the Lab

THAMER illustrated developer portrait and signature

ABOUT THE DEVELOPER

Independent Software Developer specializing in Bitcoin Script, Golang, and AI Agents.

Software engineering · Independent research · Open-source projects