Skip to content

Commit

Permalink
Merge pull request #1655 from zcash/pczt-inspection
Browse files Browse the repository at this point in the history
pczt: Add `Pczt::into_effects`
  • Loading branch information
nuttycom authored Dec 14, 2024
2 parents 82093f8 + 688dcaf commit 37ca338
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions pczt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
use getset::Getters;
use serde::{Deserialize, Serialize};

#[cfg(feature = "signer")]
use {roles::signer::EffectsOnly, zcash_primitives::transaction::TransactionData};

pub mod roles;

pub mod common;
Expand Down Expand Up @@ -107,6 +110,23 @@ impl Pczt {
bytes.extend_from_slice(&PCZT_VERSION_1.to_le_bytes());
postcard::to_extend(self, bytes).expect("can serialize into memory")
}

/// Gets the effects of this transaction.
#[cfg(feature = "signer")]
pub fn into_effects(self) -> Option<TransactionData<EffectsOnly>> {
let Self {
global,
transparent,
sapling,
orchard,
} = self;

let transparent = transparent.into_parsed().ok()?;
let sapling = sapling.into_parsed().ok()?;
let orchard = orchard.into_parsed().ok()?;

roles::signer::pczt_to_tx_data(&global, &transparent, &sapling, &orchard).ok()
}
}

/// Errors that can occur while parsing a PCZT.
Expand Down
2 changes: 1 addition & 1 deletion pczt/src/roles/signer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ pub(crate) fn pczt_to_tx_data(
))
}

pub(crate) struct EffectsOnly;
pub struct EffectsOnly;

impl Authorization for EffectsOnly {
type TransparentAuth = transparent::EffectsOnly;
Expand Down

0 comments on commit 37ca338

Please sign in to comment.