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

wallet: add test-only helper to clear in-memory transaction state

Public commit record

What the developer wrote

Authored by brunoerg

95/100 · Strong
wallet: add test-only helper to clear in-memory transaction state

Add CWallet::ClearInMemoryTxStateForTest(), which drops mapWallet,
wtxOrdered, mapTxSpends, m_txos and m_locked_coins, leaving the
database, the wallet flags and the ScriptPubKeyMans untouched.

This exists so that fuzz harnesses can reuse a single wallet across
inputs instead of rebuilding it for every one. m_txos and mapTxSpends
are private, so a harness cannot reset them on its own.

RemoveTxs() is not usable here: it erases each transaction's
m_it_wtxOrdered from wtxOrdered, and that iterator is only valid for
transactions added through AddToWallet(). Harnesses that populate
mapWallet directly leave it uninitialized.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit adds a private, test-only helper function to Bitcoin Core's wallet that clears in-memory transaction tracking data. It is explicitly labeled for testing/fuzzing use, requires an internal lock to be held, and does not touch the wallet database, keys, or flags. There is no indication it is used in normal wallet operation or exposed to users.

Recommended action

No security action required. Treat as normal code hygiene for fuzzing infrastructure. If reviewing further, verify that fuzz harnesses using this helper do not accidentally rely on stale database state after clearing in-memory caches.

Security signals we found

01

Test-only helper with explicit 'ForTest' naming and comment

02

Requires cs_wallet lock; does not bypass synchronization

03

Does not modify persistent wallet database or key material

04

No production callers or external interfaces introduced

05

No incident or vulnerability disclosure references supplied

Risk score

Why this scored 15/100

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