Commit Graph

242 Commits

Author SHA1 Message Date
Kris Nuttycombe beeea7b44e zcash_client_backend: Modify `Proposal` to make multi-step transactions representable. 2024-02-14 19:30:52 -07:00
Kris Nuttycombe 1db3109cb4 zcash_client_backend: Move the `Proposal` types to a `proposal` module.
This separation is in preparation for modifying the `Proposal` type
to wrap a vector of proposal steps.
2024-02-14 19:04:47 -07:00
Kris Nuttycombe 6e0d9a9420 zcash_client_backend: Add selected output pools to transaction proposals.
Fixes #1174
2024-02-14 18:58:48 -07:00
Kris Nuttycombe 7a5852598e zcash_keys, zcash_client_backend: feature-flag off transparent-input WalletRead methods.
This also moves the `TransparentAddressMetadata` type behind the
`transparent-inputs` feature flag and performs associated cleanup.
2024-02-14 17:38:52 -07:00
Andrew Arnott f1b6dd0636
Switch out `AddressMetadata` for new struct 2024-02-13 18:34:33 -07:00
Andrew Arnott 8f6afb2182
Update changelogs 2024-02-13 18:02:24 -07:00
Andrew Arnott 918f5cc812
Change `WalletRead::get_transparent_receivers` signature
It needn't return the account id that was given as an input, and it shouldn't return an 11-byte diversifier index when a 31-bit child index is more appropriate.
2024-02-13 11:39:06 -07:00
Kris Nuttycombe 11f5589595 zcash_client_backend: Allow serialization of empty transaction requests. 2024-01-30 16:42:31 -08:00
str4d 610b19bcd2
Merge pull request #1129 from zcash/wallet/orchard_compiler_flag
Add `zcash_unstable` compiler flag to fully gate `orchard` functionality
2024-01-25 19:15:53 +00:00
Kris Nuttycombe 0ae986cad0 zcash_client_backend: Move features guarded by the `orchard` flag to a separate Unreleased section of the CHANGELOG 2024-01-24 20:19:14 -07:00
Kris Nuttycombe ea4d00a12d Add CHANGELOG entries. 2024-01-24 18:00:55 -07:00
Jack Grigg db071f2e1f zcash_client_backend: Add desired Sapling shard index to `WalletSummary`
Closes zcash/librustzcash#1124.
2024-01-24 18:06:31 +00:00
Kris Nuttycombe 0ca955336d Split `zcash_keys` crate out from `zcash_client_backend`
This change makes it easier for third parties to make use of the Unified
key infrastructure without incurring a dependency upon the rest of the
`zcash_client_backend` interfaces.
2024-01-16 13:49:42 -07:00
Andrew Arnott 28ed048c7e
Add punctuation to changelog
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2024-01-11 12:02:24 -07:00
Andrew Arnott 69d92808f3
Add `WalletRead::get_account_ids` function 2024-01-10 13:01:01 -07:00
Kris Nuttycombe 6cbdd494cf zcash_client_backend: Add receiver type selection to unified address derivation. 2024-01-09 10:48:13 -07:00
Kris Nuttycombe 24ebe4c643 Address comments from code review.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2024-01-05 17:00:46 -07:00
Kris Nuttycombe adc75566a0 zcash_client_backend: Add Orchard support to transaction proposals. 2024-01-05 16:59:54 -07:00
Kris Nuttycombe 56f2ac573c zcash_client_backend: Add Orchard support to change strategies.
This modifies the `compute_balance` method to operate in a
bundle-oriented fashion, which simplifies the API and makes it easier to
elide Orchard functionality in the case that the `orchard` feature is
not enabled.
2024-01-05 16:59:54 -07:00
Kris Nuttycombe 1b036f1e0d zcash_client_backend: rename `WalletNote` to `Note` 2024-01-05 09:13:53 -07:00
Kris Nuttycombe d4aa2d6f06 Replace SaplingInputSource and TransparentInputSource with InputSource
This unification allows us to better isolate transparent-input dependent
functionality. Previously, `TransparentInputSource` could not be placed
under a feature flag because the interface was needed for proposal
deserialization; by instead making the transparent input source methods
flag-dependent, we can correctly produce an error when proposal
deserializaiton attempts to select transparent inputs and the feature
flag is off.
2024-01-04 14:00:20 -07:00
Kris Nuttycombe 967fd36d39
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2024-01-04 11:56:59 -07:00
Kris Nuttycombe 857e44a11c zcash_client_backend: Use a polymorphic type for `ScannedBlock` note commitment and nullifier data. 2024-01-04 11:19:22 -07:00
Kris Nuttycombe f18d082aa3 zcash_client_backend: Introduce an "orchard-client" feature flag.
We plan to also introduce a similar flag to gate access to Sapling
functionality. Since introduction of Orchard functionality is still
nascent, it's the correct time to introduce this isolation, before
there's more functionality that needs to be isolated in this fashion.
2024-01-03 17:05:20 -07:00
Kris Nuttycombe 9ac3594bbb zcash_client_backend: Rename RecipientAddress to Address 2023-12-08 11:34:27 -07:00
Kris Nuttycombe aab9938b53 zcash_client_backend: Rename `RecipientAddress::Shielded` to `RecipientAddress::Sapling` 2023-12-07 15:24:47 -07:00
Kris Nuttycombe 4eaa41affa zcash_primitives: Remove and relocate `InputView` traits. 2023-12-06 20:17:43 -07:00
Kris Nuttycombe ca54b3489d Apply suggestions from code review
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-12-05 15:55:52 -07:00
Kris Nuttycombe cad4f25b75 zcash_client_backend: Replace `ReceivedSaplingNote` with `ReceivedNote`
`ReceivedNote` now allows Orchard notes to be represented as received
notes. As part of this change, received notes now track whether they
were received using internally- or externally-scoped viewing keys.
This eliminates the need to trial-regenerate notes using the wallet's
IVKs to determine scope at spend time.
2023-12-05 10:55:06 -07:00
Kris Nuttycombe 6b10a6dc86 zcash_client_backend: Move essential wallet types into the `wallet` module. 2023-12-05 10:55:04 -07:00
Kris Nuttycombe 214a3750c5 zcash_client_backend: Make `Balance` and `AccountBalance` fields private.
Public methods for mutation of these fields have been provided that
perform checking for overflow of the valid monetary range as part
of their operation.
2023-12-04 13:53:27 -07:00
Kris Nuttycombe 9aec53eec9 zcash_client_backend: Add Orchard components to `ScannedBlock` 2023-11-30 13:08:17 -07:00
Kris Nuttycombe c5f48f50e1 Apply suggestions from code review
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
Co-authored-by: str4d <thestr4d@gmail.com>
2023-11-15 10:53:23 -07:00
Kris Nuttycombe aeb405ef5d Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-11-14 12:58:22 -07:00
Kris Nuttycombe 33169719ce zcash_client_backend: Add serialization & parsing for protobuf Proposal representation. 2023-11-09 20:07:16 -07:00
Kris Nuttycombe b9ac7c5eda zcash_client_backend: Fix off-by-one in tree heights at NU activation. 2023-11-09 09:44:57 -07:00
Kris Nuttycombe 27f78d1894 zcash_client_backend: Add Orchard note commitment tree size to block metadata. 2023-11-08 16:46:44 -07:00
Kris Nuttycombe aa063ae3fd zcash_client_backend: Factor out input source traits from `WalletRead`
Prior to this change, it's necessary to implement the entirety of the
`WalletRead` trait in order to be able to use the input selection
functionality provided by `zcash_client_backend::data_api::input_selection`.
This change factors out the minimal operations required for transaction
proposal construction to better reflect the principle of least authority
and make the input selection code reusable in more contexts.

