Commit Graph

775 Commits

Author SHA1 Message Date
Kris Nuttycombe 2d8ece3003 Fix broken intra-doc link 2023-09-20 13:24:53 -06:00
Kris Nuttycombe bdc6886e2d
Apply suggestions from code review.
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-20 13:21:53 -06:00
Kris Nuttycombe d5dc4c6d9c zcash_client_backend: Document `data_api::ScannedBlock`
Fixes #885
2023-09-20 12:53:54 -06:00
Kris Nuttycombe 996fea70ac zcash_client_backend: Add detail to documentation of `suggest_scan_ranges`
Fixes #971
2023-09-20 12:39:43 -06:00
Kris Nuttycombe 6d2c53111a zcash_client_backend 0.10.0-rc.3 2023-09-19 15:00:51 -06:00
Kris Nuttycombe 1575f2db88 zcash_client_backend: make the `SpanningTree` type usable outside of `zcash_client_sqlite`
This adds the `data_api::scanning::spanning_tree` module under
a new `unstable-spanning-tree` feature flag, making it available to
other implementations who want to be able to write their own storage
backends without having to reinvent the spanning tree logic.
2023-09-18 11:22:35 -06:00
Kris Nuttycombe 24068cd63a zcash_client_backend 0.10.0-rc.2 2023-09-12 08:31:39 -06:00
Kris Nuttycombe 1e39daf6f8
Merge pull request #963 from nuttycom/bug/commitment_tree_depth
zcash_client_backend: Fix an error that can occur due to sparse `shardtree` checkpoints.
2023-09-12 08:05:50 -06:00
Kris Nuttycombe f2dcba3a34 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-09-11 18:39:27 -06:00
Kris Nuttycombe 24e8c82546 zcash_client_backend: Get commitment tree depth for a given number of confirmations from the database.
This fixes the following bug:

Due to complexities related to non-linear scanning, checkpoints are only
added to the wallet's commitment tree in cases where there are notes
discovered within a scanned block. At present, the `shardtree` API only
makes it possible to add multiple checkpoints of the same tree state
when adding checkpoints at the chain tip, and this functionality is not
used by `zcash_client_backend` because we perform checkpoint insertion
in batches that may contain gaps in the case that multiple blocks
contain no Sapling notes. While it would be possible to fix this by
altering the `shardtree` API to permit explicit insertion of multiple
checkpoints of the same tree state at a given note position, this fix
takes a simpler approach.

