Skip to content

wallet, rpc: add include_change parameter to listtransactions#35009

Open
alfonsoromanz wants to merge 2 commits intobitcoin:masterfrom
alfonsoromanz:wallet-listtransactions-include-change
Open

wallet, rpc: add include_change parameter to listtransactions#35009
alfonsoromanz wants to merge 2 commits intobitcoin: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
Copy link
Copy Markdown
Contributor

DrahtBot commented Apr 5, 2026

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

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK 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
Comment thread test/functional/wallet_listtransactions.py
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
Copy link
Copy Markdown
Member

achow101 commented Apr 7, 2026

ACK 0ef6fff

@luke-jr
Copy link
Copy Markdown
Member

luke-jr commented Apr 8, 2026

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
Copy link
Copy Markdown
Member

achow101 commented Apr 8, 2026

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.

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

4 participants