Skip to content

zcash_client_backend: Add note locking functionality.#2162

Draft
nuttycom wants to merge 8 commits intozcash:mainfrom
nuttycom:feature/note_locking
Draft

zcash_client_backend: Add note locking functionality.#2162
nuttycom wants to merge 8 commits intozcash:mainfrom
nuttycom:feature/note_locking

Conversation

@nuttycom
Copy link
Copy Markdown
Collaborator

No description provided.

@nuttycom nuttycom changed the title Feature/note locking zcash_client_backend: Add note locking functionality. Feb 24, 2026
@nuttycom nuttycom force-pushed the feature/note_locking branch from 14d3ccd to 38c2064 Compare February 24, 2026 04:22
@nuttycom nuttycom linked an issue Feb 24, 2026 that may be closed by this pull request
@nuttycom nuttycom force-pushed the feature/note_locking branch 10 times, most recently from 9107042 to 0eff72c Compare February 26, 2026 19:43
nuttycom and others added 8 commits March 4, 2026 12:18
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>
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: Support note locking

1 participant