@@ -34,7 +34,7 @@ use secp256k1_zkp::{
3434} ;
3535
3636/// Description of an asset issuance in a transaction input
37- #[ derive( Copy , Clone , Debug , Default , Eq , Hash , PartialEq , PartialOrd , Ord ) ]
37+ #[ derive( Copy , Clone , Debug , Eq , Hash , PartialEq , PartialOrd , Ord ) ]
3838pub struct AssetIssuance {
3939 /// Zero for a new asset issuance; otherwise a blinding factor for the input
4040 pub asset_blinding_nonce : Tweak ,
@@ -47,6 +47,15 @@ pub struct AssetIssuance {
4747}
4848
4949impl AssetIssuance {
50+ /// Create a null issuance.
51+ pub fn null ( ) -> Self {
52+ AssetIssuance {
53+ asset_blinding_nonce : ZERO_TWEAK ,
54+ asset_entropy : [ 0 ; 32 ] ,
55+ amount : confidential:: Value :: Null ,
56+ inflation_keys : confidential:: Value :: Null ,
57+ }
58+ }
5059
5160 /// Checks whether the [`AssetIssuance`] is null
5261 pub fn is_null ( & self ) -> bool {
@@ -56,6 +65,12 @@ impl AssetIssuance {
5665serde_struct_impl ! ( AssetIssuance , asset_blinding_nonce, asset_entropy, amount, inflation_keys) ;
5766impl_consensus_encoding ! ( AssetIssuance , asset_blinding_nonce, asset_entropy, amount, inflation_keys) ;
5867
68+ impl Default for AssetIssuance {
69+ fn default ( ) -> Self {
70+ Self :: null ( )
71+ }
72+ }
73+
5974/// A reference to a transaction output
6075#[ derive( Copy , Clone , Debug , Eq , Hash , PartialEq , PartialOrd , Ord ) ]
6176pub struct OutPoint {
@@ -343,7 +358,7 @@ impl std::error::Error for RelativeLockTimeError {
343358
344359
345360/// Transaction input witness
346- #[ derive( Clone , Default , PartialEq , Eq , Debug , Hash , PartialOrd , Ord ) ]
361+ #[ derive( Clone , PartialEq , Eq , Debug , Hash , PartialOrd , Ord ) ]
347362pub struct TxInWitness {
348363 /// Amount rangeproof
349364 pub amount_rangeproof : Option < Box < RangeProof > > ,
@@ -358,6 +373,16 @@ serde_struct_impl!(TxInWitness, amount_rangeproof, inflation_keys_rangeproof, sc
358373impl_consensus_encoding ! ( TxInWitness , amount_rangeproof, inflation_keys_rangeproof, script_witness, pegin_witness) ;
359374
360375impl TxInWitness {
376+ /// Create an empty input witness.
377+ pub fn empty ( ) -> Self {
378+ TxInWitness {
379+ amount_rangeproof : None ,
380+ inflation_keys_rangeproof : None ,
381+ script_witness : Vec :: new ( ) ,
382+ pegin_witness : Vec :: new ( ) ,
383+ }
384+ }
385+
361386 /// Whether this witness is null
362387 pub fn is_empty ( & self ) -> bool {
363388 self . amount_rangeproof . is_none ( ) &&
@@ -367,6 +392,12 @@ impl TxInWitness {
367392 }
368393}
369394
395+ impl Default for TxInWitness {
396+ fn default ( ) -> Self {
397+ Self :: empty ( )
398+ }
399+ }
400+
370401
371402/// Parsed data from a transaction input's pegin witness
372403#[ derive( Copy , Clone , PartialEq , Eq , Debug , Hash ) ]
@@ -604,7 +635,7 @@ impl TxIn {
604635}
605636
606637/// Transaction output witness
607- #[ derive( Clone , Default , PartialEq , Eq , Debug , Hash , PartialOrd , Ord ) ]
638+ #[ derive( Clone , PartialEq , Eq , Debug , Hash , PartialOrd , Ord ) ]
608639pub struct TxOutWitness {
609640 /// Surjection proof showing that the asset commitment is legitimate
610641 // We Box it because surjection proof internally is an array [u8; N] that
@@ -619,6 +650,14 @@ serde_struct_impl!(TxOutWitness, surjection_proof, rangeproof);
619650impl_consensus_encoding ! ( TxOutWitness , surjection_proof, rangeproof) ;
620651
621652impl TxOutWitness {
653+ /// Create an empty output witness.
654+ pub fn empty ( ) -> Self {
655+ TxOutWitness {
656+ surjection_proof : None ,
657+ rangeproof : None ,
658+ }
659+ }
660+
622661 /// Whether this witness is null
623662 pub fn is_empty ( & self ) -> bool {
624663 self . surjection_proof . is_none ( ) && self . rangeproof . is_none ( )
@@ -635,6 +674,12 @@ impl TxOutWitness {
635674 }
636675}
637676
677+ impl Default for TxOutWitness {
678+ fn default ( ) -> Self {
679+ Self :: empty ( )
680+ }
681+ }
682+
638683/// Information about a pegout
639684#[ derive( Clone , PartialEq , Eq , Debug , Hash ) ]
640685pub struct PegoutData < ' txo > {
@@ -690,7 +735,6 @@ impl Decodable for TxOut {
690735}
691736
692737impl TxOut {
693-
694738 /// Create a new fee output.
695739 pub fn new_fee ( amount : u64 , asset : AssetId ) -> TxOut {
696740 TxOut {
0 commit comments