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

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK achow101

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  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.

            txid = self.nodes[0].sendtoaddress(address3, 0.1)
            vout = find_vout_for_address(self.nodes[0], txid, address3)
            self.generate(self.nodes[0], 1)
            external_addr = self.nodes[0].getnewaddress()
            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. edit: changes applied

  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
  7. achow101 commented at 10:38 PM on March 31, 2026: member

    ACK 13b880a5aa37648e8ed3f5ab0459d3c9784b006e


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-04-13 15:12 UTC

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