From 688dcaf077e3f989a7b7ddea5c391c5f9eb433af Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Sat, 14 Dec 2024 11:29:24 +0000 Subject: [PATCH] pczt: Add `Pczt::into_effects` --- pczt/src/lib.rs | 20 ++++++++++++++++++++ pczt/src/roles/signer/mod.rs | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pczt/src/lib.rs b/pczt/src/lib.rs index d629f6394..293656ae3 100644 --- a/pczt/src/lib.rs +++ b/pczt/src/lib.rs @@ -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; @@ -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> { + 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. diff --git a/pczt/src/roles/signer/mod.rs b/pczt/src/roles/signer/mod.rs index 5923c6218..a3a417fb8 100644 --- a/pczt/src/roles/signer/mod.rs +++ b/pczt/src/roles/signer/mod.rs @@ -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;