Commit Graph

529 Commits

Author SHA1 Message Date
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
Kris Nuttycombe 878a428c3c Factor out witness updates from scan_output 2022-07-28 15:23:21 -06:00
Kris Nuttycombe 94c8d8e7ef Return the network type for encoding addresses as part of the network parameters. 2022-06-30 12:09:32 -06:00
Daira Hopwood 09567fc280
Merge pull request #574 from nuttycom/fix_account_key_init
Fix account key init
2022-06-29 21:36:29 +01:00
Kris Nuttycombe 0e098e1f17 Test correctness of unknown ufvk element roundtrip encoding. 2022-06-29 10:13:22 -06:00
Daira Hopwood dae2e008e9
Merge pull request #577 from daira/bosl-notice
Projects that rely on BOSL exceptions should say that they do
2022-06-29 12:59:07 +01:00
Kris Nuttycombe 0142a3db1b
Merge pull request #570 from zcash/387-migrate-from-extfvk-to-ufvk
`zcash_client_*`: Migrate from `ExtendedFullViewingKey` to `UnifiedFullViewingKey`
2022-06-28 10:49:37 -06:00
Daira Hopwood a9aa2929d2 Address feedback about the use of "permissive".
Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-06-28 16:46:13 +01:00
Daira Hopwood 75ca854005 Projects that rely on BOSL exceptions should say that they do.
fixes #576

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
2022-06-28 12:29:16 +01:00
Kris Nuttycombe 7236204b14 Don't panic if the sapling key is missing from the UFVK
Instead, just skip Sapling decryption.

Also, a trivial namespacing fix.
2022-06-27 17:44:20 -06:00
Jack Grigg 6f4de16b97 zcash_proofs 0.7.0 2022-06-24 17:00:39 +00:00
Jack Grigg e952ff637e zcash_primitives 0.7.0 2022-06-24 17:00:39 +00:00
Jack Grigg 18fb1f0b07 orchard 0.2 2022-06-24 16:25:51 +00:00
Jack Grigg b52e949bd6 zcash_client_backend: Migrate to correct ZIP 316 UFVK encoding
We also add support for parsing Orchard full viewing keys from encoded
UFVKs (rather than treating them as unknown). `UnifiedSpendingKey` still
does not have Orchard support, so `UnifiedFullViewingKey`s will be
generated without Orchard components.
2022-06-17 10:03:17 +00:00
Jack Grigg 76d015ed11 zcash_client_backend: Fix `UnifiedFullViewingKey` Sapling item type
Per ZIP 316, the Sapling FVK Encoding only includes `(ak, nk, ovk, dk)`
which is a subset of the Sapling `ExtendedFullViewingKey`. We therefore
need to use `DiversifiableFullViewingKey` inside `UnifiedFullViewingKey`
in order to make it parseable from the UFVK string encoding.

`zcash_client_sqlite::wallet::get_extended_full_viewing_keys` has been
removed as a consequence of this change: we can no longer reconstruct
the correct `ExtendedFullViewingKey` from the `UnifiedFullViewingKey`.
2022-06-17 10:03:17 +00:00
Jack Grigg d8b860207d zcash_client_backend: Remove account from `UnifiedFullViewingKey`
The account number is not stored in the ZIP 316 UFVK encoding, and in
general won't necessarily be known (e.g. if a UFVK is being imported
into a wallet).

`zcash_client_sqlite::wallet::init::init_accounts_table` reverts to its
previous behaviour of requiring the provided `&[UnifiedFullViewingKey]`
to be indexed by account number.
2022-06-17 10:03:17 +00:00
Jack Grigg 1ce289e568 zcash_client_backend: Pass UFVKs into `decrypt_transaction` 2022-06-17 10:03:17 +00:00
Jack Grigg c0e8ee0fa0 zcash_client_backend: Return UFVKs from `WalletRead` instead of ExtFVKs 2022-06-17 10:03:17 +00:00
Jack Grigg 0d0527dbf3 zcash_client_sqlite: Store UFVK/UA instead of Sapling ExtFVK/address
This is a breaking change to the database format. We don't have support
for migrations yet, so existing wallets won't work after this commit
until zcash/librustzcash#489 is done.
2022-06-14 02:18:25 +00:00
Jack Grigg e86ba927af zcash_client_backend: Add a fake UFVK encoding
We can't use the real ZIP 316 encoding until `UnifiedFullViewingKey` has
been altered to not store a Sapling `ExtendedFullViewingKey`. But making
that change first requires fully migrating `zcash_client_sqlite` in the
same commit (as its entire API is built around `ExtendedFullViewingKey`).

