Commit Graph

97 Commits

Author SHA1 Message Date
Kris Nuttycombe d2aa6cfc7f Apply suggestions from code review
Co-authored-by: str4d <thestr4d@gmail.com>
2024-04-22 14:41:50 -06:00
Kris Nuttycombe aeac544aed Address comments from code review. 2024-04-22 10:55:25 -06:00
Daira-Emma Hopwood ea82dbeb64
Apply straightforward suggestions from code review 2024-04-18 01:12:13 +01:00
Kris Nuttycombe b60600a4c3 zcash_client_sqlite: Use `ZcashAddress` for persistence of sent note addresses
Prior to this change, the recipient of a sent transaction would always
be shown as the protocol-level address, instead of any unified address
intended as the recipient. Now, instead of reencoding the recipient
address, we use the original `ZcashAddress` value from the payment
request.
2024-04-05 16:48:13 -06:00
Kris Nuttycombe 3ea7d84183 zcash_client_backend: Update to use extracted `zip321` crate 2024-04-05 16:25:21 -06:00
Kris Nuttycombe d982d7826a zip321: Replace dependencies on `zcash_keys` types with `zcash_address` 2024-04-05 16:10:22 -06:00
Kris Nuttycombe cef9e7641d `zcash_address`: Add support for ZIP 320, TEX addresses. 2024-03-06 14:59:16 +00:00
Kris Nuttycombe 4b18426fcd zcash_address: Use `zcash_protocol::consensus::NetworkType`
This inverts the dependency relationship between `zcash_protocol` and
`zcash_address`, permitting the network constants (primarily the HRPs)
defined in `zcash_protocol` to be used directly in `zcash_address`
instead of being duplicated.
2024-03-05 13:36:15 -07:00
Jack Grigg 22271145a7 zcash_address: Improve documentation 2024-01-12 04:53:39 +00:00
Jack Grigg 6570116384 zcash_address: Show feature flags in documentation 2024-01-12 02:45:22 +00:00
Jack Grigg 3f006bffac zcash_address: Remove private type aliases for raw data sizes
These served no type safety purpose; they were just to make developing
the crate easier. However, while docs.rs correctly shows these in trait
APIs as their plain `[u8; N]` form, editor LSPs like `rust-analyzer`
assume the crate-private types are public and auto-create stubs that
reference them, which is not good UX for downstream developers.
2024-01-12 00:15:55 +00: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 03c3370de8 Fix problems identified by clippy's beta lints 2022-09-17 08:57:37 -06: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
Jack Grigg b8e8a0c491 zcash_address: Add `ZcashAddress::convert_if_network`
This, along with the corresponding `TryFromRawAddress` trait, enables
converting `ZcashAddress` into a network-agnostic type.

Closes zcash/librustzcash#564.
2022-06-10 15:19:42 +00:00
Jack Grigg 16938d1c4f zcash_address: Replace `FromAddress` with `TryFromAddress`
This enables the user-defined conversions to be fallible, which they
will almost always want to be (as address data needs to be validated
before it can be used).
2022-06-07 18:09:42 +00:00
Kris Nuttycombe 981fc62b08 Add `ZcashAddress::encode` method.
This provides the encoding corresponding to
`ZcashAddress::try_from_encoded` and documents the fact that the
`Display` instance can also provide this encoding.

