Skip to content

Commit

Permalink
primitives: add LeafScript constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
dr-orlovsky committed Oct 6, 2023
1 parent 8efffe9 commit b757924
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions primitives/src/taproot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,18 @@ impl From<TapScript> for LeafScript {
}

impl LeafScript {
#[inline]
pub fn new(version: LeafVer, script: ScriptBytes) -> Self { LeafScript { version, script } }
#[inline]
pub fn with_bytes(version: LeafVer, script: Vec<u8>) -> Result<Self, confinement::Error> {
Ok(LeafScript {
version,
script: ScriptBytes::from(script),
})
}
#[inline]
pub fn from_tap_script(tap_script: TapScript) -> Self { Self::from(tap_script) }
#[inline]
pub fn tap_leaf_hash(&self) -> TapLeafHash { TapLeafHash::with_leaf_script(self) }
}

Expand Down

0 comments on commit b757924

Please sign in to comment.