RPC importprunedfunds doesn't allow importing spending txs, only receiving txs
- Dominant language
- C++
- Stars
- 90.2k
- Forks
- 39.4k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 88
Description
I noticed one of my wallets shows that I own funds that I really don't. I identified the spending transaction and tried to import it using 'importprunedfunds' but was told:
`No addresses in wallet correspond to included transaction`
It turns out that 'importprunedfunds' only allows you to import txs which credit an address owned by your wallet. It won't let you import txs which spend from addresses owned by your wallet.
I made the following change and then was able to import the missing transaction:
--- a/src/wallet/rpcdump.cpp
+++ b/src/wallet/rpcdump.cpp
@@ -372,7 +372,7 @@ RPCHelpMan importprunedfunds()
CWalletTx::Confirmation confirm(CWalletTx::Status::CONFIRMED, height, merkleBlock.header.GetHash(), txnIndex);
CTransactionRef tx_ref = MakeTransactionRef(tx);
- if (pwallet->IsMine(*tx_ref)) {
+ if (pwallet->IsMine(*tx_ref) || pwallet->IsFromMe(*tx_ref)) {
pwallet->AddToWallet(std::move(tx_ref), confirm);
return NullUniValue;
}
Contributor guide
Research direction
Start in src/wallet/rpcdump.cpp at the importprunedfunds handler and review how it decides whether a transaction belongs to the wallet. Verify the reported spending transaction can be imported while existing receiving-transaction behavior remains unchanged, then add or update coverage if the surrounding wallet tests provide a suitable entry point.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100