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

chaintopology: fix RBF loop that never stops after replacement tx confirms

Public commit record

What the developer wrote

Authored by enaples

85/100 · Strong
chaintopology: fix RBF loop that never stops after replacement tx confirms

After consider_onchain_rebroadcast() creates a higher-fee replacement,
rebroadcast_txs() calls refresh() which updates otx->tx in-place, but
the confirmation guard still queries the original otx->txid (the map key):

if (wallet_transaction_height(topo->ld->wallet, &otx->txid))
continue;

Because the original tx was never mined (only the replacement was),
wallet_transaction_height always returns 0 and the RBF loop fires on
every subsequent block forever, even after the channel is fully resolved.

Fix: compute cur_txid from the current otx->tx before the guard. This
naturally reflects any replacement made by a prior refresh() call, so
wallet_transaction_height finds the confirmed txid and skips the entry.

otx->txid (the hash-map key) is intentionally left unchanged: mutating
the key in-place while the entry lives in the map would corrupt the table.

Changelog-Fixed: chaintopology: stop the on-chain RBF rebroadcast loop once a fee-bumped replacement transaction confirms; previously the loop kept firing on every new block forever.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This fix resolves a bug where Core Lightning would keep trying to replace a transaction with a higher-fee version forever, even after the replacement had already been confirmed on the Bitcoin blockchain. The loop happened because the code checked the old transaction ID instead of the current one. This wasted resources, created unnecessary transactions, and could bloat the wallet or leak funds through repeated fees.

Recommended action

Apply the patch. Monitor affected nodes for unusually high numbers of RBF replacement transactions in on-chain channel-close flows, and consider wallet cleanup if the bug has already triggered.

Security signals we found

01

CWE-835: Infinite Loop

02

Resource exhaustion via repeated on-chain transaction creation

03

Potential fee loss / wallet bloat from perpetual RBF replacements

04

Logic error using stale key instead of current transaction state

Risk score

Why this scored 59/100

Our methodology →
Potential impact 18/30
Exploitability 5/25
Stealth signal 10/15
Affected reach 12/15
Confidence 9/10
Evidence quality 5/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.