Fixes #463
2022-04-11 10:36:27 -06:00
Kris Nuttycombe 990b0afe5d Update unified address test vectors 2022-03-29 14:56:00 -06:00
Jack Grigg fa75c9587c zcash_address: Avoid an unnecessary allocation while parsing a UA 2022-02-03 00:02:03 +00:00
Jack Grigg 4a30679491 f4jumble: Return `Error` from allocating functions 2022-02-03 00:02:03 +00:00
Kris Nuttycombe 8d34e62114 Clean up proptest generation for unified containers. 2022-01-04 15:31:20 -07:00
Kris Nuttycombe 6065c07003 Update test vectors to respect item ordering. 2022-01-04 11:48:23 -07:00
Kris Nuttycombe 2fa73ed368 Remove `Ord` instances for sealed items.
There are two canonical orderings for sealed items: preference
order and encoding order. Removing the `Ord` instances means
that a user can't accidentally choose the wrong ordering;
these orderings are replaced by explicit `preference_order`
and `encoding_order` comparison functions.
2022-01-04 11:48:23 -07:00
Kris Nuttycombe e413f12fb5 Apply suggestions from code review
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-01-04 11:48:23 -07:00
Kris Nuttycombe 4c4c0b1e63 Makes unified container parsing enforce typecode order.
Co-authored-by: Daira Hopwood <daira@jacaranda.org>
2022-01-04 11:48:23 -07:00
Kris Nuttycombe fd786f28b7 Ensure unrecognized prefixes map to ParseError::NotZcash 2021-12-07 12:59:41 -07:00
Kris Nuttycombe 4e906508ae Make unified container construction correctly sort items.
Newly constructed unified containers now obey ZIP 316 item
ordering rules, while parsing and reserialization preserve
order.
2021-12-07 11:07:15 -07:00
Kris Nuttycombe cc8c2868eb Ensure that unknown typecodes don't duplicate known typecodes. 2021-12-07 09:16:55 -07:00
Kris Nuttycombe cccc493067 Add unknown typecodes to UA proptests. 2021-12-06 11:34:12 -07:00
Kris Nuttycombe e30f4bd094 Fix incorrect ordering of receivers in writing raw encoding. 2021-12-06 08:32:07 -07:00
Kris Nuttycombe 9144aaef0a Ensure shrinking will work properly for ufvk proptests. 2021-12-03 15:27:25 -07:00
Kris Nuttycombe fd300e0061 Apply suggestions from code review
Co-authored-by: str4d <jack@electriccoin.co>
2021-12-03 14:26:02 -07:00
Kris Nuttycombe a6420858f4 Fix clippy lints. 2021-12-03 14:21:40 -07:00
Kris Nuttycombe 76082e4287 Return correct errors for incorrectly encoded unified containers. 2021-12-03 14:15:02 -07:00
Kris Nuttycombe ba3ff42e13 Address comments from code review. 2021-12-03 12:07:26 -07:00
Kris Nuttycombe 8cf43d255f Fix clippy complaints. 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 914363f9b7 Rename "to_bytes" internal method to "to_jumbled_bytes" 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 2ffe5963a1 Fix the byte length of Sapling and Transparent UFVK components. 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 7e629db29f Adds high-level encoding and decoding functions for unified types.
This renames the `FromReceivers` trait to `UnifiedEncoding` and makes
its public methods (as well as the private to_bytes method) function in
terms of network values rather than explicit HRP arguments. It also adds
high-level encoding and decoding methods that handle conversion to and
from the Bech32m-encoded transport format for all supported types, and
then delegates to these from locations that previously used lower-level
utilities.
2021-12-02 14:44:38 -07:00
Kris Nuttycombe 3b70731cc4 Adds `unified::SealedContainer::network_hrp` 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 7d801cf71b Expose unified addresses, IVKs and Fvks 2021-12-02 14:44:38 -07:00
ying tong c8993881ae kind::unified: Make ivk::Ivk, fvk::Fvk available outside the crate.
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
2021-12-02 14:44:38 -07:00
therealyingtong c4ceb8e9df Test both Sapling and Orchard receivers in arb_shielded_* proptests. 2021-12-02 14:44:38 -07:00
therealyingtong b4c1ca11c9 Remove P2SH variant for FVK and IVK. 2021-12-02 14:44:38 -07:00
therealyingtong cb06bbcf05 unified::fvk::tests: Add unit tests for parsing UFVK. 2021-12-02 14:44:38 -07:00
therealyingtong 194a790335 unified::fvk: Parse unified full viewing keys. 2021-12-02 14:44:38 -07:00
therealyingtong fc82523e31 unified::ivk::tests: Add unit tests for parsing UIVK. 2021-12-02 14:44:38 -07:00
therealyingtong 7cd12f4ee2 unified::ivk: Parse unified incoming viewing keys. 2021-12-02 14:44:38 -07:00
Kris Nuttycombe 566c973ea7
Fix comment in components/zcash_address/src/kind/unified.rs
Co-authored-by: str4d <jack@electriccoin.co>
2021-12-02 11:35:54 -07:00
Kris Nuttycombe 82be04dfaf Generalize the naming of unified containers and items. 2021-12-02 09:10:03 -07:00