Instead of ensuring that a checkpoint exists at every block and
computing the required checkpoint depth directly from the minimum number
of confirmations required when attempting a spend, we alter the
`WalletCommitmentTrees` API to allow internal information of the note
commitment tree to be used to determine this checkpoint depth, given the
minimum number of commitments as an argument. This allows us to select a
usable checkpoint from the sparse checkpoint set that resulted from the
sparse insertion of checkpoints described above.
2023-09-11 18:38:54 -06:00
Kris Nuttycombe 771e4013c3 Move shardtree serialization to the `zcash_client_backend` crate 2023-09-11 18:18:08 -06:00
Jack Grigg 9db68c76ee zcash_client_backend 0.10.0-rc.1 2023-09-08 19:50:53 +00:00
Jack Grigg 87ca71b8db zcash_proofs 0.13.0-rc.1 2023-09-08 19:48:55 +00:00
Jack Grigg 67b84c25e0 zcash_primitives 0.13.0-rc.1 2023-09-08 19:45:54 +00:00
Kris Nuttycombe 46cc6666df Address comments from code review.
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-08 13:03:53 -06: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 2131cd547e zcash_client_sqlite: Return a balance for every account from `get_wallet_summary`
Fixes #948
2023-09-07 11:02:59 -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 7abd1324de Apply suggestions from code review
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-09-05 16:49:36 -06: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 5b3f544102 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
Co-authored-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-09-01 10:38:20 -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 3272f129e2 zcash_client_backend: Remove now-superfluous braces from build script 2023-08-31 20:32:42 +00: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 22b6ddd754 Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-08-29 17:02:46 -06: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
Andrew Arnott 9859066c72
Fix API doc comment on UnifiedSpendingKey
This fixes a simple copy/paste error of the docs from the unified viewing key.
2023-08-24 07:47:30 -06:00
Kris Nuttycombe b3be0318c6 zcash_client_sqlite: Initialize the scan queue as part of `init_blocks_table`
Fixes #902
Fixes #898
2023-08-21 09:03:31 -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 d3fc9670d5 zcash_client_backend: Fix `scan_cached_blocks` panic with genesis block
If `from_height = 0` and `limit > 1`, then the conditional being used to
initialise `continuity_check_metadata` was previously running for every
block, and would therefore panic while processing the block at height 1.
2023-08-09 17:57:00 +00: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
Kris Nuttycombe 90412ebdc2 Fix SentTransactionOutput documentation. 2023-08-04 14:11:24 -06:00
Kris Nuttycombe a5a8562ddd zcash_client_backend, zcash_client_sqlite: Ensure consistency between sent & stored memos. 2023-08-04 14:05:00 -06:00
Kris Nuttycombe 40ecaaf758 zcash_client_backend: Fix error where change memos were not being included in sent transactions. 2023-08-02 11:35:27 -06:00
Kris Nuttycombe e640f82ff6 Pin `time` dependency to avoid forced MSRV bump.
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2023-08-02 10:22:54 -06:00
Jack Grigg facd4ccac5 Migrate to latest `shardtree` revision 2023-07-25 20:57:49 +00: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 0f2689b9c3 zcash_client_sqlite: Maintain a nullifier map from out-of-order scanning
Closes zcash/librustzcash#876.
2023-07-21 18:01:52 +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
Jack Grigg 2a98f94f05 Add more debug and trace logging
The `Debug` impl for `sapling::Node` is updated to output hex-encoded
bytes for readability.
2023-07-18 17:23:57 +00:00
Jack Grigg f7163e9dd9 Code simplifications
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-07-18 17:23:55 +00:00
Jack Grigg ed4b6dc9b9 Fix bugs in `ScanRange::truncate_*` 2023-07-18 17:22:48 +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
Jack Grigg a11545459b Bump patched dependencies to bring in shardtree bugfixes 2023-07-06 22:19:21 +00:00
Kris Nuttycombe d55fa09464 Add a check to ensure that blocks passed to `put_blocks` are sequential. 2023-07-06 12:13:39 -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 81a32f284e Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2023-07-06 11:24:16 -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 c363e71fa9 Rename proto::compact::{BlockMetadata => ChainMetadata} 2023-07-03 16:19:13 -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 45177a51e1 Fix off-by-one error in scan_block_with_runner. 2023-06-30 09:30:24 -06:00
Kris Nuttycombe c05b3d0c8c Add a test demonstrating off-by-one error in `scan_block_with_runner` 2023-06-30 09:30:24 -06:00
Kris Nuttycombe 8fa3a08c0b Fix indexing error in checkpoint determination. 2023-06-30 09:30:24 -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 ba709177d3 Reorganize Sapling and Orchard note commitment tree sizes in CompactBlock.
We move thes fields out into a separate BlockMetadata struct to ensure
that future additions to block metadata are structurally separated from
future additions to block data.
2023-06-29 15:35:18 -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 3e358bc1c9 zcash_client_backend: Use `shardtree` for note commitments in block scanning.
Also adds a skeleton `zcash_client_sqlite` implementation of
`shardtree::ShardStore` and a skeleton migration for related
database changes.
2023-06-29 15:35:18 -06:00
Kris Nuttycombe 32e2991c4d zcash_client_backend: Add note commitment tree sizes to `CompactBlock` serialization. 2023-06-26 10:19:43 -06:00
Hazel OHearn 4fbdd64c89 Add Orchard support to `zcash_primitives::transaction::builder::Builder`
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2023-06-23 14:09:59 -06:00
Nate Wilcox 5ba44b9019 Update dependencies to resolve https://rustsec.org/advisories/RUSTSEC-2022-0090 2023-06-17 12:44:35 -07:00
Kris Nuttycombe e7fb276b04 Release zcash_proofs 0.12.0 2023-06-06 15:56:29 -06:00
Kris Nuttycombe f9cacc5b21 Release zcash_primitives 0.12.0 2023-06-06 15:56:28 -06:00
Kris Nuttycombe 60ac1070c5 Release zcash_address version 0.3.0 2023-06-06 15:53:16 -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 0b126a107c
Clarify `Zip321Error::TooManyPayments` documentation.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2023-06-06 09:29:43 -06:00
Kris Nuttycombe bca951bf44 doc-only: Document ZIP 321 error variants.
Fixes #499
2023-06-06 08:42:54 -06:00
Kris Nuttycombe ebcfae987d Update the data access API in preparation for shardtree introduction. 2023-06-02 10:59:17 -06:00
Kris Nuttycombe 4b3ea857df
Merge pull request #818 from nathan-at-least/resolve-RUSTSEC-2023-0018
Bump `tempfile` to 3.5.0 to mitigate RUSTSEC-2023-0018…
2023-05-22 20:19:43 -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
Kris Nuttycombe d99b4d4d6e Update memo retrieval API to reflect that memos may not be present.
Memos may be absent for both sent and received notes in cases where only
compact block information has been used to populate the wallet database.
This fixes a potential crash in the case that we attempt to decode a
SQLite `NULL` as a byte array. It does, however, introduce a slight
semantic confusion that will need to be considered in the case of future
updates where a note may not have an associated memo; at present, the
only reason we might not have the memo is that we might not have
retrieved the full transaction information from the chain, but in the
future there might be other possible reasons for this absence.

Fixes #384
2023-05-16 10:27:40 -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
Kris Nuttycombe 87212b6137
Merge branch 'main' into resolve-RUSTSEC-2023-0018 2023-05-12 09:08:59 -06:00
Kris Nuttycombe a718810fa8
Update zcash_client_backend/src/data_api/wallet.rs 2023-05-09 12:32:56 -06:00
Daira Emma Hopwood 9cc6319f26 Fix clippy lints.
Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-05-09 17:59:03 +01:00
Daira Emma Hopwood 3903935234 Deprecate `transaction::components::amount::DEFAULT_FEE` and
`zcash_primitives::transaction::fees::fixed::FeeRule::standard()`.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-05-09 17:18:34 +01:00
Daira Emma Hopwood 736d11b45b Change `transaction::fees::fixed::FeeRule::standard()` to use the ZIP 317
minimum fee (10000 zatoshis rather than 1000 zatoshis) as the fixed fee.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-05-09 16:42:41 +01:00
Daira Emma Hopwood 4cf27126e5 Revert "Update DEFAULT_FEE to 10_000 from 1000"
This reverts commit 2a6dc59c5d.

