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:
Tobin C. Harding 2024-09-19 14:14:42 +10:00
parent 7e5bd5048d
commit f5c46cd411
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
2 changed files with 14 additions and 14 deletions

View File

@ -404,6 +404,7 @@ mod test {
use crate::consensus::encode::{deserialize, serialize};
use crate::locktime::absolute;
use crate::merkle_tree::TxMerkleNode;
use crate::transaction::OutPointExt;
use crate::{
transaction, Amount, CompactTarget, OutPoint, ScriptBuf, Sequence, TxIn, TxOut, Txid,
Witness,

View File

@ -99,21 +99,20 @@ impl OutPoint {
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`].
#[inline]
#[deprecated(since = "TBD", note = "use struct initialization syntax instead")]
pub const fn new(txid: Txid, vout: u32) -> OutPoint { OutPoint { txid, vout } }
/// Creates a "null" `OutPoint`.
#[inline]
#[deprecated(since = "TBD", note = "use OutPoint::COINBASE_PREVOUT instead")]
pub fn null() -> OutPoint { Self::COINBASE_PREVOUT }
#[allow(clippy::new-ret-no-self)]
fn new(txid: Txid, vout: u32) -> Self { OutPoint { txid, vout } }
/// Checks if an `OutPoint` is "null".
#[inline]
#[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 {