The scanblocks
RPC call allows one to get relevant blockhashes from a set of descriptors by scanning all blockfilters in a given range.
Example:
scanblocks start '["addr(<bitcoin_address>)"]' 661000
(returns relevant blockhashes for <bitcoin_address>
from blockrange 661000->tip)
Why is this useful?
Fast wallet rescans: get the relevant blocks and only rescan those via rescanblockchain getblockheader(<hash>)[height] getblockheader(<hash>)[height])
. A future PR may add an option to allow to provide an array of blockhashes to rescanblockchain
.
prune wallet rescans: (needs additional changes): together with a call to fetch blocks from the p2p network if they have been pruned, it would allow to rescan wallets back to the genesis block in pruned mode (relevant #15946).
SPV mode (needs additional changes): it would be possible to build the blockfilterindex from the p2p network (rather then deriving them from the blocks) and thus allow some sort of hybrid-SPV mode with moderate bandwidth consumption (related #9483)