Signed-off-by: Daira Emma Hopwood <daira@jacaranda.org>
2023-05-09 13:15:52 +01:00
Kris Nuttycombe d37e6adee5
Merge pull request #783 from nuttycom/upgrade_bridgetree
Upgrade `zcash_primitives` to use updated `incrementalmerkletree` types.
2023-05-08 12:00:00 -06:00
str4d 579ab92b93
Merge branch 'main' into 823-secp256k1-0.26 2023-05-08 18:53:33 +01:00
Kris Nuttycombe 1f9747e15f Move merkle tree types to the `incrementalmerkletree` crate.
This removes the `CommitmentTree`, `IncrementalWitness`, and
`MerklePath` types in favor of equivalent versions available
from the `incrementalmerkletree` crate.
2023-05-04 12:30:56 -06:00
Kris Nuttycombe ec57d23115 Use const generics to set commitment tree & incremental witness depths.
This is in preparation for extraction into the `incrementalmerkletree`
crate, which is not Sapling-specific and therefore cannot hard-code
the depths of these data structures.
2023-05-04 12:16:09 -06:00
Hazel OHearn 2a6dc59c5d
Update DEFAULT_FEE to 10_000 from 1000 2023-05-03 16:42:01 -03:00
Jack Grigg 8b53d4a0c4 zcash_client_backend 0.9.0 2023-04-28 01:46:28 +00:00
Kris Nuttycombe fa282695da Store change notes as received for internal transfers. 2023-04-27 14:41:26 -06:00
Kris Nuttycombe f3745c0cb5 Make the internal state of `SentTransactionOutput` private. 2023-04-27 13:07:34 -06:00
Kris Nuttycombe ac3439e65e Rename *rewind* to *truncate* in data_api methods.
This better reflects the semantics of wallet behavior. Also, this
adds a `zcash_client_backend::WalletRead::get_min_unspent_height`
method that replaces the deprecated & removed (and misleadingly
named) `get_rewind_height` method.
2023-04-27 09:12:07 -06:00
Kris Nuttycombe 7405d0cd69 Make internals of `WalletSaplingSpend` and `WalletSaplingOutput` private. 2023-04-26 14:47:10 -06:00
Kris Nuttycombe bfc5b9a5b3 Parameterize `DecryptedOutput` by note type. 2023-04-26 14:47:10 -06:00
Kris Nuttycombe 55c2de0066 Remove the redundant `WalletSaplingOutput::to` and `DecryptedOutput::to` fields. 2023-04-26 14:47:10 -06:00
Kris Nuttycombe c15a185454 Remove deprecated APIs & rename Sapling-specific data structures to include "Sapling"
This helps to clarify the Sapling-specific nature of a number of
operations in wallet code.
2023-04-26 14:47:10 -06:00
Jack Grigg ec1c1bcf21 Migrate to `secp256k1 0.26`, `hdwallet 0.4`
Closes zcash/librustzcash#823.
2023-04-19 19:33:34 +00:00
Jack Grigg 4dbb9c01e5 zcash_client_backend 0.8.0 2023-04-15 00:00:40 +00:00
Jack Grigg 4678ff8299 zcash_proofs 0.11.0 2023-04-14 23:58:53 +00:00
Jack Grigg a419b56e80 zcash_primitives 0.11.0 2023-04-14 23:56:16 +00:00
Jack Grigg 7be5d1bf7d Update changelogs 2023-04-14 23:49:13 +00:00
Nate Wilcox 25f03f8dc0 Bump `tempfile` to 3.5.0 to mitigate RUSTSEC-2023-0018…
See https://rustsec.org/advisories/RUSTSEC-2023-0018

This is one of multiple audit failures reported in: https://github.com/zcash/librustzcash/issues/816
2023-04-14 16:40:13 -07:00
Jack Grigg f82866dbb9 Migrate to `bech32 0.9` 2023-04-11 16:01:19 +00:00
Jack Grigg 6b7c62eb22 zcash_client_backend: Migrate to `base64 0.21` 2023-04-11 15:57:16 +00:00
Jack Grigg 3fb66a8aa1 zcash_client_backend: Migrate to `tonic 0.9` 2023-04-11 15:48:44 +00:00
Jack Grigg 2fcde5e047 Migrate to `orchard 0.4.0`
Closes zcash/librustzcash#766.
2023-04-11 13:25:17 +00:00
Kris Nuttycombe f1f63043ca Ensure that Sapling padding outputs are taken account in ZIP 317 change computation.
Fixes #799
2023-04-05 21:39:27 -06:00
Kris Nuttycombe d6fafa291b Update Sapling note encryption for `zcash_note_encryption 0.3.0`
Fixes zcash/librustzcash#455
2023-03-21 11:09:38 -06:00
Kris Nuttycombe c696069f93 Bump zcash_note_encryption to version 0.3.0 for release.
This removes the path-based dependencies on the `zcash_note_encryption`
crate in favor of using versioned dependencies locally. This better
reflects the future state in which `zcash_note_encryption` is factored
out of the workspace and maintained in a separate repository.
2023-03-20 16:16:34 -06:00
Kris Nuttycombe cb1be45f22 Update CHANGELOGs to reflect the addition of the zcash_primitives/multicore feature. 2023-03-20 15:11:05 -06:00
Kris Nuttycombe 7c1a4c898d Fix wasm32 CI runner.
The `halo2_proofs/multicore` flag must be disabled when running wasm
builds; this ensures that we do not accidentally include it as a
transitive dependency when building with `--no-default-features`.
2023-03-20 14:39:07 -06:00
Kris Nuttycombe 77fbd8cb4f Update dependencies to reflect changes in ff 0.13 2023-03-20 14:35:45 -06:00
Jack Grigg d8cb20e091 zcash_client_backend 0.7.0 2023-02-01 02:11:56 +00:00
Jack Grigg 24b5e04c8d zcash_proofs 0.10.0 2023-02-01 02:10:42 +00:00
Jack Grigg 9852c31970 zcash_primitives 0.10.0 2023-02-01 02:10:42 +00:00
Jack Grigg 5b00699d66 Update changelogs 2023-02-01 01:58:45 +00:00
str4d b6f7ff06ed
Merge pull request #761 from nuttycom/wallet/expose_transaction_propose
Factor out a transaction proposal API from `spend`.
2023-02-01 00:51:31 +00:00
Kris Nuttycombe 4fafd14d17 Factor out a transaction proposal API from `spend`.
This change makes it possible for wallets using the
`zcash_client_backend::data_api::wallet` module to perform transaction
preparation, including input selection and fee calculation, as an
independent step prior to creating proofs and signatures. This can be
used to improve user experience by making it possible to report the
proposed effects of the transaction to the wallet user (including
privacy implications) prior to authorizing the transaction.
2023-02-01 00:15:33 +00:00
Francisco Gindre 444591705c Rephrase documentation for `validate_chain()` at data_api/chain.rs
Delete documentation no longer being accurate for `validate_chain()`
2023-01-31 13:14:07 -07:00
Kris Nuttycombe 636bac7154 Make block height argument to `BlockSource::with_blocks` optional.
Previously, if a caller wanted to use a block source to perform
scanning from the first available block, they would have to guess
at the block height to start from. Changing this to an optional
argument makes this explicit.
2023-01-31 13:14:07 -07:00
Francisco Gindre bf73ed3a00 Adds `limit` parameter to `validate_chain()`
This allows callers to validate smaller intervals of the given
`BlockSourceT` shortening processing times of the function call at the
expense of obtaining a partial result on a given section of interest of
the block source.

