Merge pull request #1655 from zcash/pczt-inspection
pczt: Add `Pczt::into_effects`
This commit is contained in:
commit
37ca338fa5
|
@ -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.
|
||||||
|
|
|
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue