pub trait ChangeStrategy {
type FeeRule: FeeRule + Clone;
type Error: From<<Self::FeeRule as FeeRule>::Error>;
type MetaSource: MetaSource;
type AccountMetaT;
// Required methods
fn fee_rule(&self) -> &Self::FeeRule;
fn fetch_wallet_meta<P: Parameters>(
&self,
params: &P,
meta_source: &Self::MetaSource,
account: <Self::MetaSource as MetaSource>::AccountId,
target_height: TargetHeight,
exclude: &[<Self::MetaSource as MetaSource>::NoteRef],
) -> Result<Self::AccountMetaT, <Self::MetaSource as MetaSource>::Error>;
fn compute_balance<P: Parameters, NoteRefT: Clone>(
&self,
params: &P,
target_height: TargetHeight,
anchor_height: BlockHeight,
zip318: &PoolMigrationParams,
transparent_inputs: &[impl InputView],
transparent_outputs: &[impl OutputView],
sapling: &impl BundleView<NoteRefT>,
orchard: &impl BundleView<NoteRefT>,
ironwood: &impl BundleView<NoteRefT>,
ephemeral_balance: Option<EphemeralBalance>,
wallet_meta: &Self::AccountMetaT,
) -> Result<TransactionBalance, ChangeError<Self::Error, NoteRefT>>;
}Expand description
A trait that represents the ability to compute the suggested change and fees that must be paid by a transaction having a specified set of inputs and outputs.
Required Associated Types§
type FeeRule: FeeRule + Clone
type Error: From<<Self::FeeRule as FeeRule>::Error>
Sourcetype MetaSource: MetaSource
type MetaSource: MetaSource
The type of metadata source that this change strategy requires in order to be able to retrieve required wallet metadata.
Sourcetype AccountMetaT
type AccountMetaT
Tye type of wallet metadata that this change strategy relies upon in order to compute change.
Required Methods§
Sourcefn fee_rule(&self) -> &Self::FeeRule
fn fee_rule(&self) -> &Self::FeeRule
Returns the fee rule that this change strategy will respect when performing balance computations.
Sourcefn fetch_wallet_meta<P: Parameters>(
&self,
params: &P,
meta_source: &Self::MetaSource,
account: <Self::MetaSource as MetaSource>::AccountId,
target_height: TargetHeight,
exclude: &[<Self::MetaSource as MetaSource>::NoteRef],
) -> Result<Self::AccountMetaT, <Self::MetaSource as MetaSource>::Error>
fn fetch_wallet_meta<P: Parameters>( &self, params: &P, meta_source: &Self::MetaSource, account: <Self::MetaSource as MetaSource>::AccountId, target_height: TargetHeight, exclude: &[<Self::MetaSource as MetaSource>::NoteRef], ) -> Result<Self::AccountMetaT, <Self::MetaSource as MetaSource>::Error>
Uses the provided metadata source to obtain the wallet metadata required for change
creation determinations, for a transaction on the network params expected to be mined
at target_height.
Sourcefn compute_balance<P: Parameters, NoteRefT: Clone>(
&self,
params: &P,
target_height: TargetHeight,
anchor_height: BlockHeight,
zip318: &PoolMigrationParams,
transparent_inputs: &[impl InputView],
transparent_outputs: &[impl OutputView],
sapling: &impl BundleView<NoteRefT>,
orchard: &impl BundleView<NoteRefT>,
ironwood: &impl BundleView<NoteRefT>,
ephemeral_balance: Option<EphemeralBalance>,
wallet_meta: &Self::AccountMetaT,
) -> Result<TransactionBalance, ChangeError<Self::Error, NoteRefT>>
fn compute_balance<P: Parameters, NoteRefT: Clone>( &self, params: &P, target_height: TargetHeight, anchor_height: BlockHeight, zip318: &PoolMigrationParams, transparent_inputs: &[impl InputView], transparent_outputs: &[impl OutputView], sapling: &impl BundleView<NoteRefT>, orchard: &impl BundleView<NoteRefT>, ironwood: &impl BundleView<NoteRefT>, ephemeral_balance: Option<EphemeralBalance>, wallet_meta: &Self::AccountMetaT, ) -> Result<TransactionBalance, ChangeError<Self::Error, NoteRefT>>
Computes the totals of inputs, suggested change amounts, and fees given the provided inputs and outputs being used to construct a transaction.
The fee computed as part of this operation should take into account the prospective
change outputs recommended by this operation. If insufficient funds are available to
supply the requested outputs and required fees, implementations should return
ChangeError::InsufficientFunds, with a required value that exceeds the total
value of the inputs provided.
If the inputs include notes or UTXOs that are not economic to spend in the context
of this input selection, a ChangeError::DustInputs error can be returned
indicating inputs that should be removed from the selection (all of which will
have value less than or equal to the marginal fee). Every input it names must be
one of the inputs provided, and it must name at least one. The caller should order
the inputs from most to least preferred to spend within each pool, so that the most
preferred ones are less likely to be indicated to remove.
ironwood: the Ironwood bundle view (behind theorchardfeature). A V6 transaction carries a separate Ironwood bundle, distinct fromorchard, with its own action count; pass an empty view when nothing targets the Ironwood pool.ephemeral_balance: if the transaction is to be constructed with either an ephemeral transparent input or an ephemeral transparent output this argument may be used to provide the value of that input or output. The value of this argument should beNonein the case that there are no such items.wallet_meta: Additional wallet metadata that the change strategy may use in determining how to construct change outputs. This wallet metadata value should be computed excluding the inputs provided in thetransparent_inputs,sapling,orchard, andironwoodarguments.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<I: InputSource> ChangeStrategy for zcash_client_backend::fees::fixed::SingleOutputChangeStrategy<I>
Available on crate feature non-standard-fees only.
impl<I: InputSource> ChangeStrategy for zcash_client_backend::fees::fixed::SingleOutputChangeStrategy<I>
non-standard-fees only.