`params: &ParamsT` has been removed from the arguments since they were
only needed to fall back to `sapling_activation_height` when `None` as
passed as the `validate_from` argument. Passing `None` as validation
start point on a pre-populated `block_source` would result in an error
`ChainError::block_height_discontinuity(sapling_activation_height - 1, current_height)`

With this new API callers must specify a concrete `validate_from`
argument and assume that `validate_chain` will not take any default
fallbacks to chain `ParamsT`.

The addition of a `limit` to the chain validation function changes the
meaning of its successful output, being now a `BlockHeight, BlockHash)`
tuple indicating the block height and block hash up to which the chain
as been validated on its continuity of heights and hashes. Callers
providing a `limit` aregument are responsible of subsequent calls to
`validate_chain()` to complete validating the remaining blocks stored on
the `block_source`.

Closes zcash/librustzcash#705
2023-01-31 13:14:04 -07:00
Francisco Gindre e9eb5f8c0f Remove unstable function `WalletWrite::remove_unmined_tx`
Closes #622

Used PR https://github.com/zcash/librustzcash/pull/621 as reference to
know what had been added and remove it.
2023-01-31 15:21:46 -03:00
Jack Grigg 7f970bb82f Use `EphemeralSecretKey, EphemeralPublicKey, SharedSecret` types in APIs 2023-01-24 15:02:49 +00:00
Jack Grigg ded14adbb3 Add `sapling::keys::DiversifiedTransmissionKey` 2023-01-24 15:02:38 +00:00
Jack Grigg 06ba399d80 Clean up the `sapling::Note` API 2023-01-24 15:02:32 +00:00
Jack Grigg 87d0bd7db1 Refactor `sapling::Note`
Its internals are now private, and it stores a `PaymentAddress` (and by
extension the diversifier) instead of `g_d`.
2023-01-24 15:02:27 +00:00
Jack Grigg dff21222fb Require `PaymentAddress` to contain a valid diversifier 2023-01-24 14:51:13 +00:00
Jack Grigg 42c332a7a8 Use `sapling::note::ExtractedNoteCommitment` type in APIs 2023-01-24 14:37:11 +00:00
Jack Grigg 49b1cb3e69 Bump MSRV for `zcash_primitives` and dependents to 1.60
The MSRVs of the component crates are left as-is, partly because our
dependencies don't require us to bump them, and partly because those
crates have no pending changes and are relatively stable. We also plan
to split the component crates out into a separate repository, where it
will be easier to have a separate MSRV.

Closes zcash/librustzcash#759.
2023-01-19 23:48:24 +00:00
Kris Nuttycombe 95cbc7abaf
Merge pull request #734 from zcash/sapling-type-safety
Improve Sapling type safety
2023-01-05 13:12:45 -07:00
Kris Nuttycombe 125d2bc3d5
Merge pull request #727 from nuttycom/test/shield_transparent_funds
Add `shielding_threshold` argument to `shield_transparent_funds`.
2022-12-15 13:11:55 -07:00
Kris Nuttycombe 76f0f0510e
Update zcash_client_backend/CHANGELOG.md
Co-authored-by: str4d <thestr4d@gmail.com>
2022-12-15 11:10:32 -07:00
Jack Grigg fee0b6a18d Make Sapling transaction structs non-transparent
We instead provide getters for the struct fields.
2022-12-13 04:03:06 +00:00
Jack Grigg 38e3280545 Update generated protobuf bindings 2022-12-11 13:28:52 +00:00
Kris Nuttycombe 0f56f095c2 Add `shielding_threshold` argument to `shield_transparent_funds`.
Previously, the shielding threshold was fixed to 100000 zatoshis.

