Commit Graph

3901 Commits

Author SHA1 Message Date
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 8636daa4f3 Tiny simplification.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-29 12:22:44 +01:00
Daira-Emma Hopwood 14bdcdeaaa We cannot spend prior outputs at all when "transparent-inputs" is not
enabled. (I got this right in a previous commit but broke it when
refactoring the proposal error handling.)

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-29 12:22:44 +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 bc38f2af80 Document the `possible_change` parameter to `check_for_uneconomic_inputs`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-29 01:34:19 +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 3922d71ade Change the type of `n` in `reserve_next_n_ephemeral_addresses` back to `u32`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 20:59:12 +01:00
Daira-Emma Hopwood 25006ab013 Documentation improvement from code review.
Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 20:52:05 +01:00
Daira-Emma Hopwood 38296634d9 Change note selection query to select notes > 5000 zats, not >= 5000 zats.
Also the issue reference was wrong.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 19:03:11 +01:00
Daira-Emma Hopwood 9c082dca3e `zcash_primitives::transaction::fees::zip317::FeeRule::non_standard` has
been deprecated, because in general it can calculate fees that violate
ZIP 317, which might cause transactions built with it to fail. Maintaining
the generality of the current implementation imposes ongoing maintenance
costs, and so it is likely to be removed in the near future.

Use `transaction::fees::zip317::FeeRule::standard()` instead to comply
with ZIP 317.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 19:03:08 +01:00
Daira-Emma Hopwood baccb4361b Restore the logic to determine whether we are spending inputs that are
uneconomic to spend.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 17:47:08 +01:00
Daira-Emma Hopwood feabe6df93 Remove complicated code to calculate the number of dust spends.
See #1316 for re-adding it.

The previous code was essentially dead because it had no side effects
other than potentially returning an error. That error is unnecessary
and incorrect when we are not actually performing dust spends.

When we re-enable them, we should not try to make dust spends in
any transaction with non-default `ephemeral_parameters`, or if the
`dust_output_policy` is `DustAction::AddDustToFee`. That would
guarantee that we will always have a shielded change output, which
makes the calculations more tractable and excludes some potentially
complicated interactions.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 17:47:08 +01:00
Daira-Emma Hopwood f0e5aab692 Improve discrimination of proposal errors.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 17:47:08 +01:00
Daira-Emma Hopwood 81a2846593 Simpler way to calculate `has_shielded_inputs`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 17:47:08 +01:00
Daira-Emma Hopwood ec4a6d0cad Documentation improvements.
Co-authored-by: Jack Grigg <thestr4d@gmail.com>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 17:47:08 +01:00
Daira-Emma Hopwood 6471d4c27a Don't assume that prior step outputs are ephemeral iff they are
`StepOutputIndex::Change`.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-28 17:47:08 +01:00
Daira-Emma Hopwood 7a05b44df9 Make mutable inputs to closures in `create_proposed_transaction` explicit.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:45:45 +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 c926e7ce0a Filter ephemeral transparent `ChangeValue`s by `is_ephemeral()` as well as
pool type.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:43:09 +01:00
Daira-Emma Hopwood 0735390546 Rename `amount` to `transfer_amount` in `send_multi_step_proposed_transfer`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:43:09 +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 7d8a96f827 Don't cache metadata between steps; it's not an important optimization.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:43:09 +01:00
Daira-Emma Hopwood 7fb355739e Implement `WalletRead::get_transparent_address_metadata` for
`zcash_client_sqlite` using direct database queries.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-27 01:43:09 +01:00
Daira-Emma Hopwood 5a90fffed4 Factor out the conversion of the `diversifier_index_be` field in the
`addresses` table to a `NonHardenedChildIndex`.

(This moves where a `diversifier_index_be` field of the wrong length would
be detected and so is not quite a no-op, but that shouldn't matter.)

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 6b465b702e Document the mapping functions on `zcash_client_backend::wallet::Recipient`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 745054ba69 `find_account_for_transparent_output` now searches unreserved ephemeral
addresses within the gap limit. This should make recording TXOs found at
these addresses via `WalletWrite::put_received_transparent_utxo` work
correctly.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 914acb57ce Move most remaining code for wallet support of ephemeral addresses into
`zcash_client_sqlite::wallet::transparent::ephemeral`.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood e164b59329 Move most ephemeral address index handling into helper functions in
`zcash_client_sqlite::wallet::transparent::ephemeral`. Also report the
account id and index for `SqliteClientError::ReachedGapLimit`.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 25f07da47d Add a constraint on the range of `ephemeral_addresses(address_index)`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 994f6ff387 Change type of `n` in `reserve_next_n_ephemeral_addresses`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 637ae925da Add a migration test for the `ephemeral_addresses` migration.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 0f49daed5f `mark_ephemeral_address_as_mined` now prefers setting `mined_in_tx` to
the transaction mined at an earlier height, out of the newly observed
transaction and any already referenced one. This slightly reduces the
chance of unnecessarily reaching the gap limit too early in some corner
cases.

Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +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 eb8846162c Address review comment: `EphemeralIvk` should not implement `IncomingViewingKey`.
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-25 08:40:08 +01:00
Daira-Emma Hopwood 549fe0b652 In `reserve_next_n_ephemeral_addresses`, exclude addresses observed in
unmined transactions from consideration when calculating the end of the
gap.

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 5bd911f63b
Merge pull request #1402 from nuttycom/transparent_txos_migration
zcash_client_sqlite: Align handling of transparent UTXOs with that of shielded notes.
2024-06-24 20:34:44 -06:00
Kris Nuttycombe 9716617b55 Apply suggestions from code review
Co-authored-by: Jack Grigg <thestr4d@gmail.com>
Co-authored-by: Daira-Emma Hopwood <daira@jacaranda.org>
2024-06-24 14:50:29 -06:00
Kris Nuttycombe 10258b8443 zcash_client_sqlite: Address comments from code review. 2024-06-21 19:13:18 -06: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
Kris Nuttycombe d92bf27bfc zcash_client_sqlite: Move transparent-inputs wallet methods into the `wallet::transparent` module. 2024-06-21 19:13:17 -06:00
str4d 26c6b82e9b
Merge pull request #1419 from zcash/dependabot/github_actions/codecov/codecov-action-4.5.0
build(deps): bump codecov/codecov-action from 4.3.0 to 4.5.0
2024-06-20 21:23:03 +01:00
str4d 5e4c4a03e5
Merge pull request #1433 from nuttycom/fix_migration_pragmas
zcash_client_sqlite: Fix handling of PRAGMA directives.
2024-06-20 00:56:02 +01:00