BIP 157/158 (Client-Side Block Filtering)
Client-side filtering that lets light wallets find their own transactions without telling a server which addresses they own.
Basically
BIP 157 and BIP 158 let your wallet check for relevant Bitcoin transactions without downloading every block. They keep your addresses and transaction interests private from the nodes you connect to.
Key Takeaways
- BIP 157 and BIP 158 replace BIP 37 Bloom filters with a privacy-preserving alternative for light clients. The server never learns which addresses or transactions your client cares about.
- BIP 158 defines how to build compact block filters using Golomb-Rice coding. BIP 157 defines the peer-to-peer protocol for requesting and serving those filters.
- Neutrino, the reference implementation built by Lightning Labs, powers light-client mode in LND. It enables mobile wallets to verify transactions without running a full node or leaking financial data to third parties.
What Is BIP 157/158?
BIP 157 and BIP 158 are two complementary Bitcoin Improvement Proposals. Together, they enable client-side block filtering, so a light client can check whether a block contains relevant transactions without downloading the whole block or revealing its interests to the serving node.
BIP 158, authored by Olaoluwa Osuntokun and Alex Akselrod, specifies how to construct compact probabilistic filters for each block using Golomb-Rice coding. BIP 157, authored by the same pair along with Jim Posen, specifies the peer-to-peer network messages that light clients use to request these filters from full nodes.
The core insight reverses who holds the filter. Under BIP 37, the client sends its filter to the server, effectively telling the server what it is looking for. Under BIP 157/158, the server sends a deterministic filter to the client, the client checks it locally, and the server learns nothing about the client's wallet.
Why BIP 37 Bloom Filters Failed
BIP 37 was Bitcoin's original protocol for SPV light clients. The client would construct a Bloom filter containing its addresses and send it to a full node, which would then stream only the matching transactions and save the client from downloading entire blocks.
The privacy model relied on the Bloom filter's false-positive rate: if the filter matched some transactions the client did not care about, the server could not tell which matches were real. The protection collapsed in practice for several reasons.
Bitcoin Core disabled BIP 37 Bloom filter serving by default in version 0.19.0, effectively deprecating the protocol. BIP 157/158 was designed as the replacement.
How It Works
The system has two layers. BIP 158 handles filter construction, and BIP 157 handles filter delivery over the network.
BIP 158: Building the Filter
A full node builds a compact filter for each block over the set of scripts that appear in that block. The basic filter type (type 0x00) includes all scriptPubKeys from the outputs created by the block's transactions, plus all scriptPubKeys spent by the block's inputs. These scripts capture every address that sends or receives funds in that block.
The construction process works as follows. The basic filter type uses fixed parameters.
The specification sets P = 19 and M = 784,931 for the basic filter type. These values minimise total bandwidth: too low an M means the client downloads too many false-positive blocks, while too high an M makes the filters themselves large. The optimal M is approximately 1.497137 × 2^P, which yields 784,931 when P = 19, giving a false-positive rate of 1/M, or roughly 1 in 784,931 per element queried.
BIP 157: Fetching Filters Over the Network
BIP 157 adds six new P2P network messages. Light clients use these messages to request and receive filters.
A full node advertises its willingness to serve filters through the NODE_COMPACT_FILTERS service bit. When a light client connects, the typical sync flow is as follows.
The filter headers form a hash chain: each header is the double-SHA-256 of the filter's hash concatenated with the previous filter header. Clients can detect tampered or omitted filters by cross-checking headers from multiple peers.
Technical Example
A light client checks whether a block contains transactions for its addresses as follows. The check uses compact block filters.
Neutrino: The Reference Implementation
Neutrino is the reference implementation of BIP 157/158, built by Lightning Labs in Go. It is a Bitcoin light client library that syncs the blockchain using compact block filters rather than downloading full blocks or relying on trusted third-party APIs.
Lightning Labs integrated Neutrino into LND starting with version 0.5-beta in September 2018. In Neutrino mode, an LND node syncs the Bitcoin blockchain by downloading only block headers and compact filters, then fetching full blocks only when a filter matches a channel-relevant transaction. This approach greatly reduces storage and bandwidth requirements while maintaining privacy.
Neutrino removes the need for mobile Lightning wallets and applications built on LND to trust a specific server with wallet address data. Your wallet connects directly to the Bitcoin P2P network and downloads filters from multiple peers. It verifies everything locally.
Mobile and Resource-Constrained Wallets
Mobile Bitcoin wallets cannot run full nodes because of storage, bandwidth, and battery constraints. Before BIP 157/158, you had two options: trust a centralised server (Electrum-style) or use BIP 37 Bloom filters, which leak address data. Compact block filters provide a third path: light clients that are both private and trustless.
Lightning Network Light Clients
Lightning nodes need to monitor the blockchain for channel-related transactions: funding transactions, cooperative closes, force closes, and potential breach attempts. A lightweight client using BIP 157/158 can watch for these events without a full node, enabling Lightning on mobile devices. LND's Neutrino mode operates this way and has been a key enabler for mobile Lightning adoption.
Privacy-Conscious Blockchain Scanning
You may want a private light client on your phone even if you run a full node at home. BIP 157/158 ensures that your phone does not leak wallet activity to whichever peers it connects to, giving you convenience without sacrificing privacy.
Bandwidth Cost
BIP 37 servers only sent matching transactions. BIP 157/158 clients download a filter for every block, regardless of whether the block is relevant. Each basic filter is roughly 15 to 20 KB for a typical block, and syncing the full chain from genesis requires downloading the entire filter chain.
The design trades higher bandwidth use for revealing nothing to the server. The total filter chain is still far smaller than the full blockchain. For a client that only needs recent blocks, such as a Lightning wallet, the overhead is modest.
False Positives Still Require Full Block Downloads
A filter match requires your client to download the full block to confirm. With a false-positive rate of about 1 in 784,931 per element, a wallet watching a small number of scripts will rarely encounter false positives. A wallet with thousands of addresses increases its chance of false matches, leading to more unnecessary block downloads.
No Filter for Transaction Completeness
A malicious full node could serve a valid but incomplete filter by omitting a script that should be included. The filter-header chain lets your client detect disagreements between peers: if two peers serve different filter headers for the same block, your client knows one is dishonest and can download the full block to verify. That check requires connecting to multiple honest peers, which is a weaker security assumption than running a full node.
Server-Side Resource Costs
Full nodes that serve compact block filters must build and store an additional index. BIP 158 filters are precomputed and deterministic, unlike BIP 37, where the server scans blocks on demand. Every honest node produces the same filter for the same block, which makes serving efficient but adds storage requirements for the filter and filter-header indexes.
Adoption
Both BIPs carry "Deployed" status in the BIP repository. Bitcoin Core added support for building and serving compact block filters, enabled via the -peerblockfilters configuration flag in conjunction with -blockfilterindex.
LND's Neutrino mode remains the most prominent consumer of BIP 157/158 filters. Other Bitcoin libraries and light-client implementations, including LDK and BDK, have explored integration with varying degrees of completeness. The protocol's privacy guarantees make it particularly relevant for light-client architectures in mobile wallets and second-layer systems like Lightning and Spark, where monitoring the base chain without leaking user data is essential.
The glossary entry is for informational purposes only and does not constitute financial or investment advice. You should always do your own research before using any protocol or technology.