Fixes #726
2022-12-08 17:15:48 -07:00
Jack Grigg 1ea585fee9 zcash_client_backend 0.6.1 2022-12-06 08:18:34 +00:00
Jack Grigg 7e71cc5353 Add `tracing` spans to light client chain scanning
This enables downstream users to profile how much time is spent in each
of the main subcomponents of the current chain scanner.
2022-12-06 08:17:49 +00:00
Kris Nuttycombe 580f87dc3e
Merge pull request #701 from zcash/update-generated-protobufs
Update generated protobufs
2022-11-18 17:25:15 -07:00
Greg Pfeil 4b5086d51d Parse ZIP 321 URIs without query parameters
Fixes #707.
2022-11-17 18:44:36 -07:00
Greg Pfeil 29af0bcb29 Add a failing test for ZIP 321 URI without params 2022-11-17 17:10:21 -07:00
Jack Grigg 81f8f6a5a4 Update generated protobufs
`prost 0.11.2` added code formatting support, so the generated files now
better match what rustfmt produces.
2022-11-12 05:26:07 +00:00
Jack Grigg a583255d45 Document that `decrypt_and_store_transaction` always stores the tx
Closes zcash/librustzcash#497.
2022-11-11 22:11:59 +00:00
Jack Grigg 98dd130f3a zcash_client_backend 0.6.0 2022-11-11 20:47:21 +00:00
Jack Grigg c03ef4926a zcash_proofs 0.9.0 2022-11-11 20:39:36 +00:00
Jack Grigg c3b6e5a72a zcash_primitives 0.9.0 2022-11-11 20:37:55 +00:00
Jack Grigg 318d1b7522 Clean up changelogs 2022-11-11 20:29:26 +00:00
str4d 53d56362cd Fix typos in error type `Display` messages 2022-11-11 05:33:48 +00:00
Kris Nuttycombe ed96131c4f Add missing `std::fmt::Display` implementations for error types. 2022-11-10 21:17:57 -07:00
str4d 796b5a4fed
ZIP 317: Improve code comments 2022-11-11 00:58:31 +00:00
Kris Nuttycombe 73ab884073 Implement ZIP 317 fee estimation, calculation, & change selection 2022-11-10 15:30:13 -07:00
Kris Nuttycombe 847ba49761 Add dust note detection to change selection.
The change selection algorithm has the most useful information for
determining whether or not a note is dust, so this adds a new error case
to `ChangeError` that allows the change selection to report the presence
of input notes without economic value back to its caller.
2022-11-10 12:18:30 -07:00
Kris Nuttycombe 9a7dc0db84 Add traits for fee estimation and input selection
This adds a set of abstractions that allow wallets to provide
independent strategies for fee estimation and note selection, and
implementations of these strategies that perform these operations in the
same fashion as the existing `spend` and `shield_transparent_funds`
functions.

This required a somewhat hefty rework of the error handling in
zcash_client_backend. It fixes an issue with the error types whereby
callees needed to have a bit too much information about the error
types produced by their callers.

Reflect the updated note selection and error handling in zcash_client_sqlite.
2022-11-10 12:17:59 -07:00
str4d 6f4a6aa00c
Merge pull request #695 from nuttycom/fix_clippy_lints
Fix clippy complaints about generated protobuf code.
2022-11-05 00:15:47 +00:00
Kris Nuttycombe fb8681adbb Ignore clippy lints in generated protobuf modules. 2022-11-04 14:14:56 -06:00
Kris Nuttycombe 18e61346cc Spend internal Sapling notes with the internal Sapling spending key. 2022-11-04 13:27:23 -06:00
Kris Nuttycombe cdfca848ea Improve type safety of note commitment tree node construction. 2022-11-03 18:44:48 -06:00
Kris Nuttycombe 1be86b7a54 Derive the correct note when spending from a change address. 2022-11-03 18:44:48 -06:00
Kris Nuttycombe b68d37a0b1 Use DiversifiableFullViewingKey instead of ExtFVK where possible. 2022-11-03 18:44:45 -06:00
str4d d4f4f5ad91
Merge pull request #658 from nuttycom/wallet/builder_explicit_change
Update the transaction builder to make change outputs explicit
2022-11-04 00:42:31 +00:00
Kris Nuttycombe 9c894ebf3e Create per-protocol fees modules. 2022-11-03 15:07:14 -06:00
Kris Nuttycombe 37e78e1fe3 Expose less information about Sapling outputs to change calculation. 2022-11-03 09:56:50 -06:00
Kris Nuttycombe 1be97e9cef Address comments from code review. 2022-11-03 09:56:08 -06:00
Jack Grigg 4d6e2bcf59 Merge pull request #642 from zcash/lightwalletd-grpc-bindings
zcash_client_backend: Add gRPC bindings behind feature flag
2022-11-03 05:32:29 +00:00
Jack Grigg 587e1fa60b Fix clippy lints related to `prost` API usage 2022-11-03 05:02:39 +00:00
Kris Nuttycombe 9496fc6118 Add fee calculator to the transaction builder.
This adds a fee calculation strategy abstraction that can be used to
dynamically compute fees so that the total fees required may be taken
taken into account during note selection, and also removes automatic
change creation from the transaction builder.

Change outputs must now be directly created by the caller by the caller.
This is a necessary prerequisite for permitting fees to adjust based
upon the contents of the transaction being constructed.

The initial implementation of the fee strategy simply uses the current
default fee.
2022-11-02 08:28:16 -06:00
Jack Grigg 17a4830c70 zcash_client_backend: Add gRPC bindings behind feature flag
The lightwalletd service file is sourced from:
  Git: https://github.com/zcash/lightwalletd
  Rev: ad5ecda5fbb5e12799f926b8cd785d54fdd250c8

