diff --git a/consensus/src/taproot.rs b/consensus/src/taproot.rs index 46c25f19..9b999474 100644 --- a/consensus/src/taproot.rs +++ b/consensus/src/taproot.rs @@ -165,6 +165,7 @@ impl InternalPk { XOnlyPk::from_byte_array(data).map(Self) } + #[inline] pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result> { XOnlyPk::from_bytes(bytes).map(Self) } @@ -172,6 +173,9 @@ impl InternalPk { #[inline] pub fn to_byte_array(&self) -> [u8; 32] { self.0.to_byte_array() } + #[inline] + pub fn to_xonly_pk(&self) -> XOnlyPk { self.0 } + pub fn to_output_pk(&self, merkle_root: Option) -> (OutputPk, Parity) { let mut engine = Sha256::from_tag(MIDSTATE_TAPTWEAK); // always hash the key @@ -223,10 +227,15 @@ impl OutputPk { XOnlyPk::from_byte_array(data).map(Self) } + #[inline] pub fn from_bytes(bytes: impl AsRef<[u8]>) -> Result> { XOnlyPk::from_bytes(bytes).map(Self) } + #[inline] + pub fn to_xonly_pk(&self) -> XOnlyPk { self.0 } + + #[inline] pub fn to_script_pubkey(&self) -> ScriptPubkey { ScriptPubkey::p2tr_tweaked(*self) } #[inline]