Insights on Crypto Payments, Infrastructure, and Operations

BIP 158 Compact Block Filters

Abbreviation: BIP 158

Pronunciation: BIP one-fifty-eight kuhm-PAKT BLOK FIL-ters

Also known as: BIP158 Compact Block Filter, Compact Block Filters, BIP 158

Definition

BIP 158 defines compact block filters as a Golomb-coded set representation of selected Bitcoin block data that lets light clients efficiently test whether a block may contain scripts relevant to them. It specifies the contents and Golomb-coded representation of Bitcoin’s basic compact block filter. The compact structure lets wallets test locally for scripts that may be relevant without sending those scripts to another node.

Overview

Meaning and scope

BIP 158 defines compact block filters as a Golomb-coded set representation of selected Bitcoin block data that lets light clients efficiently test whether a block may contain scripts relevant to them. It specifies the contents and Golomb-coded representation of Bitcoin’s basic compact block filter. The compact structure lets wallets test locally for scripts that may be relevant without sending those scripts to another node.

Mechanism and operation

BIP 158 specifies how the basic compact block filter is constructed. A node extracts defined elements from a block, including relevant output scripts and certain spent-output scripts, hashes them with a block-specific key, and encodes the resulting set using Golomb-Rice coding. A wallet can test its own scripts against the filter without revealing those scripts to the node serving the data. A positive result means the block may be relevant and should be downloaded or examined. The filters are compact enough to download for every block, making them useful for privacy-preserving lightweight wallets.

Practical payment example

A lightweight Bitcoin wallet downloads compact block filters, tests for likely relevant transactions and fetches matching blocks without receiving every transaction upfront.

Operational checks

Filter headers form a chain that allows clients to detect inconsistent filter data. BIP 157 defines the peer-to-peer protocol messages and verification workflow used to distribute the filters. The filter uses a block-specific key and an encoded set of defined script elements. A wallet transforms its own scripts according to the same rules and tests for possible membership.

Distinctions and limits

Because filters are probabilistic, a match can be a false positive, but a correctly created filter should not omit an included element. Correctly constructed filters should not omit included elements, but probabilistic matching can produce false positives.

Related definitions: compact block filter, block.

Example

A lightweight Bitcoin wallet downloads compact block filters, tests for likely relevant transactions and fetches matching blocks without receiving every transaction upfront.

Comparison

Because filters are probabilistic, a match can be a false positive, but a correctly created filter should not omit an included element. Correctly constructed filters should not omit included elements, but probabilistic matching can produce false positives.

Key Takeaway

BIP 158 defines Bitcoin’s compact filter data and encoding, while BIP 157 defines how clients retrieve and verify those filters from peers.

Sources

  1. BIP 158: Compact Block Filters — Bitcoin Improvement Proposals (2026-07-30)