Closes zcash/librustzcash#585.
2022-11-02 06:22:02 +00:00
Jack Grigg 379b703e6b zcash_client_backend: Switch from `protobuf 2` to `prost 0.11`
The latter is maintained by the Tokio developers, and has easy
integration with the `tonic` gRPC library which is actively maintained.
2022-11-02 06:21:38 +00:00
Jack Grigg 3720b45feb Categorise dependencies in `Cargo.toml` files
This should make it easier to upgrade dependencies in future.
2022-11-01 09:02:54 +00:00
Jack Grigg a0016588ac Remove unused dependencies
Some were only used by tests, others weren't used at all.
2022-11-01 09:02:27 +00:00
Kris Nuttycombe 334383f363 Allow shielding from multiple taddrs within a single transaction. 2022-10-25 13:17:21 -06:00
Kris Nuttycombe efa95fcb39 Add `get_transparent_balances` to data api. 2022-10-25 12:53:54 -06:00
Kris Nuttycombe 8cb16d878e Require a source transparent address to shield transparent funds.
Previously, `shield_transparent_funds` was only shielding funds
associated with the legacy default transparent address. This meant
that transparent funds sent to unified addresses could not reliably
be shielded, as a unified address will frequently be constructed
using a diversifier index greater than zero.

This modifies the `get_transparent_receivers` method to return address
metadata containing the account ID and diversifier index used to derive
each address along with the receiver.
2022-10-25 12:53:54 -06:00
Sean Bowe bd7f9d7c3c
Bump zcash_encoding and zcash_address crate versions to 0.2. 2022-10-19 16:51:59 -06:00
Kris Nuttycombe 5bf36989e2 Fix beta clippy complaints. 2022-10-19 13:35:51 -06:00
Sean Bowe 176e21b015
Update zcash_primitives to orchard 0.3; release zcash_primitives and zcash_proofs 0.8. 2022-10-19 13:32:51 -06:00
Jack Grigg b3dc323876 zcash_client_backend: Fix missing bound
In 47a0d0d2b7 `WalletWriteTransparent` was
merged into `WalletWrite`, including its associated type `UtxoRef`.
However, `shield_transparent_funds` placed a bound on this associated
type that was not moved to `WalletWrite`. This left the generic
parameter `U` unconstrained, which didn't cause a local failure because
the method has no local tests, but was immediately apparent when trying
to use the method in the mobile SDKs.
2022-10-14 20:45:35 +00:00
Kris Nuttycombe c773ea3b3e Make the internals of `WalletTransparentOutput` private. 2022-10-14 12:38:55 -06:00
Kris Nuttycombe 69791af92c Mark our utxos spent when we detect them as inputs to a transaction.
This modifies `decrypt_and_store_transaction` to check for inputs
to a transaction being decrypted that correspond to utxos known
to our wallet. For each such UTXO found, it is marked spent.
2022-10-14 10:40:43 -06:00
Kris Nuttycombe 47a0d0d2b7 Remove the `WalletReadTransparent` and `WalletWriteTransparent` extension traits.
These traits introduce a problem, in that constraints on a method cannot
be conditionally required based upon the presence or absence of a
feature flag. Instead, we make the methods previously introduced by
the removed traits present in all cases on the `WalletRead` and
`WalletWrite` traits, but ensure that their implementations return
an error if the caller attempts to use them in a wallet that has not
been configured with support for transparent inputs functionality.
2022-10-13 21:05:49 -06:00
Jack Grigg 8f068b3b71 zcash_note_encryption 0.2.0 2022-10-13 21:35:39 +00:00
Jack Grigg 8842de18cc Remove unused dependencies
These were mostly detected with `cargo-udeps`, for which I've also added
exclusions for the dependencies it can't detect are used in doc-tests.
2022-10-13 20:06:52 +00:00
Kris Nuttycombe f1f9465f37 Remove `received_by_account` field from WalletTransparentOutput
Due to how the wallets retrieved unspent transparent outputs from the
light wallet server, the account associated with a particular UTXO may
not be known by the light wallet. Instead of requiring the caller to
perform a separate lookup and match the address of the received UTXO
with a known account, it's simpler to perform this lookup internally at
the time of insertion or update.

