Add action methods (#2199)
* add action methods Co-authored-by: teor <teor@riseup.net> Co-authored-by: Janito Vaqueiro Ferreira Filho <janito.vff@gmail.com>
This commit is contained in:
parent
896565377a
commit
c3820b44eb
|
|
@ -3,7 +3,7 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
amount::Amount,
|
amount::Amount,
|
||||||
block::MAX_BLOCK_BYTES,
|
block::MAX_BLOCK_BYTES,
|
||||||
orchard::{tree, Action},
|
orchard::{tree, Action, Nullifier},
|
||||||
primitives::{
|
primitives::{
|
||||||
redpallas::{Binding, Signature, SpendAuth},
|
redpallas::{Binding, Signature, SpendAuth},
|
||||||
Halo2Proof,
|
Halo2Proof,
|
||||||
|
|
@ -38,6 +38,27 @@ pub struct ShieldedData {
|
||||||
pub binding_sig: Signature<Binding>,
|
pub binding_sig: Signature<Binding>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ShieldedData {
|
||||||
|
/// Iterate over the [`Action`]s for the [`AuthorizedAction`]s in this transaction.
|
||||||
|
pub fn actions(&self) -> impl Iterator<Item = &Action> {
|
||||||
|
self.actions.actions()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Collect the [`Nullifier`]s for this transaction, if it contains
|
||||||
|
/// [`Action`]s.
|
||||||
|
pub fn nullifiers(&self) -> impl Iterator<Item = &Nullifier> {
|
||||||
|
self.actions().map(|action| &action.nullifier)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl AtLeastOne<AuthorizedAction> {
|
||||||
|
/// Iterate over the [`Action`]s of each [`AuthorizedAction`].
|
||||||
|
pub fn actions(&self) -> impl Iterator<Item = &Action> {
|
||||||
|
self.iter()
|
||||||
|
.map(|authorized_action| &authorized_action.action)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// An authorized action description.
|
/// An authorized action description.
|
||||||
///
|
///
|
||||||
/// Every authorized Orchard `Action` must have a corresponding `SpendAuth` signature.
|
/// Every authorized Orchard `Action` must have a corresponding `SpendAuth` signature.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue