diff --git a/src/blockdata/transaction.rs b/src/blockdata/transaction.rs index f875b324..8ae4eda8 100644 --- a/src/blockdata/transaction.rs +++ b/src/blockdata/transaction.rs @@ -203,6 +203,17 @@ pub struct TxIn { } serde_struct_impl!(TxIn, previous_output, script_sig, sequence, witness); +impl Default for TxIn { + fn default() -> TxIn { + TxIn { + previous_output: OutPoint::default(), + script_sig: Script::new(), + sequence: u32::max_value(), + witness: Vec::new(), + } + } +} + /// A transaction output, which defines new coins to be created from old ones. #[derive(Clone, PartialEq, Eq, Debug, Hash)] pub struct TxOut { @@ -659,6 +670,16 @@ mod tests { assert!(txin.is_ok()); } + #[test] + fn test_txin_default() { + let txin = TxIn::default(); + assert_eq!(txin.previous_output, OutPoint::default()); + assert_eq!(txin.script_sig, Script::new()); + assert_eq!(txin.sequence, 0xFFFFFFFF); + assert_eq!(txin.previous_output, OutPoint::default()); + assert_eq!(txin.witness.len(), 0 as usize); + } + #[test] fn test_is_coinbase () { use network::constants::Network;