Merge pull request #1655 from zcash/pczt-inspection

pczt: Add `Pczt::into_effects`
This commit is contained in:
Kris Nuttycombe 2024-12-14 07:27:50 -07:00 committed by GitHub
commit 37ca338fa5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View File

@ -44,6 +44,9 @@
use getset::Getters; use getset::Getters;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg(feature = "signer")]
use {roles::signer::EffectsOnly, zcash_primitives::transaction::TransactionData};
pub mod roles; pub mod roles;
pub mod common; pub mod common;
@ -107,6 +110,23 @@ impl Pczt {
bytes.extend_from_slice(&PCZT_VERSION_1.to_le_bytes()); bytes.extend_from_slice(&PCZT_VERSION_1.to_le_bytes());
postcard::to_extend(self, bytes).expect("can serialize into memory") 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. /// Errors that can occur while parsing a PCZT.

View File

@ -258,7 +258,7 @@ pub(crate) fn pczt_to_tx_data(
)) ))
} }
pub(crate) struct EffectsOnly; pub struct EffectsOnly;
impl Authorization for EffectsOnly { impl Authorization for EffectsOnly {
type TransparentAuth = transparent::EffectsOnly; type TransparentAuth = transparent::EffectsOnly;