zcash_primitives: Implement `Clone` on bundle marker types

This enables unauthorized Sapling bundles to be cloned, for example when
loading them into a `TransactionData` for signature hashing.
This commit is contained in:
Jack Grigg 2023-11-04 03:59:21 +00:00
parent 7d1c0a29ca
commit 3b8c932ab9
1 changed files with 11 additions and 3 deletions

View File

@ -583,7 +583,7 @@ impl<P: InProgressProofs, S: InProgressSignatures> Authorization for InProgress<
///
/// The [`SpendDescription`]s and [`OutputDescription`]s within the bundle contain the
/// private data needed to create proofs.
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub struct Unproven;
impl InProgressProofs for Unproven {
@ -592,7 +592,7 @@ impl InProgressProofs for Unproven {
}
/// Marker for a [`Bundle`] with proofs.
#[derive(Debug)]
#[derive(Clone, Copy, Debug)]
pub struct Proven;
impl InProgressProofs for Proven {
@ -692,6 +692,14 @@ pub struct Unsigned {
bsk: PrivateKey,
}
impl Clone for Unsigned {
fn clone(&self) -> Self {
Self {
bsk: PrivateKey(self.bsk.0),
}
}
}
impl fmt::Debug for Unsigned {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Unsigned").finish_non_exhaustive()
@ -713,7 +721,7 @@ pub struct SigningParts {
}
/// Marker for a partially-authorized bundle, in the process of being signed.
#[derive(Debug)]
#[derive(Clone, Debug)]
pub struct PartiallyAuthorized {
binding_signature: Signature,
sighash: [u8; 32],