Explainer

What is a Bitcoin compact block filter?

A compact block filter helps a Bitcoin wallet decide which blocks to download and why a filter match can still turn out to be a false positive.

3 min readGlossary
What is a Bitcoin compact block filter?

The short answer

A compact block filter is a small summary that helps a Bitcoin wallet decide which blocks to download. The wallet checks each filter on its own device for the payment scripts it watches. A match tells it to fetch and inspect that block. The full block is where the wallet finds the actual transaction and amount.

Bitcoin separates the two parts of this system. BIP 158 defines how to build the basic filter. BIP 157 defines how peers exchange filters and filter headers, which help clients check the filters they receive.

What a wallet checks

A payment script is the rule that controls how a transaction output can be spent. The basic filter covers scripts for outputs created in the block, with exceptions such as OP_RETURN, and scripts for earlier outputs spent by transactions in the block. That lets a wallet look for activity in both directions: a new payment to one of its scripts or a later spend of an output it was tracking. For the difference between an output and its spending condition, see Bitcoin UTXOs.

Suppose a wallet watches script A and receives three filters. It finds a match in the second and third. After downloading those two blocks, it finds a payment in the second and no matching transaction in the third. That extra download is expected. A correctly built filter matches every script it includes, but compression can also produce a false positive for a script absent from the block.

How to recognize it in practice

On a node running Bitcoin Core 32.1 with its basic block filter index enabled and synchronized, the documented getblockfilter RPC takes a block hash and returns a hex-encoded filter and filter header. If the filter is unavailable, check the index configuration and synchronization before concluding that the block is missing. The RPC was reviewed against the documentation and was not run for this entry.

The wallet can download the same filters as other clients without sending its watched scripts to peers. Requests for matching blocks can still reveal patterns, and a light client does not gain the full validation of a Bitcoin node. Filters cover confirmed blocks, so the absence of a match says nothing about an unconfirmed payment. A compact block serves a different purpose: it helps a node reconstruct a block from transactions it already has. A compact block filter helps a wallet decide whether to fetch the block in the first place.

Newsletter

Bitcoin, without the noise

What happened in Bitcoin, what it actually changes, and the sources so you can check us. One issue at a time, straight to your inbox.

  • One email per issue, never a drip campaign
  • No tracking pixels and no shared addresses
  • Unsubscribe from any issue in one click

Get the next issue

One email per issue, no tracking pixels, and unsubscribe from any of them. We do not share your address. Privacy policy