diff --git a/src/issuance.rs b/src/issuance.rs index 74247f928..fcb4a2e98 100644 --- a/src/issuance.rs +++ b/src/issuance.rs @@ -14,6 +14,7 @@ use crate::issuance::Error::{ use crate::keys::{IssuanceAuthorizingKey, IssuanceValidatingKey}; use crate::note::asset_id::is_asset_desc_of_valid_size; use crate::note::{AssetId, Nullifier}; +use crate::primitives::redpallas::Signature; use crate::value::NoteValue; use crate::{ primitives::redpallas::{self, SpendAuth}, @@ -21,7 +22,7 @@ use crate::{ }; /// A bundle of actions to be applied to the ledger. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct IssueBundle { /// The issuer key for the note being created. ik: IssuanceValidatingKey, @@ -106,20 +107,20 @@ impl IssueAction { } /// Defines the authorization type of an Issue bundle. -pub trait IssueAuth: fmt::Debug {} +pub trait IssueAuth: fmt::Debug + Clone {} /// Marker for an unauthorized bundle with no proofs or signatures. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Unauthorized; /// Marker for an unauthorized bundle with injected sighash. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Prepared { sighash: [u8; 32], } /// Marker for an authorized bundle. -#[derive(Debug)] +#[derive(Debug, Clone)] pub struct Signed { signature: redpallas::Signature, } @@ -129,6 +130,11 @@ impl Signed { pub fn signature(&self) -> &redpallas::Signature { &self.signature } + + /// Constructs an `Signed` from its constituent parts. + pub fn from_parts(signature: Signature) -> Self { + Signed { signature } + } } impl IssueAuth for Unauthorized {} @@ -176,6 +182,19 @@ impl IssueBundle { pub fn commitment(&self) -> IssueBundleCommitment { IssueBundleCommitment(hash_issue_bundle_txid_data(self)) } + + /// Constructs an `IssueBundle` from its constituent parts. + pub fn from_parts( + ik: IssuanceValidatingKey, + actions: Vec, + authorization: T, + ) -> Self { + IssueBundle { + ik, + actions, + authorization, + } + } } impl IssueBundle { diff --git a/src/keys.rs b/src/keys.rs index dc1d7d77b..9007290a3 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -271,7 +271,7 @@ impl Eq for IssuanceValidatingKey {} impl IssuanceValidatingKey { /// Converts this spend validating key to its serialized form, /// I2LEOSP_256(ik). - pub(crate) fn to_bytes(&self) -> [u8; 32] { + pub fn to_bytes(&self) -> [u8; 32] { // This is correct because the wrapped point must have ỹ = 0, and // so the point repr is the same as I2LEOSP of its x-coordinate. <[u8; 32]>::from(&self.0)