Add methods for getting block nullifiers
* Add methods for getting block nullifiers
These methods will be used in a future PR to check for double-spends.
* Add doc links
@@ -29,8 +29,11 @@ use serde::{Deserialize, Serialize};
use crate::{
fmt::DisplayToDebug,
+ orchard,
parameters::{Network, NetworkUpgrade},
+ sapling,
serialization::{TrustedPreallocate, MAX_PROTOCOL_MESSAGE_LEN},
+ sprout,
transaction::Transaction,
transparent,
};
@@ -116,6 +119,30 @@ impl Block {
Ok(())
}
+
+ /// Access the [`sprout::Nullifier`]s from all transactions in this block.
+ pub fn sprout_nullifiers(&self) -> impl Iterator<Item = &sprout::Nullifier> {
+ self.transactions
+ .iter()
+ .map(|transaction| transaction.sprout_nullifiers())
+ .flatten()
+ }
+
+ /// Access the [`sapling::Nullifier`]s from all transactions in this block.
+ pub fn sapling_nullifiers(&self) -> impl Iterator<Item = &sapling::Nullifier> {
+ self.transactions
+ .iter()
+ .map(|transaction| transaction.sapling_nullifiers())
+ .flatten()
+ }
+
+ /// Access the [`orchard::Nullifier`]s from all transactions in this block.
+ pub fn orchard_nullifiers(&self) -> impl Iterator<Item = &orchard::Nullifier> {
+ self.transactions
+ .iter()
+ .map(|transaction| transaction.orchard_nullifiers())
+ .flatten()
+ }
}
impl<'a> From<&'a Block> for Hash {
