wallet: allow importprunedfunds for spending transactions #34371

pull 8144225309 wants to merge 1 commits into bitcoin:master from 8144225309:fix-importprunedfunds-spending changing 2 files +17 −1
  1. 8144225309 commented at 3:54 pm on January 21, 2026: none

    Fixes #21647

    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”

    The fix adds IsFromMe() alongside IsMine(), matching the pattern used elsewhere in wallet code.

    A functional test imports a transaction that spends from the wallet but has no outputs to it (entire UTXO sent externally), verifying the new code path.

  2. DrahtBot added the label Wallet on Jan 21, 2026
  3. DrahtBot commented at 3:54 pm on January 21, 2026: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34371.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. in test/functional/wallet_importprunedfunds.py:124 in af80d2c367
    116@@ -117,6 +117,20 @@ def run_test(self):
    117         w1.removeprunedfunds(txnid3)
    118         assert not [tx for tx in w1.listtransactions() if tx['txid'] == txnid3]
    119 
    120+        # Import a spending transaction with no wallet outputs (issue #21647)
    121+        self.nodes[0].sendtoaddress(address3, 0.1)
    122+        self.generate(self.nodes[0], 1)
    123+        external_addr = self.nodes[0].getnewaddress()
    124+        spend_txid = w1.sendtoaddress(address=external_addr, amount=0.1, subtractfeefromamount=True)
    


    achow101 commented at 11:11 pm on January 26, 2026:

    Let’s not use subtractfeefromamount. It’s also better if we explicitly specify the UTXO to use here rather than hoping that SFFO will pick the right one.

    0        txid = self.nodes[0].sendtoaddress(address3, 0.1)
    1        vout = find_vout_for_address(self.nodes[0], txid, address3)
    2        self.generate(self.nodes[0], 1)
    3        external_addr = self.nodes[0].getnewaddress()
    4        spend_txid = w1.sendall(recipients=[self.nodes[0].getnewaddress()], inputs=[{"txid": txid, "vout": vout}])["txid"]
    

    8144225309 commented at 3:36 pm on January 27, 2026:
    Ah! Thank you, testing the fixed version now.
  5. wallet: allow importprunedfunds for spending transactions
    importprunedfunds only accepted receiving transactions (via IsMine).
    Add IsFromMe to also accept spending transactions.
    
    Test covers a transaction with wallet inputs but no wallet outputs.
    
    Fixes #21647
    13b880a5aa
  6. 8144225309 force-pushed on Jan 27, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-02-11 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me