Add default trait implementation for TxIn
This commit is contained in:
parent
c93a70487f
commit
0586ed94c4
|
@ -204,6 +204,17 @@ pub struct TxIn {
|
||||||
}
|
}
|
||||||
serde_struct_impl!(TxIn, previous_output, script_sig, sequence, witness);
|
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.
|
/// A transaction output, which defines new coins to be created from old ones.
|
||||||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||||
pub struct TxOut {
|
pub struct TxOut {
|
||||||
|
@ -662,6 +673,16 @@ mod tests {
|
||||||
assert!(txin.is_ok());
|
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]
|
#[test]
|
||||||
fn test_is_coinbase () {
|
fn test_is_coinbase () {
|
||||||
use network::constants::Network;
|
use network::constants::Network;
|
||||||
|
|
Loading…
Reference in New Issue