Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pczt: Add Pczt::into_effects #1655

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading