Skip to content

wallet, rpc: add include_change parameter to listtransactions - #35009

Closed
alfonsoromanz wants to merge 2 commits into
bitcoin:masterfrom
alfonsoromanz:wallet-listtransactions-include-change
Closed

alfonsoromanz wants to merge 2 commits into
bitcoin:masterfrom
alfonsoromanz:wallet-listtransactions-include-change

Conversation

@alfonsoromanz

Copy link
Copy Markdown
Contributor

Currently, listtransactions silently hides transactions whose outputs go exclusively to change addresses. This can be confusing, as reported in #34632: a user created a consolidation transaction sending funds to a change address, and the transaction disappeared from listtransactions, making it appear as though funds were lost.

listsinceblock already supports an include_change parameter for this purpose. The internal ListTransactions helper also already accepts it. This PR simply wires the parameter through the listtransactions RPC handler for consistency.

  • Adds include_change (bool, default false) as a new argument after the existing include_watchonly
  • No behavior change for existing callers
  • Includes functional test coverage

This approach was suggested by @mossein in #34632. A more comprehensive listrawtransactions RPC as mentioned by @achow101 could be pursued separately.

Fixes #34632

@DrahtBot

DrahtBot commented Apr 5, 2026 •

Copy link
Copy Markdown
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/35009.

Reviews

See the guideline for information on the review process.

Type Reviewers
User requested bot ignore achow101

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34872 (wallet: fix mixed-input transaction accounting in history RPCs by w0xlt)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

LLM Linter (✨ experimental)

Possible places where named args for integral literals may be used (e.g. func(x, /*named_arg=*/0) in C++, and func(x, named_arg=0) in Python):

  • ListTransactions(*pwallet, *pwtx, 0, true, ret, filter_label, include_change) in src/wallet/rpc/transactions.cpp
  • ListTransactions(*pwallet, wtx, 0, false, details, /filter_label=/std::nullopt, /include_change=/false) in src/wallet/rpc/transactions.cpp
  • self.nodes[0].listtransactions("*", 100, 0, False, True) in test/functional/wallet_listtransactions.py

2026-04-07 11:05:05

Comment thread src/wallet/rpc/transactions.cpp Resolved
listsinceblock already supports an include_change parameter, and the internal ListTransactions helper already accepts it. Wire this parameter through the listtransactions RPC handler for consistency.

Since all callers of ListTransactions now pass include_change explicitly, remove the default value to ensure future callers do too.

This addresses the issue reported in bitcoin#34632, where transactions sending exclusively to change addresses are silently hidden from listtransactions.
Verify that listtransactions with include_change=true returns receive and send entries for change outputs. Mirrors the existing test_send_to_self test in wallet_listsinceblock.py.
@alfonsoromanz
alfonsoromanz force-pushed the wallet-listtransactions-include-change branch from 53d55d8 to 0ef6fff Compare April 7, 2026 11:04
@alfonsoromanz

Copy link
Copy Markdown
Contributor Author

Force-pushed to address @achow101's feedback.

@achow101

achow101 commented Apr 7, 2026 •

Copy link
Copy Markdown
Member

ACK 0ef6fff

@luke-jr

luke-jr commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

listtransactions is meant to show logical transactions, not L1 transactions. Change is by definition not a logical transaction. If you send bitcoins to a change address, I would expect it to not appear at all, rather than appearing as losing money.

@achow101

achow101 commented Apr 8, 2026

Copy link
Copy Markdown
Member

If you send bitcoins to a change address, I would expect it to not appear at all, rather than appearing as losing money.

I agree that change should not appear at all, but if it were to be shown, they should be (and are) shown as send to self, which we show as separate send and receive transactions.

@achow101

achow101 commented May 19, 2026 •

Copy link
Copy Markdown
Member

Did some further thinking on transaction listing, and I no longer thing this is the right approach. Change is not a logical transaction and should not be shown in listtransactions which lists logical transactions. I prefer that we have a separate RPC that lists Bitcoin transactions and does not try to interpret for logical transactions.

@sedited

sedited commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

If I interpret @achow101's latest comment correctly, this pull request and its related two issues should probably be closed, no?

@achow101 achow101 closed this Jun 7, 2026
achow101 added a commit that referenced this pull request Sep 22, 2026
7c311f5 doc: Add release notes for listrawtransactions (pablomartin4btc)
b377786 test: Add functional test for listrawtransactions (pablomartin4btc)
605c4fd wallet, rpc: Add listrawtransactions RPC (pablomartin4btc)
ba6c179 wallet, rpc: allow omitting parent_descs from TransactionDescriptionString (pablomartin4btc)
dc3e2bc wallet, rpc: extract PushTxAmountAndFee/PushTxDecoded helpers (pablomartin4btc)

Pull request description:

  Add a new `listrawtransactions` RPC that returns wallet transactions without logical interpretation. Unlike `listtransactions`, which only lists transactions with an economic category (sends to external addresses, receives from outside), this RPC returns every transaction the wallet knows about — including consolidations and self-transfers that would otherwise be invisible.

  Each transaction appears exactly once with its net wallet balance change (`amount`) and, when the wallet funded the transaction, the fee paid (`fee`). Pagination is supported via `count` and `skip` parameters, matching the interface of `listtransactions`.

  Next possible follow-ups:
  - A filter parameter (`"all"` / `"received"` / `"sent"` / `"self"`) once per-tx semantics are agreed on
  - Some fields inherited from `TransactionDescriptionString()` carry references to `category` (e.g. `replaced_by_txid`, `parent_descs`) which don't apply here — could be cleaned up in a separate pass

  Closes #34632.

  Previous attempt: #35009 (by alfonsoromanz), closed in favour of a separate RPC as suggested by achow101.

ACKs for top commit:
  Bicaru20:
    reACK 7c311f5
  achow101:
    ACK 7c311f5
  polespinasa:
    ACK 7c311f5

Tree-SHA512: c80f98844124d10b16a7f275107e22d4f5983329d93208e95b3e56ac7295c7265eebdb247a4fa7d70da8d38f4b453df17efaee29a4bd6bae8cb1da60b029c489
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

Successfully merging this pull request may close these issues.

listtransactions does not list tx that spends only change outputs to a change address

5 participants