#34872 wallet: fix mixed-input transaction accounting in history RPCs

full analysis

https://github.com/bitcoin/bitcoin/pull/34872 · w0xlt · +993/-59 in 11 files, 13 commits · labels: Wallet, Needs rebase

Goal

  • Stop wallet history RPCs from showing nonsensical negative fees and fabricated sends
  • Accurately report collaborative transactions that mix wallet and foreign inputs

This pull request updates wallet history accounting in `gettransaction`, `listtransactions`, and `listsinceblock` for transactions with mixed wallet and foreign inputs. When transactions contain foreign inputs of unknown or nonzero value, the wallet omits speculative per-output sends and fees, reporting an aggregate debit entry and exposing mixed-input metadata instead.

Problem: When a wallet transaction spends both wallet-owned and foreign inputs (such as CoinJoins or Payjoins), the wallet currently treats all outputs as sent by the wallet and calculates nonsensical or negative fees, misrepresenting transaction history to users.

Category: Wallet (#36 of 84)

P3 · bug fix

  • P3 because it fixes incorrect fee calculations and phantom sends for collaborative transactions
  • Only affects users participating in CoinJoins or Payjoins, making the fix deferrable

Fixes a long-standing bug (#14136) where wallet history RPCs report incorrect negative fees and fabricate send entries for collaborative transactions. While important for users participating in CoinJoins or Payjoins, it affects a non-standard transaction flow and is reasonably deferrable.

Membership: Modifies wallet transaction caching, input ownership detection, and history accounting RPCs.

Factors: security/stability 0, bug 2, performance 0, user value 2, leverage 0

Reviewability: Stale: Needs rebase

  • Needs rebase due to merge conflicts with master
  • Author has been silent for over two months following review comments

The branch has merge conflicts with master and the author has been silent for 71 days following review comments.

Author status: silent since 2026-07-08; pinged for rebase on 2026-09-09

Open concerns:

  • Clarification of 'attributable' terminology and RPC documentation descriptions.
  • Handling and identification of known zero-value inputs such as ephemeral P2A anchors.
  • Merge conflicts with multiple wallet PRs.

Resolved concerns:

  • Original proposal completely omitted send entries for mixed-input transactions, which was rejected; resolved by reporting an aggregate debit send entry.

Agreement: Positive

  • General support for reporting an aggregate send on mixed-input transactions
  • Objected to omitting send entries entirely, addressed by adding aggregate debits (achow101)
  • Concept approval for the reworked approach (rkrux)
  • Strong support calling it a great improvement while requesting minor clarifications (murchandamus)

achow101 NACKed omitting send entries, addressed by adding aggregate sends; rkrux and murchandamus support the reworked approach.

The author addressed achow101's objection by retaining an aggregate send entry. Reviewers rkrux and murchandamus expressed concept support for the fallback approach, with murchandamus leaving constructive inline review comments.

  • achow101 NACKed omitting send entries entirely on 2026-05-19
  • w0xlt force-pushed a reworked approach on 2026-05-20 reporting aggregate sends
  • rkrux Concept ACKed the reworked approach on 2026-05-21
  • murchandamus reviewed on 2026-07-15 calling it a 'great improvement' while requesting clarifications

Review verdicts (DrahtBot): 0 -1

Files

744 lines under test/bench/ci.

  • test/functional/wallet_gettransaction_mixed_inputs.py +617/-0
  • src/wallet/rpc/transactions.cpp +97/-34
  • src/wallet/receive.cpp +89/-12
  • test/functional/wallet_listtransactions.py +69/-12
  • src/wallet/test/wallet_tests.cpp +45/-0
  • doc/release-notes-34872.md +26/-0
  • src/wallet/wallet.cpp +19/-0
  • src/wallet/receive.h +14/-1
  • src/wallet/transaction.h +12/-0
  • src/wallet/wallet.h +4/-0
  • test/functional/test_runner.py +1/-0

Card

This PR fixes wallet history reporting in gettransaction, listtransactions, and listsinceblock for mixed-input transactions such as CoinJoins and Payjoins (#14136). When non-wallet inputs cannot be proven to contribute zero value, the wallet replaces misleading per-output send entries and negative fee calculations with an aggregate debit summary and mixed-input metadata. The author resolved an early objection against omitting send entries entirely, gaining concept support from rkrux and murchandamus. The PR is currently stale, needing a rebase and author responses to inline comments from July.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T16:18, confidence high, input hash a72bca589ed9f040