Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dooglus opened this issue Apr 10, 2021 · 3 comments
Open

Comments

@dooglus
Copy link
Contributor

dooglus commented Apr 10, 2021

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;
     }
@dooglus dooglus changed the title RPC importprunedfunds doesn't allo importing spending txs, only receiving txs RPC importprunedfunds doesn't allow importing spending txs, only receiving txs Apr 10, 2021
@ghost
Copy link

ghost commented Apr 11, 2021

I noticed one of my wallets shows that I own funds that I really don't.

How can I reproduce it?

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.

Sounds interesting and also never used this RPC command. Reading the things mentioned here: https://bitcoincore.org/en/doc/0.21.0/rpc/wallet/importprunedfunds/ still not sure when does this help users.

I made the following change and then was able to import the missing transaction:

If this resolves the issue and doesn't break anything else, maybe a PR can be created for it?

@jamesob
Copy link
Member

jamesob commented Jan 3, 2022

@dooglus any interest in making a PR for this? The "good first issue" label might apply here.

@dooglus
Copy link
Contributor Author

dooglus commented Jan 4, 2022

I've not had much luck making PRs. I don't have enough energy to fight for them to be reviewed and merged. I hope this issue makes the problem and the solution clear enough that anyone interested can fix it.

If the "good first issue" label might help please feel free to apply it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants