Move transaction::Version to primitives
We would like to move the `Transaction` type to `primitives`, as a step towards this move the `transaction::Version` and its trait imps (just `Display`) over there.
This commit is contained in:
parent
f490222068
commit
c48d9d6523
|
@ -31,6 +31,10 @@ use crate::sighash::{EcdsaSighashType, TapSighashType};
|
||||||
use crate::witness::Witness;
|
use crate::witness::Witness;
|
||||||
use crate::{Amount, FeeRate, SignedAmount, VarInt};
|
use crate::{Amount, FeeRate, SignedAmount, VarInt};
|
||||||
|
|
||||||
|
#[rustfmt::skip] // Keep public re-exports separate.
|
||||||
|
#[doc(inline)]
|
||||||
|
pub use primitives::transaction::*;
|
||||||
|
|
||||||
hashes::hash_newtype! {
|
hashes::hash_newtype! {
|
||||||
/// A bitcoin transaction hash/transaction ID.
|
/// A bitcoin transaction hash/transaction ID.
|
||||||
///
|
///
|
||||||
|
@ -925,27 +929,6 @@ impl std::error::Error for IndexOutOfBoundsError {
|
||||||
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
|
fn source(&self) -> Option<&(dyn std::error::Error + 'static)> { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The transaction version.
|
|
||||||
///
|
|
||||||
/// Currently, as specified by [BIP-68], only version 1 and 2 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
|
|
||||||
#[derive(Copy, PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)]
|
|
||||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
||||||
pub struct Version(pub i32);
|
|
||||||
|
|
||||||
impl Version {
|
|
||||||
/// The original Bitcoin transaction version (pre-BIP-68).
|
|
||||||
pub const ONE: Self = Self(1);
|
|
||||||
|
|
||||||
/// The second Bitcoin transaction version (post-BIP-68).
|
|
||||||
pub const TWO: Self = Self(2);
|
|
||||||
}
|
|
||||||
|
|
||||||
crate::internal_macros::define_extension_trait! {
|
crate::internal_macros::define_extension_trait! {
|
||||||
/// Extension functionality for the [`Version`] type.
|
/// Extension functionality for the [`Version`] type.
|
||||||
pub trait VersionExt impl for Version {
|
pub trait VersionExt impl for Version {
|
||||||
|
@ -969,10 +952,6 @@ impl Decodable for Version {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for Version {
|
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
|
|
||||||
}
|
|
||||||
|
|
||||||
impl_consensus_encoding!(TxOut, value, script_pubkey);
|
impl_consensus_encoding!(TxOut, value, script_pubkey);
|
||||||
|
|
||||||
impl Encodable for OutPoint {
|
impl Encodable for OutPoint {
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub mod locktime;
|
||||||
pub mod opcodes;
|
pub mod opcodes;
|
||||||
pub mod pow;
|
pub mod pow;
|
||||||
pub mod sequence;
|
pub mod sequence;
|
||||||
|
pub mod transaction;
|
||||||
|
|
||||||
#[doc(inline)]
|
#[doc(inline)]
|
||||||
pub use units::*;
|
pub use units::*;
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
// SPDX-License-Identifier: CC0-1.0
|
||||||
|
|
||||||
|
//! Bitcoin transactions.
|
||||||
|
//!
|
||||||
|
//! A transaction describes a transfer of money. It consumes previously-unspent
|
||||||
|
//! transaction outputs and produces new ones, satisfying the condition to spend
|
||||||
|
//! the old outputs (typically a digital signature with a specific key must be
|
||||||
|
//! provided) and defining the condition to spend the new ones. The use of digital
|
||||||
|
//! signatures ensures that coins cannot be spent by unauthorized parties.
|
||||||
|
//!
|
||||||
|
//! This module provides the structures and functions needed to support transactions.
|
||||||
|
|
||||||
|
use core::fmt;
|
||||||
|
|
||||||
|
/// The transaction version.
|
||||||
|
///
|
||||||
|
/// Currently, as specified by [BIP-68], only version 1 and 2 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
|
||||||
|
#[derive(Copy, PartialEq, Eq, Clone, Debug, PartialOrd, Ord, Hash)]
|
||||||
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||||
|
pub struct Version(pub i32);
|
||||||
|
|
||||||
|
impl Version {
|
||||||
|
/// The original Bitcoin transaction version (pre-BIP-68).
|
||||||
|
pub const ONE: Self = Self(1);
|
||||||
|
|
||||||
|
/// The second Bitcoin transaction version (post-BIP-68).
|
||||||
|
pub const TWO: Self = Self(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
impl fmt::Display for Version {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fmt::Display::fmt(&self.0, f) }
|
||||||
|
}
|
Loading…
Reference in New Issue