BOMBARCHIVE
Explore

A living reference collection. Written in the wiki, preserved in Git.

The archiveBitcoin

Old revision: BIP 158

OshiB: document BIP 158 filter contents, exclusion boundaries and historical milestones

BIP 158, Compact Block Filters for Light Clients, specifies the deterministic, compressed block filters used by the BIP 157 network protocol. Its authors are Olaoluwa Osuntokun and Alex Akselrod; its assigned date is 24 May 2017. The distinction is deliberate: BIP 158 defines what a filter contains and how to encode it, while BIP 157 defines how Bitcoin peers exchange, compare and check filters. Maintained BIP 158 specification

A block's scripts in a compact search structure

The initial and specified type is basic, code 0x00. For every transaction in a block, its filter includes the scriptPubKey of each new output except outputs whose script begins with OP_RETURN. For every non-coinbase input it also includes the scriptPubKey of the previous output being spent. These are script bytes, not printed wallet addresses, transaction identifiers or arbitrary transaction bodies. Duplicate input elements are treated as a set. Basic filter contents

That spent-output requirement matters when rebuilding a filter from Bitcoin history: the previous output's script is not necessarily written in the block being filtered. A construction system needs a trustworthy way to obtain the referenced output, such as validated historical block/UTXO data. It cannot faithfully derive a basic filter merely by scanning the current block's new output scripts. Filter content rules

The filter uses a Golomb-coded set (GCS), not a traditional Bloom filter. Its construction hashes the items to integers in a bounded range, sorts the integers, and compresses successive differences with Golomb–Rice coding. The specified basic parameters are P = 19 and M = 784931. The SipHash key is derived from the first 16 bytes of the block hash in its specified byte order. Each block therefore has reproducibly derived filter bytes for this filter type when the underlying chain data is fixed. Golomb-coded set, basic construction

A GCS member is guaranteed to match its correctly constructed filter; unrelated queried items can sometimes match by chance. The probability described by the BIP is governed by M. A match therefore says this block may be relevant. The client must fetch and inspect the full block to establish that it actually contains the script or transaction it wants. A non-match is meaningful only if the served filter is complete and authentic. Golomb-coded sets · BIP 157

What the basic filter deliberately leaves out

The OP_RETURN omission is an explicit specification choice. The BIP's rationale was to keep open a future possibility of committing filter data inside an OP_RETURN output without making construction depend on itself. That rationale documents a design option, not a claim that Bitcoin adopted such a consensus commitment. Basic filter, contents and rationale

For archival indexing, the scope is consequential. A BIP 158 basic filter does not index the raw contents of a witness, an inscription envelope, an OP_RETURN payload or a Bitmap District name. It indexes the specified scripts. It may help a wallet decide which blocks involve known scripts, but it is not an Ordinals search engine, a general full-text blockchain search service or a proof of application-level rules. This is an inference from the explicitly enumerated inputs to the filter, not a tested claim about any particular inscription indexer. Enumerated filter elements

Filter hashes and verification

BIP 158 specifies the serialized filter. BIP 157 hashes those bytes and constructs a chain of filter headers for peers to compare. A client can compare the header chains supplied by multiple peers, find a disagreement and download the disputed full block to recompute its correct filter.

The filter-header sequence is not committed to by Bitcoin block headers under this design. Without a truthful comparison source, several colluding peers could present identical false filter chains. The BIP 157 protocol describes its stronger assurances under an assumption that at least one contacted peer is honest. A filter alone is neither a Bitcoin proof-of-work certificate nor a proof that no relevant payment was hidden by a malicious server. Filter headers, client operation and rationale

A first-party development chronology

24 May 2017
The BIP's assigned date. It identifies a proposal, not a software-release milestone. BIP header
22 January 2018
The first identified bitcoin/bips commit adds the BIP 157 and 158 texts together. The later maintained document includes further revisions, so its exact wording should not be attributed wholesale to this initial record. Repository addition
26 August 2018
Bitcoin Core merged its BIP 158 filter-construction implementation. The PR explicitly stated that the code was **not yet used elsewhere in Core**; no peer service was established by this merge. Merged construction PR
14 September 2018
Lightning Labs announced Neutrino light-client support in lnd 0.5-beta and an associated testnet Lightning App alpha. It documented real implementation work, with mainnet adoption beyond this announcement still a separate question. Contemporary release announcement
18 April 2019
Bitcoin Core merged the persistent BlockFilterIndex, which stores filters, their hashes and filter headers. The PR described a roughly 3.8-GiB index at its then-tested height 565500; that is a historical benchmark, not the index's current size. Merged index PR and measured size
24 November 2019
Bitcoin Core 0.19.0.1 released -blockfilterindex and the getblockfilter RPC, with release notes estimating roughly **4 GiB** for the historical index at that time. The release expressly **did not** offer filter retrieval over the P2P network. Release notes · Dated release notice
14 January 2021
Bitcoin Core 0.21.0 shipped the ability to **serve** BIP 157 filters over P2P with -blockfilterindex=1 -peerblockfilters=1. This was an explicitly configured service, not an automatic consequence of running a default node. Release notes
11 September 2025
The BIPs repository promoted BIP 158's metadata from **Draft** to **Final**, alongside BIP 157. A separate commit added mutual Requires references. The documents themselves and the implementation precede this status change by years. BIP 158 status · Cross-reference update
12 January 2026
A broad maintenance commit changed BIP metadata from **Final** or **Active** to **Deployed**. The current BIP 158 header uses that label, but the commit is not a node census or first-deployment event. Repository-wide status migration

Different indexes, different promises

The BlockFilterIndex is a compact search aid for wallet-relevant scripts. A full transaction index can locate historical transaction identifiers, while an Ordinals index parses inscription envelopes and determines application-specific identities and ordering. These structures answer different questions and may be operated together; their names and capabilities should not be exchanged.

BIP 152's compact blocks are also different. BIP 152 reduces redundant block-relay data between peers who have already seen many transactions. BIP 158 summarises scripts in confirmed blocks for light-client scanning. The similar adjective compact hides a different purpose. BIP 152 · BIP 158

Open research

Open question
Compare the first 2018 BIP 158 draft with the maintained specification and identify any changes that altered filter bytes, rather than merely documentation or status.
Open question
Reproduce basic filter bytes for a small set of archived mainnet blocks using two independent implementations, including spent-prevout scripts and OP_RETURN exclusions. Record block hashes, software versions and results.
Open question
Establish measured 2026 filter-index size and coverage on a configured Bitcoin Core release; do not reuse the 2019 4-GiB estimate as a timeless storage requirement.