Skip to content

zcash_client_backend: Add WalletRead::get_account_received_outputs - #2973

Draft
pacu wants to merge 2 commits into
mainfrom
pacu/account-received-outputs
Draft

zcash_client_backend: Add WalletRead::get_account_received_outputs#2973
pacu wants to merge 2 commits into
mainfrom
pacu/account-received-outputs

Conversation

@pacu

@pacu pacu commented Aug 15, 2026

Copy link
Copy Markdown
Collaborator

Closes #2972.

Adds WalletRead::get_account_received_outputs, gated behind the existing zcashd-compat feature, per the proposal in #2972: an enumeration of the outputs received by an account — including outputs that have already been spent — with address/mined-height filters and offset/limit pagination pushed down into the implementation so that exchange-scale wallets can serve zcashd-style received-output listings (z_listreceivedbyaddress in Zallet, zcash/zallet#84) from indexed queries without materializing the full history.

  • zcash_client_backend: the trait method (default unimplemented!() body following the utxo_query_height pattern), plus ReceivedOutputsQuery, AccountReceivedOutput, MinedPosition, and MinedStateFilter.
  • zcash_client_sqlite: an implementation as a single query over v_received_outputs joined to transactions/addresses/blocks, with a stable ordering (mined height, tx index, pool, output index; unmined rows last). Change detection combines the view's same-transaction heuristic with internal-scope receipt (identified for shielded outputs by the absence of an addresses row, and for transparent outputs by the key scope of their address row, since the view hardcodes is_change = 0 for pool 0).
  • A TestBuilder-based test covering ordering, the change/address semantics, both filters, pagination, and that spent notes remain listed.

One observation from downstream integration: the default trait body means a delegating WalletRead implementation that forgets to forward this method compiles fine and panics at runtime (Zallet hit exactly this). That is the documented trade-off of the optional-method pattern; flagging it in case reviewers prefer a required method instead.

The branch is based on current main. Zallet consumes it via its [patch.crates-io] pin (zcash/zallet branch rpc-z-listreceivedbyaddress).

🤖 Generated with Claude Code

https://claude.ai/code/session_01REAYwXV3jKoUt17miGuA7m

pacu and others added 2 commits August 15, 2026 09:55
Adds a zcashd-compat-gated API for enumerating the outputs received by
an account, including outputs that have already been spent, with
address/height filters and pagination pushed down to the implementation
so that exchange-scale wallets can serve zcashd-style received-output
listings (such as z_listreceivedbyaddress) from indexed queries.

Part of #2972.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01REAYwXV3jKoUt17miGuA7m
The implementation is a single indexed query over v_received_outputs
joined to the transactions, addresses, and blocks tables, with the
query's address, mined-height, and pagination bounds applied in SQL.
An output is reported as change when the receiving account also spent
value in the transaction or when it was received at internal scope;
internal-scope shielded receipts are identified by the absence of an
addresses row, since internal shielded receivers are never stored as
addresses.

Part of #2972.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01REAYwXV3jKoUt17miGuA7m
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.

zcash_client_backend: Add a WalletRead API for enumerating an account's received outputs (spent + unspent)

1 participant