Move spends_per_anchor to TransferData
And update its docs for ZIP-244
This commit is contained in:
parent
9e45e6bb23
commit
d3836e6fd8
|
|
@ -165,22 +165,14 @@ where
|
||||||
AnchorV: AnchorVariant + Clone,
|
AnchorV: AnchorVariant + Clone,
|
||||||
Spend<PerSpendAnchor>: From<(Spend<AnchorV>, AnchorV::Shared)>,
|
Spend<PerSpendAnchor>: From<(Spend<AnchorV>, AnchorV::Shared)>,
|
||||||
{
|
{
|
||||||
/// Iterate over the [`Spend`]s for this transaction.
|
/// Iterate over the [`Spend`]s for this transaction, returning
|
||||||
///
|
/// `Spend<PerSpendAnchor>` regardless of the underlying transaction version.
|
||||||
/// Returns `Spend<PerSpendAnchor>` regardless of the underlying transaction
|
|
||||||
/// version, to allow generic verification over V4 and V5 transactions.
|
|
||||||
///
|
///
|
||||||
/// # Correctness
|
/// # Correctness
|
||||||
///
|
///
|
||||||
/// Do not use this function for serialization.
|
/// Do not use this function for serialization.
|
||||||
pub fn spends_per_anchor(&self) -> impl Iterator<Item = Spend<PerSpendAnchor>> + '_ {
|
pub fn spends_per_anchor(&self) -> impl Iterator<Item = Spend<PerSpendAnchor>> + '_ {
|
||||||
self.spends().cloned().map(move |spend| {
|
self.transfers.spends_per_anchor()
|
||||||
Spend::<PerSpendAnchor>::from((
|
|
||||||
spend,
|
|
||||||
self.shared_anchor()
|
|
||||||
.expect("shared anchor must be Some if there are any spends"),
|
|
||||||
))
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,6 +249,32 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<AnchorV> TransferData<AnchorV>
|
||||||
|
where
|
||||||
|
AnchorV: AnchorVariant + Clone,
|
||||||
|
Spend<PerSpendAnchor>: From<(Spend<AnchorV>, AnchorV::Shared)>,
|
||||||
|
{
|
||||||
|
/// Iterate over the [`Spend`]s for this transaction, returning
|
||||||
|
/// `Spend<PerSpendAnchor>` 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<Item = Spend<PerSpendAnchor>> + '_ {
|
||||||
|
self.spends().cloned().map(move |spend| {
|
||||||
|
Spend::<PerSpendAnchor>::from((
|
||||||
|
spend,
|
||||||
|
self.shared_anchor()
|
||||||
|
.expect("shared anchor must be Some if there are any spends"),
|
||||||
|
))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<AnchorV> TransferData<AnchorV>
|
impl<AnchorV> TransferData<AnchorV>
|
||||||
where
|
where
|
||||||
AnchorV: AnchorVariant + Clone,
|
AnchorV: AnchorVariant + Clone,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue