Merge rust-bitcoin/rust-bitcoin#2091: Remove default impl from transaction version

f31fb08651 Remove default impl from transaction version (Tobin C. Harding)

Pull request description:

  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.)

  Discussed in comments here: https://github.com/rust-bitcoin/rust-bitcoin/pull/2006#issuecomment-1732385464

ACKs for top commit:
  clarkmoody:
    ACK  f31fb08651
  apoelstra:
    ACK f31fb08651

Tree-SHA512: 1112c35173d6b2e7d6c50f058b1964fc8b633615ae703b0c1231e701a3e322fd55d3a8377c7ea078f28f523b15b7de6e9eca844226fcd19528206161d75dcfdf
This commit is contained in:
Andrew Poelstra 2023-09-25 13:39:50 +00:00
commit 55c5408aff
No known key found for this signature in database
GPG Key ID: C588D63CE41B97C1
2 changed files with 2 additions and 6 deletions

View File

@ -980,10 +980,6 @@ impl Version {
pub fn is_standard(&self) -> bool { *self == Version::ONE || *self == Version::TWO } 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 { impl Encodable for Version {
fn consensus_encode<W: io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> { fn consensus_encode<W: io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, io::Error> {
self.0.consensus_encode(w) self.0.consensus_encode(w)
@ -1942,7 +1938,7 @@ mod tests {
]; ];
let empty_transaction_weight = Transaction { let empty_transaction_weight = Transaction {
version: Version::default(), version: Version::TWO,
lock_time: absolute::LockTime::ZERO, lock_time: absolute::LockTime::ZERO,
input: vec![], input: vec![],
output: vec![], output: vec![],

View File

@ -1463,7 +1463,7 @@ mod tests {
#[rustfmt::skip] // Allow long function call `taproot_signature_hash`. #[rustfmt::skip] // Allow long function call `taproot_signature_hash`.
fn test_sighash_errors() { fn test_sighash_errors() {
let dumb_tx = Transaction { let dumb_tx = Transaction {
version: transaction::Version::default(), version: transaction::Version::TWO,
lock_time: absolute::LockTime::ZERO, lock_time: absolute::LockTime::ZERO,
input: vec![TxIn::default()], input: vec![TxIn::default()],
output: vec![], output: vec![],