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

Merge bitcoin/bitcoin#34371: wallet: allow importprunedfunds for spending transactions

Public commit record

What the developer wrote

Authored by Ava Chow

91/100 · Strong
Merge bitcoin/bitcoin#34371: wallet: allow importprunedfunds for spending transactions

c2da52d3660f178a9c11210216d295515988e89d wallet: allow importprunedfunds for spending transactions (8144225309)

Pull request description:

`importprunedfunds` only allowed importing transactions that credit the wallet
(checked via `IsMine`), rejecting transactions that spend from it. This could
leave a pruned wallet showing an incorrect balance: if a spending transaction
was removed with `removeprunedfunds`, it couldn't be re-imported and would fail
with "No addresses in wallet correspond to included transaction".

This routes the import through `AddToWalletIfInvolvingMe()`, which already
checks both `IsMine()` and `IsFromMe()`, so spending transactions are accepted
and the involvement check is no longer duplicated in `importprunedfunds`. A
functional test imports a transaction that spends from the wallet but has no
outputs to it (entire UTXO sent externally).

Fixes #21647

ACKs for top commit:
achow101:
ACK c2da52d3660f178a9c11210216d295515988e89d
Bicaru20:
re-ACK c2da52d366

Tree-SHA512: 0ece38c75d3608948f1c29c5fca29b6420197b0a153e361decf232fd27edd5dd1f2e5d6f9625eee6f7691abd9992f95ef89c904d486ee927d03c88475e479b9c
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This change fixes a Bitcoin Core wallet bug where the `importprunedfunds` RPC command could only re-import transactions that sent money to the wallet, not transactions that spent money from it. After this fix, both incoming and outgoing transactions can be re-imported, so a pruned wallet's balance and transaction history stay accurate.

Recommended action

No immediate security response required; this is a correctness fix for wallet balance accuracy. Users running pruned wallets who rely on `importprunedfunds` should upgrade to a release containing this fix to avoid incorrect balances after removing spending transactions.

Security signals we found

01

Logic bug in wallet transaction import scope

02

Incorrect balance possible after removing and re-importing spending transaction

03

Fix routes import through existing involvement check (IsMine + IsFromMe)

04

Functional test added for spending-transaction re-import

Risk score

Why this scored 32/100

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