pub struct ControlBlock {
pub leaf_version: LeafVersion,
pub output_key_parity: Parity,
pub internal_key: UntweakedPublicKey,
pub merkle_branch: TaprootMerkleBranch,
}Expand description
Control Block data structure used in Tapscript satisfaction
Fields§
§leaf_version: LeafVersionThe tapleaf version,
output_key_parity: ParityThe parity of the output key (NOT THE INTERNAL KEY WHICH IS ALWAYS XONLY)
internal_key: UntweakedPublicKeyThe internal key
merkle_branch: TaprootMerkleBranchThe merkle proof of a script associated with this leaf
Implementations§
Source§impl ControlBlock
impl ControlBlock
Sourcepub fn from_slice(sl: &[u8]) -> Result<ControlBlock, TaprootError>
pub fn from_slice(sl: &[u8]) -> Result<ControlBlock, TaprootError>
Obtain a ControlBlock from slice. This is an extra witness element
that provides the proof that taproot script pubkey is correctly computed
with some specified leaf hash. This is the last element in
taproot witness when spending a output via script path.
§Errors:
- If the control block size is not of the form 33 + 32m where
0 <= m <= 128,
InvalidControlBlockis returned
Sourcepub fn size(&self) -> usize
pub fn size(&self) -> usize
Obtain the size of control block. Faster and more efficient than calling
serialize() followed by len(). Can be handy for fee estimation
Sourcepub fn encode<Write: Write>(&self, writer: Write) -> Result<usize>
pub fn encode<Write: Write>(&self, writer: Write) -> Result<usize>
Serialize to a writer. Returns the number of bytes written
Sourcepub fn serialize(&self) -> Vec<u8> ⓘ
pub fn serialize(&self) -> Vec<u8> ⓘ
Serialize the control block. This would be required when
using ControlBlock as a witness element while spending an output via
script path. This serialization does not include the VarInt prefix that would be
applied when encoding this element as a witness.
Sourcepub fn verify_taproot_commitment<C: Verification>(
&self,
secp: &Secp256k1<C>,
output_key: &TweakedPublicKey,
script: &Script,
) -> bool
pub fn verify_taproot_commitment<C: Verification>( &self, secp: &Secp256k1<C>, output_key: &TweakedPublicKey, script: &Script, ) -> bool
Verify that a control block is correct proof for a given output key and script This only checks that script is contained inside the taptree described by output key, full verification must also execute the script with witness data
Trait Implementations§
Source§impl Clone for ControlBlock
impl Clone for ControlBlock
Source§fn clone(&self) -> ControlBlock
fn clone(&self) -> ControlBlock
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ControlBlock
impl Debug for ControlBlock
Source§impl Deserialize for ControlBlock
impl Deserialize for ControlBlock
impl Eq for ControlBlock
Source§impl Hash for ControlBlock
impl Hash for ControlBlock
Source§impl Ord for ControlBlock
impl Ord for ControlBlock
Source§fn cmp(&self, other: &ControlBlock) -> Ordering
fn cmp(&self, other: &ControlBlock) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ControlBlock
impl PartialEq for ControlBlock
Source§fn eq(&self, other: &ControlBlock) -> bool
fn eq(&self, other: &ControlBlock) -> bool
self and other values to be equal, and is used by ==.