In order to make this operation more efficient, the `addresses_table`
migration is modified to add a column to cache the transparent receiver
so that it may be used in the joins in the UTXO insert and update
operations.
2022-10-12 23:11:39 -06:00
Kris Nuttycombe f7a3b9bda3
Merge pull request #661 from nuttycom/wallet/spend_with_usk
Use unified spending keys for spends & shielding.
2022-10-12 12:15:34 -06:00
Kris Nuttycombe c3b6ef28c9
Merge pull request #647 from nuttycom/update_ua_test_vectors
Update unified address test vectors
2022-10-12 10:56:26 -06:00
Kris Nuttycombe 6893da3054
Update zcash_client_backend/src/keys.rs
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-10-12 09:19:44 -06:00
Kris Nuttycombe e666e69230 Address comments from code review. 2022-10-11 16:21:17 -06:00
Kris Nuttycombe 62e1f99eb0 Improve TransferType documentation. 2022-10-11 14:42:06 -06:00
Kris Nuttycombe fd1640c242 Update CHANGELOGs 2022-10-11 13:08:15 -06:00
Kris Nuttycombe 3c837381db Disallow invalid pool/address combinations with `Recipient`. 2022-10-11 12:52:44 -06:00
Kris Nuttycombe 56b2edd498 Simplify sqlite backend storage for sent notes & utxos.
The currently deprecated implementations of `insert_sent_utxo`,
`insert_sent_note`, `put_sent_utxo` and `put_sent_note` all store to the
same `sent_notes` table internally. Since there's no immediate plan to
change this arrangement, it's better to have a single pair of internal
`insert_sent_output` and `put_sent_output` methods instead.
2022-10-11 08:57:44 -06:00
Kris Nuttycombe ee9869bbeb Use declarative style for `decrypt_transaction` 2022-10-11 08:56:26 -06:00
Kris Nuttycombe 06e43a572a Track inputs sent to wallet-internal recipients.
Ensure that we're attempting trial-decryption with the internal IVK
and correctly track internal vs. external recipients in the wallet
database.
2022-10-11 08:56:22 -06:00
str4d 1dc3cfe724
Merge pull request #657 from nuttycom/wallet/upsert_utxos
Use upsert functionality for transparent UTXOs, rather than delete/repopulate.
2022-10-11 04:17:49 +01:00
Kris Nuttycombe bd8472535c Add a test for unified address derivation. 2022-10-07 20:37:39 -06:00
Kris Nuttycombe 34a7abd653 Update unified address test vectors
This updates unified address test vectors after
https://github.com/zcash-hackworks/zcash-test-vectors/pull/89
to check addresses across multiple diversifier indices, and also
removes the superfluous binary encoding of UA strings.
2022-10-07 19:50:32 -06:00
Kris Nuttycombe b6e263d259
Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-10-05 20:33:14 -06:00
Kris Nuttycombe c5b9219f00 Look up the account by the UFVK corresponding to the USK when spending. 2022-10-05 14:35:51 -06:00
Kris Nuttycombe b7cc038050 Use unified spending keys for spends & shielding. 2022-10-05 14:35:51 -06:00
Kris Nuttycombe 6df6fec860 Add utxo received_by_account data to WalletTransparentOutput
Also, this removes wallet::delete_utxos_above.
2022-10-04 13:34:52 -06:00
Kris Nuttycombe 60785a1d7a Fix Sapling key organization.
This change moves Sapling-specific key generation into a
submodule of `zip32`. Public reexports are used to keep the
existing API consistent.
2022-10-03 20:28:04 -06:00
Jack Grigg b3f13020ac zcash_client_backend: Remove direct ff dependency 2022-10-02 23:15:51 +01:00
Jack Grigg 035e53990c zcash_client_backend: Improve estimation of `rayon` spawned task size 2022-09-24 21:01:19 +00:00
Jack Grigg 913aa0a988 zcash_client_backend: Correctly track heap usage of batch items
As of zcash/librustzcash#633, `SaplingDomain::IncomingViewingKey` now
allocates memory internally, and this memory persists as long as the
`BatchRunner` is alive. Now that we have decoupled the measurement of
heap usage for batch tasks from their internals, we can add bounds to
all of the generic parameters of `Batch` to enable correctly measuring
their actual heap usage.

We also add `DynamicUsage` impls for a bunch of `zcash_primitives` types
that will be used with `BatchRunner` (or its equivalent implementation
in `zcashd`) by callers.
2022-09-24 21:01:19 +00:00
Jack Grigg c98f04330d zcash_client_backend: Move heap tracking of batch tasks behind a trait
This enables the heap usage measurements to be conditionally enabled by
the `BatchRunner` user. Importantly, when heap usage measurements are
not enabled, the `DynamicUsage` bound on `Batch` is not required.

This refactor also fixes a bug in the prior implementation. We were
counting the heap usage of a task when it started to run, but the item
may have been in the `rayon` work-stealing queues for a non-negligible
period before then. We now count the heap usage immediately before
spawning the task into the `rayon` thread pool.
2022-09-24 17:20:55 +00:00
Jack Grigg fe258ca120 zcash_client_backend: Count `tags` in `impl DynamicUsage for Batch` 2022-09-24 13:06:04 +00:00
Jack Grigg 9a1d61cb4e zcash_client_backend: Only store successes in batch scanner
Previously we were sending an `Option<DecryptedNote>` from each `Batch`
back to its parent `BatchRunner`. However, this requires allocating
sufficient space in the channel to handle the case where every output
can be decrypted. In general this will not be the case, and we can
instead signal "nothing decrypted" by just dropping the channel sender.
This reduces the post-batch-scanning memory usage of `BatchRunner` from
being linear in the number of on-chain outputs, to being linear in the
number of outputs for the wallet.

Ported from zcash/zcash@f7f6c2070d.
2022-09-21 23:51:40 +00:00
Jack Grigg 533722b70e zcash_client_sqlite: Add dynamic memory usage tracking to `BatchRunner`
Ported from zcash/zcash@e88ea11055.
2022-09-21 23:38:44 +00:00
Daira Hopwood 20e869f501 zcash_primitives: Use prepared epk and ivk in Sapling note decryption
Co-authored-by: Jack Grigg <jack@electriccoin.co>
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-09-15 03:40:45 +01:00
Kris Nuttycombe 3bc8627e2b
Merge pull request #637 from nuttycom/wallet/create_account
Add WalletWrite::create_account function
2022-09-14 14:30:34 -06:00
Kris Nuttycombe d086c57f2f Make init_accounts_table only permit sequential account identifiers.
Also, check to ensure that account creation does not exceed the
maximum account identifier value.
2022-09-14 13:55:31 -06:00
Kris Nuttycombe 75eb082203
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2022-09-14 12:20:39 -06:00
Kris Nuttycombe d0062a87d4 Add WalletWrite::create_account function 2022-09-13 18:58:28 -06:00
Jack Grigg f7b7760051 zcash_client_backend: Add some typedefs for complex types 2022-09-13 21:58:32 +00:00
Jack Grigg 8f03208439 zcash_client_backend: Add tags to IVKs in the batch scanner
This removes the dependency on `SaplingIvk::to_repr()`, and enables us
to alter the type of `D::IncomingViewingKey` to improve the performance
of batch scanning.

