Merge rust-bitcoin/rust-bitcoin#3450: Add version three variant to transaction version
9e6b8faf84
feat: add version three variant to transaction version (Rob N) Pull request description: Topologically restricted transactions are now considered standard as of Bitcoin 28.0. ACKs for top commit: apoelstra: ACK9e6b8faf84
successfully ran local tests tcharding: ACK9e6b8faf84
Tree-SHA512: 289b986304e206802f04cee6607087167f6d91d8a81d4fc49ed01c430f4f6ad00b44646fbefdd000148fc5bfe2d257f92b386bfaf4405c482e4e438d830ab586
This commit is contained in:
commit
65e290a0ce
|
@ -342,7 +342,7 @@ fn size_from_script_pubkey(script_pubkey: &Script) -> usize {
|
|||
#[derive(Clone, PartialEq, Eq, Debug, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Transaction {
|
||||
/// The protocol version, is currently expected to be 1 or 2 (BIP 68).
|
||||
/// The protocol version, is currently expected to be 1, 2 (BIP 68) or 3 (BIP 431).
|
||||
pub version: Version,
|
||||
/// Block height or timestamp. Transaction cannot be included in a block until this height/time.
|
||||
///
|
||||
|
@ -796,7 +796,7 @@ crate::internal_macros::define_extension_trait! {
|
|||
fn non_standard(version: i32) -> Version { Self(version) }
|
||||
|
||||
/// Returns true if this transaction version number is considered standard.
|
||||
fn is_standard(&self) -> bool { *self == Version::ONE || *self == Version::TWO }
|
||||
fn is_standard(&self) -> bool { *self == Version::ONE || *self == Version::TWO || *self == Version::THREE }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -172,13 +172,14 @@ impl Wtxid {
|
|||
|
||||
/// The transaction version.
|
||||
///
|
||||
/// Currently, as specified by [BIP-68], only version 1 and 2 are considered standard.
|
||||
/// Currently, as specified by [BIP-68] and [BIP-431], version 1, 2, and 3 are considered standard.
|
||||
///
|
||||
/// Standardness of the inner `i32` is not an invariant because you are free to create transactions
|
||||
/// of any version, transactions with non-standard version numbers will not be relayed by the
|
||||
/// Bitcoin network.
|
||||
///
|
||||
/// [BIP-68]: https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki
|
||||
/// [BIP-431]: https://github.com/bitcoin/bips/blob/master/bip-0431.mediawiki
|
||||
#[derive(Copy, PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
pub struct Version(pub i32);
|
||||
|
@ -189,6 +190,9 @@ impl Version {
|
|||
|
||||
/// The second Bitcoin transaction version (post-BIP-68).
|
||||
pub const TWO: Self = Self(2);
|
||||
|
||||
/// The third Bitcoin transaction version (post-BIP-431).
|
||||
pub const THREE: Self = Self(3);
|
||||
}
|
||||
|
||||
impl fmt::Display for Version {
|
||||
|
@ -206,10 +210,11 @@ impl<'a> Arbitrary<'a> for OutPoint {
|
|||
impl<'a> Arbitrary<'a> for Version {
|
||||
fn arbitrary(u: &mut Unstructured<'a>) -> arbitrary::Result<Self> {
|
||||
// Equally weight the case of normal version numbers
|
||||
let choice = u.int_in_range(0..=2)?;
|
||||
let choice = u.int_in_range(0..=3)?;
|
||||
match choice {
|
||||
0 => Ok(Version::ONE),
|
||||
1 => Ok(Version::TWO),
|
||||
2 => Ok(Version::THREE),
|
||||
_ => Ok(Version(u.arbitrary()?)),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue