Apply documentation suggestions from code review.

Co-authored-by: Kris Nuttycombe <kris@nutty.land>
Signed-off-by: Daira-Emma Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira-Emma Hopwood 2024-06-26 07:14:47 +01:00
parent 7d8a96f827
commit bd6c9f3599
4 changed files with 21 additions and 11 deletions

View File

@ -9,8 +9,7 @@ and this library adheres to Rust's notion of
### Notable changes ### Notable changes
`zcash_client_backend` now supports TEX (transparent-source-only) addresses as specified `zcash_client_backend` now supports TEX (transparent-source-only) addresses as specified
in ZIP 320. Sending to one or more TEX addresses will automatically create a multi-step in ZIP 320. Sending to one or more TEX addresses will automatically create a multi-step
proposal that uses two transactions. This is intended to be used in conjunction with proposal that uses two transactions.
`zcash_client_sqlite` 0.11 or later.
In order to take advantage of this support, client wallets will need to be able to send In order to take advantage of this support, client wallets will need to be able to send
multiple transactions created from `zcash_client_backend::data_api::wallet::create_proposed_transactions`. multiple transactions created from `zcash_client_backend::data_api::wallet::create_proposed_transactions`.

View File

@ -604,7 +604,9 @@ where
ParamsT: consensus::Parameters + Clone, ParamsT: consensus::Parameters + Clone,
FeeRuleT: FeeRule, FeeRuleT: FeeRule,
{ {
// The set of transparent StepOutputs available and unused from prior steps. // The set of transparent `StepOutput`s available and unused from prior steps.
// When a transparent `StepOutput` is created, it is added to the map. When it
// is consumed, it is removed from the map.
#[cfg(feature = "transparent-inputs")] #[cfg(feature = "transparent-inputs")]
let mut unused_transparent_outputs = HashMap::new(); let mut unused_transparent_outputs = HashMap::new();

View File

@ -464,6 +464,9 @@ where
// The ephemeral input going into transaction 1 must be able to pay that // The ephemeral input going into transaction 1 must be able to pay that
// transaction's fee, as well as the TEX address payments. // transaction's fee, as well as the TEX address payments.
// First compute the required total without providing any input value,
// catching the `InsufficientFunds` error to obtain the required amount
// given the provided change strategy.
let tr1_required_input_value = let tr1_required_input_value =
match self.change_strategy.compute_balance::<_, DbT::NoteRef>( match self.change_strategy.compute_balance::<_, DbT::NoteRef>(
params, params,
@ -475,7 +478,7 @@ where
&orchard_fees::EmptyBundleView, &orchard_fees::EmptyBundleView,
&self.dust_output_policy, &self.dust_output_policy,
#[cfg(feature = "transparent-inputs")] #[cfg(feature = "transparent-inputs")]
true, true, // ignore change memo to avoid adding a change output
#[cfg(feature = "transparent-inputs")] #[cfg(feature = "transparent-inputs")]
&[NonNegativeAmount::ZERO], &[NonNegativeAmount::ZERO],
#[cfg(feature = "transparent-inputs")] #[cfg(feature = "transparent-inputs")]
@ -486,6 +489,8 @@ where
Err(other) => return Err(other.into()), Err(other) => return Err(other.into()),
}; };
// Now recompute to obtain the `TransactionBalance` and verify that it
// fully accounts for the required fees.
let tr1_balance = self.change_strategy.compute_balance::<_, DbT::NoteRef>( let tr1_balance = self.change_strategy.compute_balance::<_, DbT::NoteRef>(
params, params,
target_height, target_height,
@ -496,7 +501,7 @@ where
&orchard_fees::EmptyBundleView, &orchard_fees::EmptyBundleView,
&self.dust_output_policy, &self.dust_output_policy,
#[cfg(feature = "transparent-inputs")] #[cfg(feature = "transparent-inputs")]
true, true, // ignore change memo to avoid adding a change output
#[cfg(feature = "transparent-inputs")] #[cfg(feature = "transparent-inputs")]
&[tr1_required_input_value], &[tr1_required_input_value],
#[cfg(feature = "transparent-inputs")] #[cfg(feature = "transparent-inputs")]

View File

@ -26,6 +26,10 @@ use crate::{error::SqliteClientError, wallet::get_account, AccountId, SqlTransac
pub(crate) const GAP_LIMIT: i32 = 20; pub(crate) const GAP_LIMIT: i32 = 20;
// The custom scope used for derivation of ephemeral addresses. // The custom scope used for derivation of ephemeral addresses.
//
// This must match the constant used in
// `zcash_primitives::legacy::keys::AccountPubKey::derive_ephemeral_ivk`.
//
// TODO: consider moving this to `zcash_primitives::legacy::keys`, or else // TODO: consider moving this to `zcash_primitives::legacy::keys`, or else
// provide a way to derive `ivk`s for custom scopes in general there, so that // provide a way to derive `ivk`s for custom scopes in general there, so that
// the constant isn't duplicated. // the constant isn't duplicated.