AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 24 Bitcoin

chaintopology: don't use txfilter, rely on wallet_extract_owned_outputs.

Public commit record

What the developer wrote

Authored by Rusty Russell

73/100 · Adequate
chaintopology: don't use txfilter, rely on wallet_extract_owned_outputs.

txfilter.c keeps a hash with interface:
* INSERT: txfilter_add_scriptpubkey &txfilter_add_derkey
* SEARCH: txfilter_match & txfilter_scriptpubkey_matches. It simply returns true/false.

wallet.c keeps an our_addresses hash:
* INSERT: on-demand when asked based on max keyidx (plus gap)
* SEARCH: wallet_can_spend (and thus its caller wallet_extract_owned_outputs).

Here are the places which populate the txfilter:

lightningd/channel.c:
- When we generate our own address final address
=> this is already covered when we call wallet_get_newindex() to get the final_key_idx
lightningd/lightningd.c:
- init_txfilter initializes all the prior addresses
=> wallet_can_spend populates this on first call.
wallet/reservation.c:
- finish_psbt and json_addpsbtoutput for change output
=> this is already covered when get call wallet_get_newindex() in the same funciton.
wallet/wallet.c:
- got_utxo for unconfirmed outputs
=> This is called when we have already determined we can spend the output (wallet_extract_owned_outputs), or on the fixup migration where the addresses are populated from a keyindex we've already created.
wallet/walletrpc.c:
- newaddr_inner
=> Already covered by wallet_get_newindex()

The result: we can just rely on the wallet to find our addresses, and
we don't need the txfilter at all. Just make chaintopology ask the
wallet directly.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context
The short version

What changed, and why it matters

This commit removes an old shortcut (a Bloom-like 'txfilter') that Core Lightning used to guess whether a new Bitcoin block contained transactions relevant to the wallet. Instead, it now asks the wallet directly to identify which transaction outputs belong to the node. The change is a code simplification and likely a defensive fix: the old filter could in theory miss transactions or produce false positives, while the wallet lookup is authoritative. There is no direct evidence in the commit that this was exploited or that it caused a concrete loss of funds, but it touches the code that decides whether the node notices its own on-chain payments.

Recommended action

Treat as a hardening/simplification change rather than an active vulnerability. Reviewers should verify that wallet_extract_owned_outputs() reliably populates the wallet's our_addresses cache for every scriptPubKey the old txfilter would have matched, including change outputs, final addresses, and migration/fixup paths, so no UTXOs are missed during block scanning. Regression tests around block filtering and invoice_onchain_payment should be run.

Security signals we found

01

Removal of redundant address-matching filter in favor of authoritative wallet lookup

02

Change to on-chain output discovery path that affects UTXO detection and invoice payment recognition

03

Potential for missed or delayed UTXO detection if wallet_extract_owned_outputs population behavior differs from txfilter

04

No explicit bug, CVE, or exploit described in commit or references

Risk score

Why this scored 24/100

Our methodology →
Potential impact 5/30
Exploitability 3/25
Stealth signal 4/15
Affected reach 4/15
Confidence 5/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.