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 Core scanblocks: Descriptor Discovery With Compact Block Filters

permalink THAMER
#bip158#bitcoin#block-filters#scanblocks

Bitcoin Core's scanblocks RPC can search an available block filter index for blocks potentially relevant to output descriptors. It is a way to narrow historical discovery without reading every full block during the initial search. The basic filter format is defined by BIP158.

Candidate discovery

Basic filters include eligible output scripts and scripts of spent previous outputs. A wallet can use its known scripts to identify blocks that may contain either a receipt or a spend. Compact filters are probabilistic: a positive match can be a false positive. A filter match alone is not a payment record.

An illustrative query using a placeholder address is:

bitcoin-cli scanblocks start '["addr(ADDRESS)"]' 800000 810000

Replace ADDRESS and the heights with values appropriate to the wallet and network. This RPC requires the relevant block filter index to be available. Check getindexinfo and the node's RPC help for the installed version before using it.

Verifying candidate blocks

For each candidate block hash, obtain the actual block data and inspect transactions against the wallet's scripts and known outpoints. A spending input identifies a previous output by transaction ID and output index, not by a standalone destination address. Correct spend attribution therefore requires previous-output information or a maintained wallet UTXO map.

Some versions expose options for additional false-positive filtering; consult the local RPC help rather than assuming the option is universally available. Even when candidates are refined, an application still needs to construct its own relevant transaction records or use wallet RPCs to do so.

Pruned nodes and missing data

An index may retain filters for blocks whose full data has been pruned. Finding a candidate hash does not restore the corresponding block. Historical verification requires the missing data from an appropriate source. Do not report a complete transaction history merely because the filter search completed.

Handling chain changes

Record the scanned height range and chain anchors. If the active chain changes during or after processing, recheck affected block hashes and undo records belonging to disconnected blocks. Filter-assisted discovery is an optimization of the search process, not a replacement for active-chain reconciliation.

Primary references

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

https://bitcoincore.org/en/doc/28.0.0/rpc/blockchain/scanblocks/

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