Skip to main content

zcash_primitives/transaction/
fees.rs

1//! Abstractions and types related to fee calculations.
2
3use crate::transaction::fees::transparent::InputSize;
4use zcash_protocol::{
5    consensus::{self, BlockHeight},
6    value::Zatoshis,
7};
8
9#[cfg(feature = "non-standard-fees")]
10pub mod fixed;
11pub mod transparent;
12pub mod zip317;
13
14/// A trait that represents the ability to compute the fees that must be paid
15/// by a transaction having a specified set of inputs and outputs.
16pub trait FeeRule {
17    type Error;
18
19    /// Computes the total fee required for a transaction given the provided inputs and outputs.
20    ///
21    /// Implementations of this method should compute the fee amount given exactly the inputs and
22    /// outputs specified, and should NOT compute speculative fees given any additional change
23    /// outputs that may need to be created in order for inputs and outputs to balance.
24    #[allow(clippy::too_many_arguments)]
25    fn fee_required<P: consensus::Parameters>(
26        &self,
27        params: &P,
28        target_height: BlockHeight,
29        transparent_input_sizes: impl IntoIterator<Item = InputSize>,
30        transparent_output_sizes: impl IntoIterator<Item = usize>,
31        sapling_input_count: usize,
32        sapling_output_count: usize,
33        orchard_action_count: usize,
34        ironwood_action_count: usize,
35    ) -> Result<Zatoshis, Self::Error>;
36}