wallet: fix removeprunedfunds bug with conflicting transactions #34358

pull mzumsande wants to merge 1 commits into bitcoin:master from mzumsande:202601_importprunedfund_bug changing 2 files +37 −2
  1. mzumsande commented at 2:40 am on January 21, 2026: contributor

    removeprunedfunds removes all entries from mapTxSpends for the inputs of the pruned tx. However, this is incorrect, because there could be multiple entries from conflicting transactions (that shouldn’t be removed as well). This could lead to the wallet creating invalid transactions, trying to double spend utxos. The bug persists when the conflicting tx was mined, because the wallet trusts its internal accounting instead of calling AddToSpends again.

    The added test should fail on master.

  2. DrahtBot added the label Wallet on Jan 21, 2026
  3. DrahtBot commented at 2:40 am 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/34358.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Concept ACK fjahr

    If your review is incorrectly listed, please copy-paste <!–meta-tag:bot-skip–> into the comment that the bot should ignore.

  4. wallet: fix removeprunedfunds bug with conflicting transactions
    removeprunedfunds removes all entries from mapTxSpends for the
    inputs of the pruned tx. However, this is incorrect, because there could be
    multiple entries from conflicting transactions (that shouldn't be
    removed as well). This could lead to the wallet creating invalid
    transactions, trying to double spend utxos.
    The bug persists when the conflicting tx was mined, because
    the wallet trusts its internal accounting instead of calling
    AddToSpends again.
    372843c016
  5. mzumsande force-pushed on Jan 21, 2026
  6. DrahtBot added the label CI failed on Jan 21, 2026
  7. DrahtBot removed the label CI failed on Jan 21, 2026
  8. fjahr commented at 11:51 pm on January 21, 2026: contributor

    Concept ACK

    Confirmed that the new test fails on master and reviewed the test code. Need to spend some extra time with the wallet code.


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-01-22 09:13 UTC

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