Repository navigation
Conversation
Restore the coins of a descriptor wallet on a pruned node, where a rescan is no longer possible. The --utxo mode finds the wallet's unspent outputs with scantxoutset, fetches pruned blocks from a NODE_NETWORK peer with getblockfrompeer, builds a proof with gettxoutproof and imports each transaction with importprunedfunds. The functional test funds a wallet on a pruned node in blocks that are then pruned, imports its descriptors into a fresh wallet without rescan and checks that the tool restores the balance, including an output beyond the initial keypool that is only found on a rerun with lookahead.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A pruned node can't rescan blocks it has already deleted, so a descriptor imported into a fresh wallet with an old timestamp ends up with no history. This adds
contrib/wallet-tools/import-pruned.py, which rebuilds it throughimportprunedfunds, the one wallet RPC that works without block data: it only needs the raw transaction and a merkle proof against a header the node still has.The first mode,
--utxo, restores the wallet's coins from the node's own UTXO set:scantxoutsetwith the wallet's descriptors, plus a configurable--lookaheadbeyond the keypoolgetblockfrompeerfrom a NODE_NETWORK peer for each block that was prunedgettxoutproofandgetrawtransactionas soon as the block arrives, since it may be pruned againimportprunedfunds, in derivation order so the keypool tops up as it would during a rescanUsage:
Pass
--cli "bitcoin-cli -signet"or similar to reach a non-default node, and--dry-runto only list what would be imported.Only currently unspent coins are restored, so the balance is correct but spent history is not. Other modes, e.g. starting from a list of txids or from a script history index, can be added later.
A functional test funds a wallet on a
-prune=1 -fastprunenode, prunes those blocks, imports the descriptors into a blank wallet and checks that the tool restores the balance.