Instead, we define a temporary fake encoding, to enable migrating the
`zcash_client_sqlite` APIs more incrementally.
2022-06-14 02:18:25 +00:00
Jack Grigg 97aee898b2 zcash_client_backend: Box `zip321::parse::Param::Addr`
After adding the `RecipientAddress::Unified` enum case, `Param::Addr`
is now much larger than the other `Param` cases. This change reduces the
size of the `Param` enum, fixing a clippy lint.
2022-06-13 23:04:18 +00:00
Jack Grigg 555a621a10 Add `UnifiedAddress` generation to `UnifiedFullViewingKey` 2022-06-13 23:04:18 +00:00
Jack Grigg ed6016857e zcash_client_backend: Add `RecipientAddress::Unified` 2022-06-10 17:16:59 +00:00
Jack Grigg f20366cf86 zcash_client_backend: Migrate `RecipientAddress` to `zcash_address` 2022-06-10 15:49:19 +00:00
Jack Grigg 1161fc963f zcash_proofs 0.6.0 2022-05-10 23:33:05 +00:00
Jack Grigg 3ecfd26d79 zcash_primitives 0.6.0 2022-05-10 23:33:05 +00:00
Jack Grigg a565c7e113 hdwallet 0.3.1
This release bumped secp256k1 to 0.21.
2022-05-10 23:00:43 +00:00
Jack Grigg 144512b547 Migrate to `ff 0.12` 2022-05-06 20:03:49 +00:00
Kris Nuttycombe 9416ab3a3e Update to secp256k1 v0.21 2022-04-06 16:09:45 -06:00
Jack Grigg 91d9a42a08 Merge branch 'non-consensus-changes-on-branchid-37519621' into merge-non-consensus-changes-3 2022-02-28 23:22:40 +00:00
Kris Nuttycombe 600c06a408 Update MSRV to 1.56.1 2022-02-24 12:26:14 -07:00
str4d efe63ad62b
Merge pull request #515 from str4d/update-compact-proto
zcash_client_backend: Bring in latest `compact_formats.proto`
2022-02-18 00:59:42 +00:00
Jack Grigg cceae3ac34 zcash_client_backend: Address compact_formats.proto comments 2022-02-17 23:58:20 +00:00
Jack Grigg 18562c71dc zcash_client_backend: Bring in latest `compact_formats.proto`
Source: 83bb19918f/walletrpc/compact_formats.proto
2022-02-17 02:44:20 +00:00
Jack Grigg 511ad71a05 Bump `protobuf` to `~2.27.1`
`protobuf 2.26` raised its MSRV to 1.52.1, which we are now above.
`protobuf 2.27.0` raised its MSRV to 1.55.0, but this was reverted in
`protobuf 2.27.1`. In any case, it's clear this dependency bumps MSRV in
minor releases, so we should use tilde requirements for it.
2022-02-15 23:37:52 +00:00
Jack Grigg f822d7aabc Bump MSRV to 1.54.0
This is the MSRV for the orchard crate version that contains the changes
to the Orchard circuit.

