Skip to main content

ChangeStrategy

Trait ChangeStrategy 

Source
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(
        &self,
        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§

Source

type FeeRule: FeeRule + Clone

Source

type Error: From<<Self::FeeRule as FeeRule>::Error>

Source

type MetaSource: MetaSource

The type of metadata source that this change strategy requires in order to be able to retrieve required wallet metadata.

Source

type AccountMetaT

Tye type of wallet metadata that this change strategy relies upon in order to compute change.

Required Methods§

Source

fn fee_rule(&self) -> &Self::FeeRule

Returns the fee rule that this change strategy will respect when performing balance computations.

Source

fn fetch_wallet_meta( &self, 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.

Source

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>>

Available on crate feature orchard only.

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.
Source§

impl<R, I> ChangeStrategy for MultiOutputChangeStrategy<R, I>
where R: Zip317FeeRule + Clone, I: InputSource, <R as FeeRule>::Error: From<BalanceError>,

Source§

type FeeRule = R

Source§

type Error = <R as FeeRule>::Error

Source§

type MetaSource = I

Source§

type AccountMetaT = AccountMeta

Source§

impl<R, I> ChangeStrategy for zcash_client_backend::fees::zip317::SingleOutputChangeStrategy<R, I>
where R: Zip317FeeRule + Clone, I: MetaSource, <R as FeeRule>::Error: From<BalanceError>,

Source§

type FeeRule = R

Source§

type Error = <R as FeeRule>::Error

Source§

type MetaSource = I

Source§

type AccountMetaT = ChangeReceivers