Introduce OutPoint extension traits
In preparation for moving the `OutPoint` over to `primitives` add an extension trait to hold everything that will stay behind.
This commit is contained in:
parent
7e5bd5048d
commit
f5c46cd411
|
@ -404,6 +404,7 @@ mod test {
|
||||||
use crate::consensus::encode::{deserialize, serialize};
|
use crate::consensus::encode::{deserialize, serialize};
|
||||||
use crate::locktime::absolute;
|
use crate::locktime::absolute;
|
||||||
use crate::merkle_tree::TxMerkleNode;
|
use crate::merkle_tree::TxMerkleNode;
|
||||||
|
use crate::transaction::OutPointExt;
|
||||||
use crate::{
|
use crate::{
|
||||||
transaction, Amount, CompactTarget, OutPoint, ScriptBuf, Sequence, TxIn, TxOut, Txid,
|
transaction, Amount, CompactTarget, OutPoint, ScriptBuf, Sequence, TxIn, TxOut, Txid,
|
||||||
Witness,
|
Witness,
|
||||||
|
|
|
@ -99,21 +99,20 @@ impl OutPoint {
|
||||||
pub const COINBASE_PREVOUT: Self = Self { txid: Txid::COINBASE_PREVOUT, vout: u32::MAX };
|
pub const COINBASE_PREVOUT: Self = Self { txid: Txid::COINBASE_PREVOUT, vout: u32::MAX };
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OutPoint {
|
crate::internal_macros::define_extension_trait! {
|
||||||
|
/// Extension functionality for the [`OutPoint`] type.
|
||||||
|
pub trait OutPointExt impl for OutPoint {
|
||||||
/// Creates a new [`OutPoint`].
|
/// Creates a new [`OutPoint`].
|
||||||
#[inline]
|
#[inline]
|
||||||
#[deprecated(since = "TBD", note = "use struct initialization syntax instead")]
|
#[deprecated(since = "TBD", note = "use struct initialization syntax instead")]
|
||||||
pub const fn new(txid: Txid, vout: u32) -> OutPoint { OutPoint { txid, vout } }
|
#[allow(clippy::new-ret-no-self)]
|
||||||
|
fn new(txid: Txid, vout: u32) -> Self { OutPoint { txid, vout } }
|
||||||
/// Creates a "null" `OutPoint`.
|
|
||||||
#[inline]
|
|
||||||
#[deprecated(since = "TBD", note = "use OutPoint::COINBASE_PREVOUT instead")]
|
|
||||||
pub fn null() -> OutPoint { Self::COINBASE_PREVOUT }
|
|
||||||
|
|
||||||
/// Checks if an `OutPoint` is "null".
|
/// Checks if an `OutPoint` is "null".
|
||||||
#[inline]
|
#[inline]
|
||||||
#[deprecated(since = "TBD", note = "use outpoint == OutPoint::COINBASE_PREVOUT instead")]
|
#[deprecated(since = "TBD", note = "use outpoint == OutPoint::COINBASE_PREVOUT instead")]
|
||||||
pub fn is_null(&self) -> bool { *self == OutPoint::null() }
|
fn is_null(&self) -> bool { *self == OutPoint::COINBASE_PREVOUT }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for OutPoint {
|
impl fmt::Display for OutPoint {
|
||||||
|
|
Loading…
Reference in New Issue