diff --git a/zebra-chain/src/sapling/shielded_data.rs b/zebra-chain/src/sapling/shielded_data.rs index 476cf70e..f3ddbc16 100644 --- a/zebra-chain/src/sapling/shielded_data.rs +++ b/zebra-chain/src/sapling/shielded_data.rs @@ -165,22 +165,14 @@ where AnchorV: AnchorVariant + Clone, Spend: From<(Spend, AnchorV::Shared)>, { - /// Iterate over the [`Spend`]s for this transaction. - /// - /// Returns `Spend` regardless of the underlying transaction - /// version, to allow generic verification over V4 and V5 transactions. + /// Iterate over the [`Spend`]s for this transaction, returning + /// `Spend` regardless of the underlying transaction version. /// /// # Correctness /// /// Do not use this function for serialization. pub fn spends_per_anchor(&self) -> impl Iterator> + '_ { - self.spends().cloned().map(move |spend| { - Spend::::from(( - spend, - self.shared_anchor() - .expect("shared anchor must be Some if there are any spends"), - )) - }) + self.transfers.spends_per_anchor() } } @@ -257,6 +249,32 @@ where } } +impl TransferData +where + AnchorV: AnchorVariant + Clone, + Spend: From<(Spend, AnchorV::Shared)>, +{ + /// Iterate over the [`Spend`]s for this transaction, returning + /// `Spend` regardless of the underlying transaction version. + /// + /// Allows generic operations over V4 and V5 transactions, including: + /// * spend verification, and + /// * non-malleable transaction ID generation. + /// + /// # Correctness + /// + /// Do not use this function for serialization. + pub fn spends_per_anchor(&self) -> impl Iterator> + '_ { + self.spends().cloned().map(move |spend| { + Spend::::from(( + spend, + self.shared_anchor() + .expect("shared anchor must be Some if there are any spends"), + )) + }) + } +} + impl TransferData where AnchorV: AnchorVariant + Clone,