Closes zcash/librustzcash#513.
2022-02-15 16:39:29 +00:00
Kris Nuttycombe e20de50b84 Make AccountId internal representation private. 2022-02-10 11:30:02 -07:00
Kris Nuttycombe a304c3953b Fix Clippy beta linting complaints. 2022-02-02 16:02:45 -07:00
Kris Nuttycombe 3699a6df97 Fix typos. 2022-02-02 14:00:05 -07:00
Kris Nuttycombe cdd899dda1 Fix documentation.
Co-authored-by: str4d <jack@electriccoin.co>
2022-02-02 12:53:59 -07:00
Kris Nuttycombe 6b189f18ff Correct the changelog relating to `store_decrypted_tx` 2022-02-02 10:33:44 -07:00
Kris Nuttycombe 9c2d485c80 Address comments from code review.
Co-authored-by: str4d <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-02-02 10:33:41 -07:00
Kris Nuttycombe 2dd0348792 Remove the `nullifiers` argument from `store_decrypted_tx`
This value can be obtained internally within the implementation
of `store_decrypted_tx` and does not need to be part of the
public API.
2022-02-02 10:32:35 -07:00
Kris Nuttycombe 41810e5be9 Merge remote-tracking branch 'upstream/non-consensus-changes-on-branchid-37519621' into autoshield-poc-daa 2022-02-02 10:32:35 -07:00
Kris Nuttycombe 3d51c53d68 Address comments from code review.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-02-02 10:32:33 -07:00
Kris Nuttycombe d0e1f98429 Use extension traits for transparent-related data api functionality. 2022-02-02 10:30:43 -07:00
Kris Nuttycombe e8e5d94ea6 Mark functions that will be made crate-private as deprecated 2022-02-02 10:29:19 -07:00
Jack Grigg e9ecb19143 Restrict cargo to `protobuf >=2.20,<2.26`
`protobuf 2.26.0` bumped its MSRV to 1.52.1, which is incompatible with
our current MSRV.
2022-02-01 14:26:47 +00:00
Kris Nuttycombe 2f1d3da26d Update changelogs. 2022-01-27 16:25:01 -07:00
Kris Nuttycombe 6e11f2d11a Validate ZIP 321 request by roundtrip through the URI format.
Co-authored-by: str4d <jack@electriccoin.co>
2022-01-27 16:08:04 -07:00
Kris Nuttycombe a1e693d15f Remove the Wif type; it should not be used.
We should attempt to avoid passing spending keys back and forth
across the FFI entirely, but in any case this is no longer the
correct type to use at this boundary; we should use the encoding
of the transparent component of a unified spending key instead.
2022-01-27 16:08:04 -07:00
Kris Nuttycombe 3a20176092 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2022-01-27 15:00:37 -07:00
Kris Nuttycombe 6fcdfda69e Derive OVKs from transparent account-level key, not child keys.
This also renames a number of legacy key types to better reflect
their intended use.
2022-01-26 13:36:27 -07:00
Kris Nuttycombe 0b43535203 Move OutgoingViewingKey to zcash_primitives::keys 2022-01-25 08:53:51 -07:00
Kris Nuttycombe f58d191439 Move transparent account keys to zcash_primitives. 2022-01-25 08:53:51 -07:00
Kris Nuttycombe 4dac37ffde Ensure that transparent input functionality is correctly feature-flagged. 2022-01-22 22:33:22 -07:00
therealyingtong c9fe8402e2 Use transparent internal ovk in shield_transparent_funds(). 2022-01-22 22:29:45 -07:00
therealyingtong a4c9f53a3a Move ExternalPrivKey, ExternalPubKey to zcash_primitives. 2022-01-22 22:29:45 -07:00
Kris Nuttycombe 15eb5aab50 Fix a minor naming error in AccountPubKey 2022-01-21 19:08:26 -07:00
Kris Nuttycombe 7d873e9d79 Fix test compilation errors related to UFVK construction. 2022-01-21 19:01:32 -07:00
Kris Nuttycombe 574ca4e180 Add accessors to UnifiedSpendingKey 2022-01-21 18:20:12 -07:00
Kris Nuttycombe 281a4d5c16 Add accessors for the ExtendedPrivKey wrapped by AccountPrivKey 2022-01-21 18:07:23 -07:00
Kris Nuttycombe 00aee09662 Add accessors for the ExtendedPubKey wrapped by AccountPubKey 2022-01-21 14:02:51 -07:00
Kris Nuttycombe dec395a5b0 Add unified spending keys. 2022-01-21 13:54:23 -07:00
Kris Nuttycombe 8f408354b9 Remove cyclic dev dependency between zcash_client_backend and zcash_client_sqlite. 2022-01-20 21:50:26 -07:00
Kris Nuttycombe 79bd2f7733 Add missing documentation & rustfmt. 2022-01-20 20:14:44 -07:00
Kris Nuttycombe ffc4d0cefb Add newtypes for transparent keys at the account & external levels.
This updates UnifiedFullViewingKey to conform to ZIP 316, and
adds types that facilitate this support. These types should likely
be factored out from `zcash_client_backend` into `zcash_primitives`
along with the remainder of the existing unified address support.
2022-01-20 20:03:20 -07:00
Kris Nuttycombe 37e6d3a2bc Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: ying tong <yingtong@z.cash>
2022-01-20 16:43:57 -07:00
Kris Nuttycombe 3dd1f310d9 Merge remote-tracking branch 'upstream/non-consensus-changes-on-branchid-37519621' into autoshield-poc-daa 2022-01-20 13:54:38 -07:00
Jack Grigg 142a38e792 zcash_note_encryption 0.1.0 2021-12-17 20:00:46 +00:00
Jack Grigg e148ca84ba Migrate to latest `zcash_note_encryption` API 2021-12-17 05:34:45 +00:00
Kris Nuttycombe fc0dd8e3eb Merge remote-tracking branch 'upstream/master' into autoshield-poc-daa 2021-10-25 13:24:03 -06:00
Kris Nuttycombe 120cc70a6d Fix type of default_address 2021-10-11 16:34:37 -06:00
Kris Nuttycombe 1373221439 Renames the `ExtendedFullViewingKey::address` method to `find_address`.
This also adds a new semantically different `address` method which
attempts to produce an address given the specified diversifier index,
and returns `None` if that index does not produce a valid diversifier.