In order to minimize the operations of the newly-created `InputSource`
and `ShieldingSource` traits, this change also removes the
`min_confirmations` field from transaction proposals, in favor of
storing explicit target and anchor heights. This has the effect of
limiting the lifetime of transaction proposals to `PRUNING_DEPTH -
min_confirmations` blocks.
2023-11-08 12:41:49 -07:00
Jack Grigg a77b6c631c Add missing unreleased changelog entries 2023-11-03 00:56:56 +00:00
Jack Grigg bed5bc6cf6 Clean up unreleased changelog entries 2023-11-03 00:56:26 +00:00
Kris Nuttycombe 13fb0a4819
Merge pull request #1019 from nuttycom/wallet/proposals_with_minconf
zcash_client_backend: Move `min_confirmations` into `Proposal`
2023-10-31 12:59:40 -06:00
Kris Nuttycombe 4cd26b7ea9 zcash_client_backend: Move `min_confirmations` into `Proposal`
This fixes an API issue whereby it was possible to execute a `Proposal`
with a different value of `min_confirmations` than that with which the
`Proposal` was constructed.
2023-10-31 10:38:52 -06:00
Kris Nuttycombe a0935b5ecd zcash_client_backend: remove `WalletRead::is_valid_account_extfvk` 2023-10-27 15:01:26 -06:00
Kris Nuttycombe 9627c806e4 zcash_client_backend: Pass `Proposal` values by reference. 2023-10-26 16:11:10 -06:00
Kris Nuttycombe cc0cc2de84 zcash_primitives: add StandardFeeRule
`StandardFeeRule` is an enumeration of the standard fees that have
existed in the history of Zcash zips. It is provided to simplify
transition to new fee strategies; legacy elements of this enumeration
are introduced already-deprecated.
2023-10-25 08:08:49 -06:00
Kris Nuttycombe f7527e14c9 Use `NonNegativeAmount` for note and utxo value fields 2023-10-23 12:59:26 -06:00
Kris Nuttycombe 29c676ff12
Merge pull request #1009 from tw0po1nt/fix_txn_builder_panic
Gracefully handle when given an Orchard-only UA
2023-10-12 18:15:36 -06:00
Matthew Watt a788cc4c4d Fix merge conflicts 2023-10-12 06:16:22 -05:00
Kris Nuttycombe 1447d8ea01 zcash_client_backend: Move change memos into the `ChangeValue` components of `Proposal`s.
The existing API limited change outputs to having only a single memo
repeated across each change output. This change makes it so that each
proposed change output can have its own associated memo, and leaves it
up to the input selector to determine how requested change memos are
associated with change outputs.
2023-10-11 14:15:19 -06:00
Kris Nuttycombe a2b5c2c784 zcash_client_backend: Use `NonNegativeAmount` for fee and change amounts.
In order to use `uint64` for amounts that must be nonnegative in the
`proposal.proto` file, it is useful to update fee and change computation
to use `NonNegativeAmount` where possible.
2023-10-10 16:12:47 -06:00
Kris Nuttycombe 5b40ddf072 zcash_client_backend: Use globally unique identifiers for notes.
Update zcash_client_backend error types to use (TxId, output_index)
as the identifier for notes instead of the internal database identifier.
2023-10-09 12:44:27 -06:00
sasha 74840829c8 zcash_client_backend: Make `ReceivedSaplingNote` internals private.
This also adds the txid and index to `ReceivedSaplingNote` for use as a
globally identifier for the note.
2023-10-09 12:22:12 -06:00
Matthew Watt 4bbe658f74
Update CHANGELOG.md
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-10-09 10:06:37 -05:00
Matthew Watt 94f2240e08 Provide PoolType to UnsupportedPoolType case; stylistic changes 2023-10-08 19:05:50 -05:00
Kris Nuttycombe a2e772c93a zcash_client_backend: Return summary information from `scan_cached_blocks`
When scanning, a wallet only needs to update balance and transaction
information shown to users when the scan has resulted in a change to
wallet state. This modifies `scan_cached_blocks` to return the range of
block heights actually scanned, along with the counts of notes spent and
received by the wallet in that range.

