zcash_client_backend: Add note locking functionality.#2162
Draft
nuttycom wants to merge 8 commits intozcash:mainfrom
Draft
zcash_client_backend: Add note locking functionality.#2162nuttycom wants to merge 8 commits intozcash:mainfrom
nuttycom wants to merge 8 commits intozcash:mainfrom
Conversation
14d3ccd to
38c2064
Compare
9107042 to
0eff72c
Compare
Introduces `OutputRef` as a structured type for referencing transaction outputs across all pools (shielded and transparent). Refactors `ProposalError::ChainDoubleSpend` and the `consumed_chain_inputs` set in `Proposal::multi_step` to use `OutputRef` instead of ad-hoc `(PoolType, TxId, u32)` tuples. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds `is_locked` column (INTEGER NOT NULL DEFAULT 0) to `sapling_received_notes`, `orchard_received_notes`, and `transparent_received_outputs` tables to support explicit note locking during proposal creation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds `lock_outputs`/`unlock_output` to `WalletWrite`, and `get_locked_outputs` to `WalletTest`. Implements these methods in the sqlite backend and adds stub implementations in the memory backend and mock wallet.
All InputSource methods (get_spendable_note, select_spendable_notes, select_unspent_notes, get_account_metadata, get_unspent_transparent_output, get_spendable_transparent_outputs) now accept an include_locked parameter. When false (the default at all current call sites), locked notes will be excluded from results once SQL filtering is implemented. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add locked value to the `zcash_client_backend::data_api::Balance` type, ensure that locked value is correctly determined in balance calculation, and thread `include_locked` parameter from InputSource and WalletRead trait implementations through to SQL queries. Affected SQL functions: - common::get_spendable_note - common::select_spendable_notes / select_spendable_notes_matching_value - common::select_unspent_notes - common::unspent_notes_meta - wallet::get_wallet_summary / with_pool_balances - transparent::get_spendable_transparent_outputs - transparent::get_transparent_balances - transparent::add_transparent_account_balances Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
After marking notes as spent via the *_received_note_spends tables, unlock any locked outputs for the same transaction. The spend records now prevent double-selection, making the explicit locks unnecessary. Also updates WalletWrite::store_transactions_to_be_sent documentation to specify that implementations must unlock spent locked outputs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds a `lock_notes: bool` parameter to `propose_transfer`, `propose_standard_transfer_to_address`, `propose_send_max_transfer`, and `propose_shielding`. When true, all inputs selected by the proposal are locked via `lock_outputs` to prevent double-spending in concurrent proposal creation scenarios. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds two new tests: - `explicit_note_locking`: Tests manual lock_output/unlock_output flow and verifies locked notes are excluded from balance and proposals. - `proposal_level_note_locking`: Tests that propose_transfer with lock_notes=true locks inputs, preventing concurrent proposals, and that create_proposed_transactions unlocks them. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
0eff72c to
2959ef8
Compare
This was referenced Mar 10, 2026
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.
No description provided.