It is then up to the caller to search the diversifier index space if
the diversifier index that they are attempting to use does not result in
a valid diversifier.
2021-10-11 16:34:37 -06:00
Kris Nuttycombe cc58a21ad7 Feature-flag transparent functionality in zcash_client_sqlite
This fixes the wasm32-wasi build issues by excluding the
hdwallet dependencies which are not wasm32-wasi compatible.
2021-10-04 16:53:55 -06:00
Kris Nuttycombe 86da9434ad Fix zcash_client_backend doctest 2021-10-04 09:12:28 -06:00
Kris Nuttycombe 74b0c50294 Fix transitivity of the test-dependencies feature. 2021-10-01 15:20:01 -06:00
Kris Nuttycombe da3c84ff31 Update hdwallet to depend upon secp256k1-v0.20 2021-10-01 12:52:19 -06:00
Kris Nuttycombe e30c5cd628 Enforce maximum zip321 payment count in TransactionRequest constructor. 2021-10-01 12:22:59 -06:00
Kris Nuttycombe d43a893c72 Apply suggestions from code review & update changelog
Co-authored-by: str4d <jack@electriccoin.co>
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2021-10-01 12:03:06 -06:00
Kris Nuttycombe d49a20e6d2 Modify WalletTransparentOutput to wrap TxOut directly. 2021-10-01 11:42:04 -06:00
Kris Nuttycombe 6cf0749ac9 Merge remote-tracking branch 'upstream/master' into autoshield-poc-reorder 2021-10-01 11:03:41 -06:00
Kris Nuttycombe db89569b90 Address documentation & naming requests from code review. 2021-10-01 11:03:09 -06:00
Kris Nuttycombe 2053d7f57b Always take number of confirmations as a parameter. 2021-10-01 11:00:50 -06:00
Jack Grigg 65e1d32774 ff 0.11, group 0.11, etc. 2021-09-09 18:20:37 +01:00
Kris Nuttycombe edd7471d90 Merge remote-tracking branch 'upstream/master' into autoshield-poc-daa 2021-08-27 11:08:50 -06:00
Jack Grigg ecb82ed813 nom 7 2021-08-23 20:15:51 +01:00
Kris Nuttycombe b783c4d0e7 Merge remote-tracking branch 'upstream/master' into autoshield-poc-daa 2021-08-12 11:21:30 -06:00
Jack Grigg 0facec094f Update changelogs with `EphemeralKeyBytes` changes 2021-08-09 21:45:16 +01:00
Jack Grigg 279a8b6bb6 Use `EphemeralKeyBytes` type in place of `[u8; 32]` 2021-08-09 21:28:42 +01:00
Jack Grigg 83c6a2d1ca Store OutputDescription `ephemeral_key` as bytes
This removes an unnecessary `to_bytes` during trial decryption of notes,
and more closely matches the protocol spec. We retain the consensus rule
canonicity check on epk due to `SaplingVerificationContext::check_output`
taking a `jubjub::ExtendedPoint`, forcing `zcashd` to parse the bytes.
2021-08-06 16:54:48 +01:00
Jack Grigg 0f15743200 Disable default benchmark harness for all workspace crates
This is necessary in order to provide criterion-specific arguments to
`cargo bench`, such as `--profile-time`.
2021-08-05 22:39:36 +01:00
Kris Nuttycombe 1a5aad723b Use generalized signature_hash for transaction builder. 2021-06-04 15:45:39 -06:00
Kris Nuttycombe 55d1090f70 Add v5 txid & signature hashing. 2021-06-04 15:45:39 -06:00
Jack Grigg 1222391dd7 Migrate to bitvec 0.22, ff 0.10, etc.
Requires patching three dependencies:

- bellman is pending a new release.
- nom is part of the funty breakage; we are blocking on a new release.
- orchard is in development.
2021-06-04 22:02:48 +01:00
Kris Nuttycombe 523424e50b Move Transparent components to a bundle within TransactionData 2021-06-03 18:46:38 -06:00
Kris Nuttycombe 84e8952ec3 Move Sapling components to a bundle within TransactionData 2021-06-03 18:46:38 -06:00
Kris Nuttycombe 72ac97a35f Derive transaction version & branch id from target height. 2021-06-02 13:45:29 -06:00
Kris Nuttycombe 8267d06846 Refactor transaction builder to create separate builders for each section. 2021-06-02 11:48:46 -06:00
Kris Nuttycombe 76999eb5c7 Make txid contents private & use txid for TzeOutPoint 2021-06-01 07:03:31 -06:00
Kris Nuttycombe 4efb21d1c7 Make amount addition and subtraction traits use checked operations. 2021-06-01 07:03:31 -06:00
Jack Grigg 5623e02a7c Migrate to ff 0.9 et al. 2021-05-19 18:29:37 +01:00
Kris Nuttycombe fd47ee3652 Fix missing method in in-memory wallet prototype. 2021-05-14 15:09:36 -06:00
Kris Nuttycombe 8e3e7de50c Minor code cleanup. 2021-05-14 14:17:42 -06:00
Kevin Gorham c1bc06964f Add get_all_nullifiers. 2021-04-16 14:27:18 -06:00
Kevin Gorham bb68744df1 Ensure that rewinds go far enough to properly restore incremental witness state. 2021-04-16 14:27:18 -06:00
Kris Nuttycombe 9b3025de4d Add ZIP-321 request based sends to zcash_client_backend. 2021-04-16 14:26:53 -06:00
Kevin Gorham 8e16d93f94 Update accounts table create statement.
This PR makes the opinionated change that T-addrs are required
to be supported when using the zcash_client_sqlite backend.
2021-04-16 14:26:53 -06:00
Kevin Gorham 5595ca225c Add public key derivations and related tests. 2021-04-16 14:26:53 -06:00
Kris Nuttycombe 665c4c7aff Figure out the account ID for z->t spends. 2021-04-16 14:26:53 -06:00
Kris Nuttycombe 13cd7498b7 Store vout as part of store_decrypted_tx 2021-04-16 14:26:53 -06:00
Kris Nuttycombe 8828276361 Query for unspent utxos checks to ensure that spending tx is mined.
Also make it an error to try to send a memo to a transparent address.
2021-04-16 14:26:51 -06:00
Kris Nuttycombe b88ee47e36 Add confirmation depth to shield_funds 2021-04-16 14:23:28 -06:00
Kris Nuttycombe a3bc1e3e63 Rename get_spendable -> get_unspent 2021-04-16 14:23:28 -06:00
Kris Nuttycombe ca3e3a4595 Add WIF derivation for transparent keys.
With @gmale
2021-04-16 14:23:28 -06:00
Kris Nuttycombe 862e221a9b Put transparent dependencies behind a feature flag. 2021-04-16 14:23:26 -06:00
Francisco Gindre cff457ff15 PoC Auto-Shielding
Add retrieval of transparent UTXOs to WalletRead

Co-authored-by: Kris Nuttycombe <kris@electriccoin.co>
Co-authored-by: Kevin Gorham <anothergmale@gmail.com>
2021-04-16 14:22:16 -06:00
Kris Nuttycombe 12cb8265d8 Fix formatting. 2021-04-12 18:47:45 -06:00
Kris Nuttycombe fae1a1517a Simplify try_sapling_output_recovery. 2021-04-12 18:40:17 -06:00
Kris Nuttycombe 324fc36521 Use ShieldedOutput trait for note encryption/decryption.
This change modifies note encryption and decryption functions
to treat a shielded output as a single value instead of handling
the parts of an output as independent arguments.
2021-04-12 12:59:06 -06:00
Kris Nuttycombe cfdbafe2e3 Add myself to crate contributors. 2021-04-08 10:13:04 -06:00
Kris Nuttycombe e77839232d Generalize note encryption and decryption.
This commit introduces a `Domain` trait which defines the types
and operations that are shared between Sapling and Orchard note
encryption and decryption processes.
2021-04-08 08:19:10 -06:00
Kris Nuttycombe 5baccdf052 Move note_encryption into the sapling module. 2021-04-08 08:19:10 -06:00
Jack Grigg 63db2729e9 Temporarily allow clippy::result_unit_err lint
Fixing these lints is deferred to zcash/librustzcash#367.
2021-03-27 19:01:03 +13:00
Jack Grigg 56b577b31e clippy: Fix small lints 2021-03-27 19:01:03 +13:00
Jack Grigg 636845d0f9 Renames to use lower-case abbreviations (matching Rust convention)
As of our MSRV bump to 1.51.0, we get lints for this.
2021-03-27 19:01:03 +13:00
Jack Grigg 8ac663f116 Fix some doctests and intra-doc links after moving Sapling primitives 2021-03-27 17:10:18 +13:00
Kris Nuttycombe 33effb7d67 Move sapling keys into sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe 4086df772c Move sapling-specific primitives into the sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe 88d58aac0a Move relevant utils into sapling module. 2021-03-27 16:18:21 +13:00
Kris Nuttycombe 16948d9d78 Move zcash_primitives::prover to sapling module 2021-03-27 16:18:21 +13:00
Jack Grigg 38f7a0330c Fix various clippy lints
The remainder will be fixed after the refactor PRs are merged.
2021-03-27 08:50:40 +13:00
Jack Grigg 9d9c0579f8 Use new name for broken_intra_doc_links lint
We also add the lint to crates in the workspace that didn't have it.