Fixes #918
2023-09-28 17:39:59 -06:00
Jack Grigg 4bc65d66b1 zcash_client_backend 0.10.0 2023-09-25 18:19:52 +00:00
Jack Grigg 4afc24af6a zcash_client_backend 0.10.0-rc.4 2023-09-22 23:25:19 +01:00
Kris Nuttycombe 6d2c53111a zcash_client_backend 0.10.0-rc.3 2023-09-19 15:00:51 -06:00
Jack Grigg 9db68c76ee zcash_client_backend 0.10.0-rc.1 2023-09-08 19:50:53 +00:00
Jack Grigg 94c1f2413d Migrate to `incrementalmerkletree 0.5`, `orchard 0.6` 2023-09-08 18:57:25 +00:00
Jack Grigg 6e34e2d113 zcash_client_backend: Migrate to `prost 0.12`, `tonic 0.10` 2023-09-08 16:21:48 +00:00
Kris Nuttycombe 1fe763de5f zcash_client_backend: Update CHANGELOG.md for 0.10.0 release. 2023-09-08 10:15:49 -06:00
Kris Nuttycombe 65420f59df zcash_client_backend: Add `WalletRead::block_max_scanned`
Fixes #941
2023-09-06 08:49:43 -06:00
str4d 236e9f2cd0
Merge pull request #914 from nuttycom/sbs/nonlinear_sync_aware_balance
Add `get_wallet_summary` to `WalletRead`
2023-09-06 01:04:42 +01:00
Kris Nuttycombe f53ea2d778 Add `get_wallet_summary` to `WalletRead`
The intent of this API is to provide a single API which returns in a
single call:

* per-account balances, including pending values
* wallet sync progress

Fixes #865
Fixes #900
2023-09-05 16:06:55 -06:00
Kris Nuttycombe dd60f51d3c Address unresovled code review comments from #907 2023-09-05 09:30:17 -06:00
Kris Nuttycombe 0b0274cdc1 zcash_client_backend: Make wallet and account birthday heights available via the data access API 2023-09-01 10:11:43 -06:00
Kris Nuttycombe 459dc49b54 zcash_client_backend: Accept account birthday as a parameter to `create_account`
This also removes the zcash_client_sqlite-specific database
initialization procedures in favor of a standardized approach using the
methods available via the data access API.
2023-09-01 10:08:17 -06:00
Jack Grigg 3ad07cad9e zcash_client_backend: Reduce scope of `lightwalletd-tonic` feature flag
The `zcash_client_backend::proto::service::compact_tx_streamer_client`
is now the only module controlled by that feature flag, exposing the
service types for use by parsers.
2023-08-31 20:32:04 +00:00
Kris Nuttycombe ff8104fa75 zcash_client_sqlite: (testing) Initialize wallets using an `AccountBirthday` struct. 2023-08-28 19:25:52 -06:00
Kris Nuttycombe 3be55ae964 zcash_client_backend: Add test-only convenience methods for default addresses. 2023-08-28 14:05:17 -06:00
Kris Nuttycombe dee43854cb zcash_client_sqlite: Ensure that target and anchor heights are relative to the chain tip.
Prior to the scan-before-sync changes, the wallet was able to assume
that the maximum scanned block height at the time of the spend was
within a few blocks of the chain tip. However, under linear scanning
after the spend-before-sync changes this invariant no longer holds,
resulting in a situation where in linear sync conditions the wallet
could attempt to create transactions with already-past expiry heights.

This change separates the notion of "chain tip" from "max scanned
height", relying upon the `scan_queue` table to maintain the wallet's
view of the consensus chain height and using information from the
`blocks` table only in situations where the latest and/or earliest
scanned height is required.

As part of this change, the `WalletRead` interface is also modified to
disambiguate these concepts.
2023-08-16 11:53:24 -06:00
Jack Grigg 44abd3450b Require `BlockSource::with_blocks` fail on non-existent `from_height`
Previously this was not clearly specified, and the implementations in
`zcash_client_sqlite` behaved similarly to when `from_height = None`.

Closes zcash/librustzcash#892.
2023-08-09 17:57:00 +00:00
Kris Nuttycombe f602ec125d Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-08-07 11:28:28 -06:00
Kris Nuttycombe d3b7dffa3c zcash_client_backend: Restrict use of backend-specific note identifiers.
In general, it is preferable to use globally relevant identifiers where
possible. This PR removes the `WalletRead::TxRef` associated type in
favor of using `TxId` directly for the transaction identifier, and
restricts the use of the `NoteRef` type to those scenarios where the
result of one query is intended to be used directly as the input to
another query.

Closes #834
2023-08-07 11:27:38 -06:00
Jack Grigg 2d3d5e8fe6 zcash_client_backend: Precompute IVKs in `scan_cached_blocks` 2023-07-25 02:21:15 +00:00
Jack Grigg b33330f9ca zcash_client_backend: Accept owned keys in `scan_block_with_runner`
This internal helper function can now take owned or borrowed keys. The
public `scan_block` function is left unaltered.
2023-07-25 02:14:18 +00:00
Jack Grigg a87dca00e2 Documentation updates, fixes, and cleanups
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-07-19 14:54:01 +00:00
Kris Nuttycombe 6fa0b46d8e Implement `suggest_scan_ranges` and `update_chain_tip`
This implements a priority queue backed by the wallet database for scan
range ordering. The scan queue is updated on each call to `put_blocks`
or to `update_chain_tip`.
2023-07-07 20:13:45 -06:00
Kris Nuttycombe 1b5a24a655 Batch data store writes of `put_block`
Instead of calling `put_block` for each block scanned,
`scan_cached_blocks` will now defer the block writes until the scan of a
batch is complete and will perform the block writes and note commitment
tree updates all within a single transaction.

