Commit Graph

298 Commits

Author SHA1 Message Date
Kris Nuttycombe 69953ccd88 zcash_client_backend: Make `AccountId` an associated type of the `Account` trait. 2024-09-04 15:51:08 -06:00
Kris Nuttycombe d9fa772665 release zcash_client_backend version 0.13.0 2024-08-20 08:00:05 -06:00
Kris Nuttycombe ac7cbf9a41 zcash_client_backend: Add a `purpose` modifier for imported accounts.
This moves the tracking of whether or not a spending key is expected to
be available for an imported account into the `AccountSource::Imported`
variant.
2024-08-09 18:38:39 -06:00
Kris Nuttycombe 8752ad7e19 zcash_client_backend: Add `target_height` to `SentTransaction` 2024-08-09 14:09:51 -06:00
Kris Nuttycombe 3da29d2506 zcash_client_backend: Add transaction data requests.
This adds a mechanism that can be used by the backend to request
additional transaction data or status information from the client,
for the purpose of being to explore transparent transaction history
that is otherwise currently unavailable.
2024-08-06 12:25:44 -06:00
Kris Nuttycombe 18207883ea zcash_client_backend: Add `block_height` argument to `decrypt_and_store_transaction`
In the case that `decrypt_and_store_transaction` is being used to add
data for fully-transparent transactions to the database, it may be the
case that there is no existing relationship between a transaction and
the block height at which it was mined (unlike for transactions being
enhanced after discovery via block scanning.) This change makes it
possible to set the mined height for transactions that do not have any
shielded components that involve the wallet.
2024-08-06 12:25:44 -06:00
Daira-Emma Hopwood f54ecbd285 Use a single database transaction when storing transactions to be sent.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-07-29 18:57:31 +01:00
Jack Grigg 4f95bd22d4
Merge pull request #1462 from nuttycom/1434-store_decrypted_tx
zcash_client_sqlite: Store received UTXOs in `store_decrypted_tx`
2024-07-26 23:11:47 +01:00
Kris Nuttycombe 3cec9ee4a7 zcash_client_sqlite: Store received UTXOs in `store_decrypted_tx`.
This fixes an issue wherein transparent outputs of transactions added to
the wallet via `decrypt_and_store_transaction` would not be properly
recorded as UTXOs belonging to the wallet.

Part of #1434
2024-07-26 15:47:16 -06:00
Kris Nuttycombe 5ad3205e58 zcash_client_sqlite: Demonstrate the failure of store_decrypted_tx to persist transparent outputs.
Related to #1434
2024-07-26 15:46:57 -06:00
Kris Nuttycombe e555854f87 Merge remote-tracking branch 'upstream/main' into ufvk_import_support 2024-07-25 16:31:34 -06:00
Andrew Arnott 664526f74a
Fixes for nearly all PR comments 2024-07-23 19:47:37 -06:00
Andrew Arnott 2ee56f77f2
Merge remote-tracking branch 'upstream/main' into ufvk_import_support 2024-07-17 23:31:08 -06:00
Jack Grigg 1e5b62bfce zcash_client_backend: Add a Tor client using the Arti library 2024-07-18 01:25:17 +00:00
Jack Grigg eaa43b4e25
Merge pull request #1257 from daira/implement-transparent-source-only
Add support for transparent-source-only (TEX) addresses
2024-07-17 19:27:36 +01:00
Kris Nuttycombe aa4312326d Use `EphemeralBalance` instead of `EphemeralParameters`
The `EphemeralParameters` type makes too many states representable, in
particular, it represents that it is possible for a proposal step to
have both ephemeral inputs and ephemeral outputs. This change reduces
the representable state space to make it so that only one or the other
is true, and also makes clear that the change memo must be attached to
the change output of the intermediate step, and not to the ultimate
output to the final recipient (where we expect there to be no shielded
change, and therefore it is not possible to attach a memo.)
2024-07-16 13:53:31 -06:00
Jack Grigg 270eec2574 CI: Don't test `zcash_client_backend/lightwalletd-tonic` on WASM
Broken until hyperium/tonic#1783 is addressed.
2024-07-11 18:09:49 -07:00
Jack Grigg e5517b61cc zcash_client_backend: Migrate to `tonic 0.12` with `http 1` 2024-07-11 22:23:55 +00:00
Daira-Emma Hopwood e97da43409 Refactoring to address review comments.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-07-04 05:24:32 +01:00
Daira-Emma Hopwood b63ff5bfcd Rename `get_reserved_ephemeral_addresses` to `get_known_ephemeral_addresses`
and change the `TransparentAddressMetadata` in its result map to not be
optional.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-07-04 05:24:32 +01:00
Daira-Emma Hopwood 01ff201ffb Minor changes responding to review comments.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-07-04 05:24:32 +01:00
Daira-Emma Hopwood 7838c048a2 Make `ephemeral_parameters` and `EphemeralParameters::NONE` available
unconditionally.

This removes a bunch of `#[cfg(feature = "transparent-inputs")]`
conditionals, with negligible (if any, after compiler optimization)
overhead. It also requires callers of functions with an
`ephemeral_parameters` parameter to do the intended thing to work
with "transparent-inputs" either enabled or disabled.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-29 12:22:44 +01:00
Daira-Emma Hopwood 286439aa96 Define a constant `EphemeralParameters::NONE` instead of deriving `Default`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-29 01:33:50 +01:00
Daira-Emma Hopwood d32b7dbd8f Remove `ChangeValue::new`. Also document `ChangeValue::is_ephemeral` as
an addition in the changelog.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 21:49:51 +01:00
Daira-Emma Hopwood b77813933a Refactor ephemeral output-related parameters to balance calculation.
This now only supports a single ephemeral input and/or output when
constructing a proposal (multiple ephemeral outputs are still supported
when creating transactions).

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:45:45 +01:00
Daira-Emma Hopwood ffb2ddf594 `zcash_client_backend::fees::ChangeValue` is now an enum, allowing only
valid combinations of output pool, memo presence, and ephemerality.

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:45:45 +01:00
Daira-Emma Hopwood bd6c9f3599 Apply documentation suggestions from code review.
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:43:09 +01:00
Daira-Emma Hopwood 4f43a01f83 Refactor transparent address metadata lookups. This is correct as-is but
will be simplified and made more efficient in subsequent commmits.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:43:09 +01:00
Daira-Emma Hopwood 2f521d7873 If a change memo is supplied, it should not be used in the second step
of a ZIP 320 proposal.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood c6520cf6a6 Change the protobuf schema to explicitly specify whether a `ChangeValue`
is ephemeral.

This also fixes `try_into_standard_proposal` to allow decoding from the
protobuf representation into a proposal that uses references to prior
ephemeral transparent outputs, provided that the "transparent-inputs"
feature is enabled.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 0f3de63ae1 Apply documentation suggestions from code review.
Co-authored-by: str4d <thestr4d@gmail.com>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 2fae4bb244 ZIP 320 implementation.
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Co-authored-by: Jack Grigg <str4d@electriccoin.co>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Kris Nuttycombe 72d8df8e68 zcash_client_sqlite: Align handling of transparent UTXOs with that of shielded notes.
Co-authored-by: Daira-Emma Hopwood <daira@jacaranda.org>
Co-authored-by: Jack Grigg <jack@electriccoin.co>
2024-06-21 19:13:18 -06:00
Daira-Emma Hopwood 21d573122c `zcash_client_backend::{fixed,standard,zip317}::SingleOutputChangeStrategy`
now implement a different strategy for choosing whether there will be any
change, and its value. The aims are:

* Ensure that it is possible to create fully transparent transactions with
  no change (this will be needed for ZIP 320). The `InsufficientFunds`
  error in this case should have a `required` field that reflects the
  additional amount needed, according to the fee calculated without an
  extra change output.
* Avoid leaking information about note amounts in some cases: an adversary
  that knew the number of external recipients and the sum of their outputs
  was able to learn the sum of the inputs if no change output was present.
* Defend against losing money by using `DustAction::AddDustToFee` with a
  too-high dust threshold.
* Ensure that if a "change memo" is requested, there will always be a
  shielded change output in which to put it. Previously, this would not
  be the case when using `DustAction::AddDustToFee`.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-19 13:12:17 +01:00
Daira-Emma Hopwood cefbaf59d5 Add `zcash_client_backend::fees::{sapling,orchard}::EmptyBundleView`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-18 21:03:22 +01:00
Daira-Emma Hopwood 2337f79484 Add `zcash_keys::Address::Tex`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-18 21:03:22 +01:00
Daira-Emma Hopwood c3e532f29b The return type of `ChangeValue::new` is now optional; it returns `None`
if a memo is given for the transparent pool. Use `ChangeValue::shielded`
to avoid this error case when creating a `ChangeValue` known to be for a
shielded pool.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-18 21:03:22 +01:00
Daira-Emma Hopwood 3582f84686 Allow `ChangeValue::output_pool` to reference the transparent pool by
changing its type from `ShieldedProtocol` to `PoolType`.

Also fix compilation errors when the "orchard" feature is used without
the "transparent-inputs" feature.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-18 21:03:22 +01:00
Daira-Emma Hopwood 1d9fede906 Cosmetic fixes to changelog.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-18 21:03:22 +01:00
Andrew Arnott ce40387511
Add `import_account_hd` and `import_account_ufvk` methods 2024-06-17 08:57:39 -06:00
Jack Grigg bffe6a4a10 Bump MSRV to 1.70 2024-06-12 10:58:17 +00:00
str4d 851e20347f
Fix changelogs to reflect actual MSRVs 2024-05-24 15:46:40 +01:00
Daira-Emma Hopwood aa77be8830 Update dependencies (including to avoid a vulnerability warning for atty), bump MSRV to 1.66,
and fix new clippy lints for MSRV 1.66.

* tonic 0.10 -> 0.11
* tonic-build 0.10 -> 0.11
* cargo update
* cargo update -p home@0.5.9 --precise 0.5.5
* cargo update -p prost-build@0.12.4 --precise 0.12.3
* cargo update -p prost-types@0.12.4 --precise 0.12.3
* cargo update -p prost@0.12.4 --precise 0.12.3
* cargo update -p prost-derive@0.12.5 --precise 0.12.3
* cargo update -p half@2.4.1 --precise 2.2.1

(The precise updates avoid a further MSRV bump to 1.70.)

Remaining duplicates are currently unavoidable.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-05-20 13:35:27 +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
Jack Grigg 24277a6ba4 zcash_client_backend: Implement async wallet synchronization function
This implements the necessary state machine for taking a wallet in some
arbitrary synchronization status, and fully scanning (the remainder of)
the chain.

Closes zcash/librustzcash#1169.
2024-04-02 00:26:08 +00:00
oscar-pepper 25b8404e2d
Add block cache trait (#1192) 2024-04-01 21:55:16 +01:00
Kris Nuttycombe 1cb33c8b06 zcash_client_backend release version 0.12.1 2024-03-27 14:58:12 -06:00
Kris Nuttycombe 777adb871d Release zcash_client_backend version 0.12.0
Closes #1079
2024-03-25 14:03:42 -06:00