Closes zcash/librustzcash#279.
2021-03-27 08:27:17 +13:00
Jack Grigg afa0b29e62 Bump MSRV to 1.51.0
This is the MSRV for the orchard crate, which we will be depending on
soon.
2021-03-27 08:21:45 +13:00
Jack Grigg 4ff0a81a7f zcash_client_sqlite 0.3.0 2021-03-26 19:01:04 +13:00
Jack Grigg acc650cc17 zcash_client_backend 0.5.0 2021-03-26 18:54:42 +13:00
Jack Grigg 813525f0b5 zcash_proofs 0.5.0 2021-03-26 18:53:42 +13:00
Jack Grigg 725699c76b zcash_primitives 0.5.0 2021-03-26 18:51:35 +13:00
Kris Nuttycombe f30502c5a2
Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-03-25 21:24:24 -06:00
str4d dd15e5f431
Add missing doc link 2021-03-26 15:10:39 +13:00
Kris Nuttycombe fc3aa233e8 Update ZIP 321 parsing to use the MemoBytes type. 2021-03-26 14:47:15 +13:00
str4d d73483f5da
Minor fixes to documentation 2021-03-26 14:18:01 +13:00
Jack Grigg c3c7bd1d9c bech32 0.8 2021-03-26 13:31:20 +13:00
Kris Nuttycombe a0c441817a Documentation fixes in zcash_client_backend. 2021-03-25 18:26:57 -06:00
Jack Grigg 675048e52b Fix broken intra-doc links and lints 2021-03-26 10:07:20 +13:00
str4d 5e0e44a388
Merge pull request #354 from nuttycom/changelog/346_sapling_ivk
Add SaplingIvk newtype to changelogs.
2021-03-26 10:07:01 +13:00
str4d 1bea40de88
zcash_client_backend: Add ScanningKey trait to changelog 2021-03-26 10:06:30 +13:00
Kris Nuttycombe c41c71c514
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2021-03-25 15:00:54 -06:00
Kris Nuttycombe 42f15a575e
Merge pull request #359 from str4d/356-create_spend_to_address-assumption
zcash_client_backend: Use correct output index for t-addr recipients
2021-03-25 07:58:53 -06:00
Kris Nuttycombe 9b1156bf49 Fix rustfmt complaint. 2021-03-25 07:40:02 -06:00
Jack Grigg 678f1b6734 zcash_client_backend: Make transparent output indexing resilient
It's cheap to scan all transparent outputs to find the output matching
a transparent recipient.
2021-03-25 21:53:47 +13:00
Jack Grigg 6f93530554 zcash_client_backend: Remove unnecessary type conversion 2021-03-25 21:45:40 +13:00
Kris Nuttycombe ebdd6cf976 Add SaplingIvk newtype to changelogs. 2021-03-24 18:39:21 -06:00
Jack Grigg cb6a993840 zcash_client_backend: Use correct output index for t-addr recipients
`create_spend_to_address` was originally written only for sending to
Sapling addresses. It was later amended to support sending to
transparent addresses, but the assumption about there being a Sapling
output was not removed. This was not an issue for most transactions
because there would be change, but in the case of a z->t transaction
with no change, `create_spend_to_address` would reliably panic.

This commit fixes the bug by setting the output index for transparent
recipients to 0. The `output_index` field of `SentTransaction` is also
documented to correctly reflect its dependency on the type of
`recipient_address`.
2021-03-24 19:01:35 +13:00
Jack Grigg 46872e2590 Update changelogs with Memo changes 2021-03-18 10:00:27 +13:00
Jack Grigg 8a84203685 Remove Default impl from MemoBytes
Memo fields have two ways to encode an empty memo:

- 0xF6 followed by all-zeroes, encoding "there is no memo".
- All-zeroes, encoding the empty UTF-8 string.

In almost all cases you want the former, but users thinking about byte
slices may expect MemoBytes::default() to result in the latter. To
ensure clarity, we now require calling either MemoBytes::default() or
MemoBytes::from_bytes(&[]) to be explicit.

No such confusion exists for the Memo enum, because the two types are
visibly separated as different enum cases, and Memo::Empty makes sense
as the default.
2021-03-17 21:16:01 +13:00
Jack Grigg c7a3ef0e88 Split memo-handling into MemoBytes struct and Memo enum
The MemoBytes struct is a minimal wrapper around the memo bytes, and only
imposes the existence of null-padding for shorter memos. The only error
case is attempting to construct a memo that is too long. MemoBytes is
guaranteed to be round-trip encodable (modulo null padding).

