Skip to content

Commit

Permalink
primitives: add Outpoint::vout_u32 convenience method
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Sep 19, 2023
1 parent 0453d78 commit 6b2e0da
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions primitives/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ impl FromHex for Txid {
pub struct Vout(u32);

impl Vout {
#[inline]
pub fn into_u32(self) -> u32 { self.0 }
}

impl FromStr for Vout {
type Err = ParseIntError;

#[inline]
fn from_str(s: &str) -> Result<Self, Self::Err> { s.parse().map(Self) }
}

Expand All @@ -92,12 +94,16 @@ pub struct Outpoint {
}

impl Outpoint {
#[inline]
pub fn new(txid: Txid, vout: impl Into<Vout>) -> Self {
Self {
txid,
vout: vout.into(),
}
}

#[inline]
pub fn vout_u32(self) -> u32 { self.vout.into_u32() }
}

#[derive(Clone, Eq, PartialEq, Debug, Display, From, Error)]
Expand Down

0 comments on commit 6b2e0da

Please sign in to comment.