Skip to content

RPC importprunedfunds doesn't allow importing spending txs, only receiving txs #21647

@dooglus

Description

@dooglus

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;
     }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions