zcash_client_backend: Add WalletRead::get_account_received_outputs - #2973
Draft
pacu wants to merge 2 commits into
Draft
zcash_client_backend: Add WalletRead::get_account_received_outputs#2973pacu wants to merge 2 commits into
pacu wants to merge 2 commits into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2972.
Adds
WalletRead::get_account_received_outputs, gated behind the existingzcashd-compatfeature, 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 andoffset/limitpagination pushed down into the implementation so that exchange-scale wallets can serve zcashd-style received-output listings (z_listreceivedbyaddressin Zallet, zcash/zallet#84) from indexed queries without materializing the full history.zcash_client_backend: the trait method (defaultunimplemented!()body following theutxo_query_heightpattern), plusReceivedOutputsQuery,AccountReceivedOutput,MinedPosition, andMinedStateFilter.zcash_client_sqlite: an implementation as a single query overv_received_outputsjoined totransactions/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 anaddressesrow, and for transparent outputs by the key scope of their address row, since the view hardcodesis_change = 0for pool 0).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
WalletReadimplementation 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 branchrpc-z-listreceivedbyaddress).🤖 Generated with Claude Code
https://claude.ai/code/session_01REAYwXV3jKoUt17miGuA7m