For the welding rig, we already annotate the viewing keys with
`AccountId`, so we use `(AccountId, Scope)` as the tag.
2022-09-13 21:40:58 +00:00
Kris Nuttycombe b5908dc964
Merge pull request #632 from nuttycom/data_api/get_next_address
Replace `get_address` with `get_current_address` and `get_next_available_address`
2022-09-12 18:43:38 -06:00
Kris Nuttycombe 03b0ff7e0a Replace `get_address` with `get_current_address` and `get_next_available_address`
This updates the data access API to provide diversified address
functionality. In order to support this change, the addresses table
is updated to store diversifier index information in big-endian order
to allow sorting by diversifier index, and account initialization
is updated to store the diversifier index accordingly. The currently
unreleased `addresses_table` migration is updated to reflect this
change.
2022-09-12 17:58:22 -06:00
Kris Nuttycombe 95610f7b4f Add fee to the transactions table & compute correct net_value in v_transactions. 2022-09-09 16:12:29 -06:00
Jack Grigg 7112ed9da5 zcash_client_backend: Add `WalletReadTransparent::get_transparent_receivers`
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2022-09-08 20:24:42 +00:00
Jack Grigg 7d404d2747 zcash_client_sqlite: Fix `WalletRead::get_address` return value
Previously it would return an error if the account identifier did not
correspond to a known account.
2022-09-08 18:49:41 +00:00
Jack Grigg a32714043b zcash_client_backend: Change `WalletRead::get_address` to return UA 2022-09-08 18:49:13 +00:00
Kris Nuttycombe 8439f1a4f7 Add binary encoding for unified spending keys.
This encoding is wallet-internal-only and is currently
guarded under the `unstable` feature flag.
2022-09-08 11:05:59 -06:00
Kris Nuttycombe a93f5945ab Remove redundant TryFrom/TryInto imports. 2022-09-02 12:05:15 -06:00
Kris Nuttycombe 16a0e43f2d Update to Rust 2021 and explicitly set MSRVs 2022-09-02 12:05:09 -06:00
Jack Grigg 4f5d757883 zcash_client_backend: Change to `WalletWrite::remove_unmined_tx`
This fixes a bug in the logic ported from the Android SDK: it was
possible to remove a transaction in the middle of a chain, which would
cause a long-spent note to become unspent and cause the wallet balance
to be over-counted. We now restrict transaction removal to unmined
transactions, which is sufficient for the Android SDK use cases.
2022-08-30 22:54:58 +00:00
Jack Grigg 586b7e5bb0 zcash_client_backend: Add `WalletWrite::remove_tx` method
This is to replace the database mutations in the Android SDK. It is
placed behind an `unstable` feature flag until we are satisfied that it
is suitable as a general-purpose API (or replace it).
2022-08-29 21:32:18 +00:00
Kris Nuttycombe ba1bb65a5f Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2022-08-26 16:09:05 -06:00
Kris Nuttycombe c4da498cf4 Shield funds to the internal Sapling key for a specified account.
This updates `shield_transparent_funds` to look up the internal
(change) address for the account specified, and use that as the
destination for shielding transparent funds.

Fixed #614
2022-08-26 16:03:25 -06:00
Jack Grigg b42344d491 zcash_client_backend: Generate Orchard component for USKs
This ensures that the resulting UFVKs and UAs also contain Orchard
components.
2022-08-24 14:56:58 +00:00
Kris Nuttycombe 397c76ca8d Add tests for batched note decryption. 2022-08-18 16:48:52 -06:00
Kris Nuttycombe 6156215d4c Add parallelized batched trial decryption to wallet scanning.
Co-authored-by: str4d <jack@electriccoin.co>
2022-08-18 16:48:22 -06:00
Kris Nuttycombe 7acd47eae8 Copy parallel batch decryption data types from zcash/zcash
This is an unmodified copy of 7d1e14ac3d/src/rust/src/wallet_scanner.rs

Co-authored-by: str4d <jack@electriccoin.co>
2022-08-18 16:40:27 -06:00
str4d 85a1522c22
Merge pull request #607 from adityapk00/oa
Return orchard address from UA
2022-08-18 23:32:19 +01:00
Kris Nuttycombe 880076b38f Improve error reporting for address & viewing key decoding. 2022-08-18 10:15:58 -06:00
Aditya Kulkarni 1fad73d5b3 Return orchard address from UA 2022-08-17 08:10:06 -05:00
Kris Nuttycombe 199c49760b Use the new name rustdoc::broken_intra_doc_links 2022-07-29 15:56:44 -06:00
Kris Nuttycombe 8a6e979cb9 Change return type of ScanningKey::to_sapling_keys to an associated type. 2022-07-28 17:28:31 -06:00
Kris Nuttycombe 73314dc682 Use batch decryption in wallet scanning.
This modifies wallet scanning to perform per-block batched
decryption. It also alters the structure of the `ScanningKey`
trait to correctly include internal (change) keys in the scan
process.
2022-07-28 17:28:31 -06:00
Kris Nuttycombe f1c2da7b1d Add sapling::NullifierDerivingKey newtype.
Nullifier computation only requires the nullifier deriving key,
not the entire Sapling viewing key. This separation of concerns
will be needed for batch decryption when wallet-internal keys
will need to be considered.
2022-07-28 15:23:21 -06:00