This should ordinarily be fine in terms of memory consumption, because
the block data being saved is pruned to only that spend an output
information that is related to transactions in the wallet, which will
normally be sparse enough that the block range size that is appropriate
for a given platform to run within a batch scanner adequately bounds the
memory consumption of this pruned representation.
2023-07-06 12:13:39 -06:00
Kris Nuttycombe 98147e0d7d Make `from_height` and `limit` parameters to `scan_cached_blocks` non-optional. 2023-07-05 18:56:19 -06:00
Kris Nuttycombe faccf56f04 Split `PoolType` enum into `PoolType` and `ShieldedProtocol`
There are cases where we wish to return informaiton that is relevant to
a specific shielded protocol and `Transparent` is an invalid case. This
is a minor preparatory refactoring that makes this distinction
expressible.
2023-07-05 18:20:43 -06:00
Kris Nuttycombe 1e5b23aeba zcash_client_backend: Add `put_sapling_subtree_roots` to `WalletCommitmentTrees`
Also add the `zcash_client_sqlite` implementation & tests for the new
method.
2023-07-05 18:18:20 -06:00
Kris Nuttycombe c13c8c6678 Address comments from code review. 2023-07-03 17:08:01 -06:00
Kris Nuttycombe 42ed6ba2a1 Rename `zcash_client_backend::welding_rig` to `zcash_client_backend::scanning` 2023-07-03 10:49:03 -06:00
Kris Nuttycombe e3aafdad19 Move chain continuity checks into `scan_block_with_runner`
In preparation for out-of-order range-based scanning, it is necessary
to ensure that the size of the Sapling note commitment tree is carried
along through the scan process and that stored blocks are always
persisted with the updated note commitment tree size.
2023-07-03 10:49:03 -06:00
Kris Nuttycombe 77b638012b Remove `zcash_client_backend::data_api::chain::validate_chain`
Local chain validation will be performed internal to
`scan_cached_blocks`, and as handling of chain reorgs will need to
change to support out-of-order scanning, the `validate_chain` method
will be superfluous. It is removed in advance of other changes in order
to avoid updating it to reflect the forthcoming changes.
2023-07-01 17:58:01 -06:00
Kris Nuttycombe e225a54d2e Use `NonZeroU32` for all `min_confirmations` values. 2023-06-30 12:37:41 -06:00
Kris Nuttycombe d65b129b43 Apply changelog, documentation & style suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-06-30 09:30:24 -06:00
Kris Nuttycombe c42cffeb1d zcash_client_backend: Replace `WalletWrite::advance_by_block` with `WalletWrite::put_block`
Also, add assertions to prevent attempting the creation of zero-conf
shielded spends.
2023-06-29 15:35:18 -06:00
Kris Nuttycombe f9cacc5b21 Release zcash_primitives 0.12.0 2023-06-06 15:56:28 -06:00
Kris Nuttycombe 75e529eea6 Upgrade to `bs58 0.5` 2023-06-06 15:53:14 -06:00
Kris Nuttycombe 3dd0c63095 Update to `incrementalmerkletree 0.4`, `orchard 0.5` 2023-06-06 14:27:39 -06:00
Kris Nuttycombe b341903ae2
Merge pull request #842 from zcash/msrv-1.65
Bump MSRV for `zcash_primitives` and dependents to 1.65
2023-05-19 09:28:43 -06:00
Kris Nuttycombe ea84243e0f Add `get_memo` change to the zcash_client_backend CHANGELOG 2023-05-17 08:56:24 -06:00
Jack Grigg a092da8d5d Fix clippy lints for 1.65 2023-05-16 15:59:58 +00:00
Jack Grigg 8681b56d52 Bump MSRV for `zcash_primitives` and dependents to 1.65 2023-05-16 15:37:07 +00:00
str4d 579ab92b93
Merge branch 'main' into 823-secp256k1-0.26 2023-05-08 18:53:33 +01:00
Jack Grigg 8b53d4a0c4 zcash_client_backend 0.9.0 2023-04-28 01:46:28 +00:00
Kris Nuttycombe f3745c0cb5 Make the internal state of `SentTransactionOutput` private. 2023-04-27 13:07:34 -06:00