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

wallet: fix removeprunedfunds bug with conflicting transactions

Public commit record

What the developer wrote

Authored by Martin Zumsande

85/100 · Strong
wallet: fix removeprunedfunds bug with conflicting transactions

removeprunedfunds removes all entries from mapTxSpends for the
inputs of the pruned tx. However, this is incorrect, because there could be
multiple entries from conflicting transactions (that shouldn't be
removed as well). This could lead to the wallet creating invalid
transactions, trying to double spend utxos.
The bug persists when the conflicting tx was mined, because
the wallet trusts its internal accounting instead of calling
AddToSpends again.
✓ 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 commit fixes a bug in Bitcoin Core's wallet where removing a pruned transaction could accidentally delete records of other conflicting transactions that spend the same coin. As a result, the wallet might mistakenly believe a coin was still available and create an invalid double-spend transaction. The fix ensures only the specific pruned transaction's spend records are removed, leaving conflicting transactions intact.

Recommended action

Apply the patch to ensure RemoveTxs only deletes the specific mapTxSpends entries belonging to the removed transaction. Users running wallet software with removeprunedfunds should upgrade to a version containing this fix, especially if they use RBF/conflicting transactions or pruning workflows.

Security signals we found

01

Incorrect multimap erase logic leading to loss of conflicting spend tracking

02

Wallet internal accounting could be corrupted, enabling creation of invalid double-spend transactions

03

Bug persists even when conflicting transaction is mined because wallet trusts corrupted internal state

04

Fix includes regression test covering conflicting transaction scenario

Risk score

Why this scored 60/100

Our methodology →
Potential impact 18/30
Exploitability 10/25
Stealth signal 8/15
Affected reach 10/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.