From b757924d7c7b1a94ddc886fd54462af9755a9dcc Mon Sep 17 00:00:00 2001 From: Dr Maxim Orlovsky Date: Fri, 6 Oct 2023 13:17:25 +0200 Subject: [PATCH] primitives: add LeafScript constructors --- primitives/src/taproot.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/primitives/src/taproot.rs b/primitives/src/taproot.rs index 2fc4b5a0..7ab9eeda 100644 --- a/primitives/src/taproot.rs +++ b/primitives/src/taproot.rs @@ -417,7 +417,18 @@ impl From 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) -> Result { + 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) } }