From f31fb08651e2d2d3dd2c1cc9723e36a4b5aea2f2 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Mon, 25 Sep 2023 05:51:24 +1000 Subject: [PATCH] Remove default impl from transaction version There is no logical default for the transaction version number, there is only pre-bip68 (v1) and post-bip68 (v2). Uses should specify the version they want not rely on us making the choice. (I originally added this impl to support testing, this was in hindsight the wrong thing to do, props to Sanket for noticing.) --- bitcoin/src/blockdata/transaction.rs | 6 +----- bitcoin/src/crypto/sighash.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index 26f72ad2..1f970b3b 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -980,10 +980,6 @@ impl Version { pub fn is_standard(&self) -> bool { *self == Version::ONE || *self == Version::TWO } } -impl Default for Version { - fn default() -> Version { Version::TWO } -} - impl Encodable for Version { fn consensus_encode(&self, w: &mut W) -> Result { self.0.consensus_encode(w) @@ -1942,7 +1938,7 @@ mod tests { ]; let empty_transaction_weight = Transaction { - version: Version::default(), + version: Version::TWO, lock_time: absolute::LockTime::ZERO, input: vec![], output: vec![], diff --git a/bitcoin/src/crypto/sighash.rs b/bitcoin/src/crypto/sighash.rs index cabf7de9..64384b4c 100644 --- a/bitcoin/src/crypto/sighash.rs +++ b/bitcoin/src/crypto/sighash.rs @@ -1463,7 +1463,7 @@ mod tests { #[rustfmt::skip] // Allow long function call `taproot_signature_hash`. fn test_sighash_errors() { let dumb_tx = Transaction { - version: transaction::Version::default(), + version: transaction::Version::TWO, lock_time: absolute::LockTime::ZERO, input: vec![TxIn::default()], output: vec![],