The Memo enum implements the additional memo rules defined in ZIP 302,
interpreting the contents of a memo (for example, parsing it as text).
2021-03-17 21:05:50 +13:00
Jack Grigg 48f7ef84a4 Move Memo into zcash_primitives::memo 2021-03-17 19:58:40 +13:00
Kris Nuttycombe 2b4951759c Fix welding rig intra-doc links. 2021-03-15 17:59:23 -06:00
Kris Nuttycombe 5a9b29a75a Address comments from code review. 2021-03-11 13:01:22 -07:00
Kris Nuttycombe 0e022f2283 Allow block scanning using either IVKs or FVKs. 2021-03-09 21:00:40 -07:00
Kris Nuttycombe 16289750e8 Remove WalletWrite::transactionally 2021-03-09 20:59:57 -07:00
Kris Nuttycombe a74cc8b231 Remove sqlite-specific data organization from data access api. 2021-03-09 20:59:57 -07:00
Kris Nuttycombe b5bbbb6f5a Factor out nullifier update from database actions in scan_cached_blocks 2021-03-09 20:59:57 -07:00
Jack Grigg 463e252af4 Fix more intra-doc links 2021-03-04 23:01:42 +00:00
Jack Grigg 464b533937 Bump MSRV to 1.47.0
We'll be needing it shortly for ff et al.
2021-03-04 17:32:57 +00:00
Jack Grigg 5431e1ef6b nom 6.1 2021-03-04 17:03:41 +00:00
Jack Grigg 5242718b8f bs58 0.4 2021-03-04 17:03:14 +00:00
Jack Grigg d510eb50fd base64 0.13 2021-03-04 17:02:34 +00:00
str4d 36e4b0d51a
Merge pull request #329 from nuttycom/ivk_payment_addresses
Introduce SaplingIvk newtype & use IVKs where possible.
2021-03-04 07:04:05 +13:00
Jack Grigg 1f6f45bbe7 Add details of unreleased changes to changelogs 2021-02-22 16:59:07 +00:00
str4d 9f14c757e6
Merge pull request #340 from str4d/changelogs
Add changelogs to the crates
2021-02-14 02:34:20 +13:00
Kris Nuttycombe f0f4f58b2b Fix generation of zip321 URIs for proptest to avoid generating invalid ones. 2021-02-04 08:32:00 -07:00
Jack Grigg bd3e18984c Changelogs: s/project/library 2021-02-04 15:16:32 +00:00
Jack Grigg b5c7d7f1e7 Add changelogs to the crates
The changelogs are accurate for the 0.4.0 release tag, but don't yet
include changes before or after that tag.
2021-02-04 15:13:22 +00:00
Kris Nuttycombe 1cc7949518 Rename CommitmentTree::new -> CommitmentTree::empty 2021-02-04 07:49:48 -07:00
Kris Nuttycombe 98530184c0 Fix clippy complaints. 2021-02-03 14:27:31 -07:00
Kris Nuttycombe 7a57aee530 Introduce SaplingIvk newtype & use IVKs where possible.
This includes making it possible to obtain a payment address from just the IVK + diversifier.
2021-02-02 15:27:13 -07:00
Kris Nuttycombe 5cb48fa962 Fix documentation of get_received_note 2021-02-02 13:16:16 -07:00
Kris Nuttycombe df09877b11 Use an enum to distinguish between sent and received notes in sqlite backend. 2021-01-20 10:51:27 -07:00
Kris Nuttycombe 7f43b05e21 Update protobuf dependency version. 2021-01-19 13:01:51 -07:00
Kris Nuttycombe 779a5670e0 Improve data access api method documentation. 2021-01-19 12:45:55 -07:00
Kris Nuttycombe f8ce44ff0b Add convenience method for CompactSpend -> Nullifier. 2021-01-19 10:09:36 -07:00
Kris Nuttycombe 8fe6f0fdfd Remove default get_balance method.
Recommended by @str4d
2021-01-19 08:25:10 -07:00
Kris Nuttycombe 8e8ed2bb4f Rename get_verified_balance -> get_balance_at 2021-01-15 12:00:14 -07:00
Kris Nuttycombe c70a9ed81f Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: str4d <thestr4d@gmail.com>
2021-01-15 11:57:58 -07:00
Kris Nuttycombe f59124ce19 Pass account ID with IVK. 2021-01-15 10:18:43 -07:00
Kris Nuttycombe 120ee25e1d Fix argument to decrypt_and_store_transaction 2021-01-15 10:02:24 -07:00
Kris Nuttycombe da8b7bdb8f Work around doctest sqlite IO errors. 2021-01-13 16:14:26 -07:00
Kris Nuttycombe a3f9fa788d Update data_api doctests for error handling changes. 2021-01-13 15:43:39 -07:00
Kris Nuttycombe 5a21580f13 Correct the hierarchy of errors. 2021-01-13 15:20:11 -07:00
Kris Nuttycombe aa72e070ce Fix MockWalletDB 2021-01-12 21:51:08 -07:00
Kris Nuttycombe 6c6b05fa9b Trivial rename. 2021-01-12 21:32:46 -07:00
Kris Nuttycombe 1a0301d122
Update zcash_client_backend/src/data_api/chain.rs
Co-authored-by: str4d <thestr4d@gmail.com>
2021-01-12 21:14:40 -07:00
Kris Nuttycombe 37b82e1c3b
Update zcash_client_backend/src/data_api.rs 2021-01-12 21:12:28 -07:00
Kris Nuttycombe ce06db197a Rustfmt. 2021-01-12 21:10:34 -07:00
Kris Nuttycombe db9eb29eba Merge remote-tracking branch 'upstream/master' into data_access_api 2021-01-12 21:09:40 -07:00
Kris Nuttycombe fd3468b4f5 Remove unnecessary map_err's 2021-01-12 20:53:09 -07:00
Kris Nuttycombe 011eda364f Add get_spendable_notes method to WalletRead 2021-01-12 20:42:04 -07:00
Kris Nuttycombe 48f226f8b5 Move decoding errors to sqlite crate.
Also move dependency on params out of wallet read/write methods.
The result is cleaner because these parameters are only required
for backend-specific encoding and decoding operations.
2021-01-12 20:07:02 -07:00
Kris Nuttycombe 5927e32059 Document error types. 2021-01-12 14:59:42 -07:00
Kris Nuttycombe ca4567b275 More data api documentation. 2021-01-12 13:55:22 -07:00
Kris Nuttycombe 34bc655f64 Add MockBlockSource and MockWalletDB
These can readily be made into an in-memory wallet implementation.
2021-01-12 12:55:24 -07:00
Jack Grigg 10f5dddb79 zcash_client_backend: Fix testnet bug in diversify-address example
I misunderstood the meanings of Err(_) vs Ok(None), which indicates that
we need to refactor this API! In the meantime, this enables the example
to work with testnet Sapling viewing keys.
2021-01-12 12:59:04 +00:00
Kris Nuttycombe 7d92150965 Fix test compilation with WalletWrite changes. 2021-01-11 18:13:40 -07:00
Kris Nuttycombe aad2e174c1 Consistently use nullifier and AccountId newtypes. 2021-01-08 21:49:38 -07:00
Kris Nuttycombe 27d7b6c569 A few doc updates. 2021-01-08 18:08:02 -07:00
Kris Nuttycombe 56adbbb545 Make `WalletWrite` depend upon `WalletRead`. 2021-01-08 12:49:10 -07:00
Jack Grigg 258e3d31ad zcash_client_backend: Add example to generate diversified addresses 2021-01-08 16:08:03 +00:00
Kris Nuttycombe 7ac08631b9 Fix doctest imports. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 1fd74d0a71 Improve naming for wallet/block database connections. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 897a70dd9e Simplify block source & clean up chain validation. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 8a215d67fe Improve wallet "database" trait names. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe b2cc240454 Do not require wallet database for chain scan. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe e6de7c07f0 Use <module_name>.rs instead of <module_name>/mod.rs 2020-12-02 09:46:17 -07:00
Kris Nuttycombe f742895118 Fix test/doctest errors. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe c60b9d3ece Remove database initialization calls from common API. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 4c2cda48e6 Clean up transactional API.
This API is still somewhat unsafe in that it doesn't inhibit nested
transactions, but it's better than it was.
2020-12-02 09:46:17 -07:00
Kris Nuttycombe cd2729bbd0 Move 'create_spend_to_address' to wallet backend.
This required changing a bit about the relationship between
database errors and wallet errors, and opens up the possibility
of now simplifying the error situation a bit.
2020-12-02 09:46:17 -07:00
Kris Nuttycombe e144015558 Reuse sent note insertion for wallet/transact. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 68737dd1dd Remove duplicate method. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe eab2951c99 Move decrypt_and_store_transaction to zcash_client_backend 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 0165ae7003 Minor renamings. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 746c4c9a00 Move scan_cached_blocks out of sqlite crate. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe d16c124ffe Abstract over data access in scan_cached_blocks. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 06c1772692 Move traversal of cached blocks to CacheOps 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 604294dd9f Factor out nullifier retrieval into data api. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe ffd503134d Factor out witness retrieval from scan. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 499dcd2e6c Add the remainder of sqlite/query.rs functions to the data API. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 56e6091876 Factor out `get_commitment_tree` from scan. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe d16c74725e Extract get_extended_full_viewing_keys function.
This required a bit of generalization of the data_api error types.
2020-12-02 09:46:17 -07:00
Kris Nuttycombe 3eec6f8faa Add get_balance, get_verified_balance to data api. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 70de11dd32 Add address retrieval. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe b72251ee28 Add accounts table initialization. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 724fbac33a Add database initialization implementation. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe f3f3512068 Move get_target_and_anchor_heights to data_api. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe 9874abfd6c Implement chain validation & fix doctests. 2020-12-02 09:46:17 -07:00
Kris Nuttycombe a437df191e Initial skeleton of low-level database access API. 2020-12-02 09:46:17 -07:00
Jack Grigg 0bbcd8c408 Remove unnecessary imports 2020-10-30 13:22:46 +00:00
Kris Nuttycombe b1c3f9d3f0
ZIP 321 Reference Implementation (#294)
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2020-10-15 14:03:40 +01:00
Kris Nuttycombe a0a36eddfd Merge remote-tracking branch 'upstream/master' into zip-tzes
Fix benchmark build issues.
2020-09-21 16:43:33 -06:00
Kris Nuttycombe ab2d5bf603 Merge remote-tracking branch 'upstream/master' into zip-tzes 2020-09-21 10:08:05 -06:00
str4d e0587e752b
Merge pull request #290 from str4d/273-remove-decryption-epk-subgroup-check
Take epk as a jubjub::ExtendedPoint for note decryption
2020-09-22 03:05:35 +12:00
Kris Nuttycombe c7c39964ec Use block.height() method instead of .into() 2020-09-18 10:55:29 -06:00
Kris Nuttycombe 90d8980162
Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2020-09-18 10:39:37 -06:00
Kris Nuttycombe 1ad9294933 Remove static determination of network state.
In the interest of making the library usable for both
testnet and mainnet without recompilation, static resolution
of network parameters has been replaced with a parameter passed
to the relevant functions. This also moves addres prefix constants
into the network parameters.
2020-09-17 10:34:42 -06:00
Kris Nuttycombe efaba87681 Add newtype for block height. 2020-09-17 10:26:41 -06:00