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: LeafVersion
The tapleaf version,
output_key_parity: Parity
The parity of the output key (NOT THE INTERNAL KEY WHICH IS ALWAYS XONLY)
internal_key: UntweakedPublicKey
The internal key
merkle_branch: TaprootMerkleBranch
The merkle proof of a script associated with this leaf
Implementations
sourceimpl 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, InvalidControlBlock is 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>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn serialize(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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: XOnlyPublicKey,
script: &Script
) -> bool
pub fn verify_taproot_commitment<C: Verification>(
&self,
secp: &Secp256k1<C>,
output_key: XOnlyPublicKey,
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
sourceimpl Clone for ControlBlock
impl Clone for ControlBlock
sourcefn clone(&self) -> ControlBlock
fn clone(&self) -> ControlBlock
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ControlBlock
impl Debug for ControlBlock
sourceimpl Deserialize for ControlBlock
impl Deserialize for ControlBlock
sourceimpl<'de> Deserialize<'de> for ControlBlock
impl<'de> Deserialize<'de> for ControlBlock
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Hash for ControlBlock
impl Hash for ControlBlock
sourceimpl Ord for ControlBlock
impl Ord for ControlBlock
sourceimpl PartialEq<ControlBlock> for ControlBlock
impl PartialEq<ControlBlock> for ControlBlock
sourcefn eq(&self, other: &ControlBlock) -> bool
fn eq(&self, other: &ControlBlock) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &ControlBlock) -> bool
fn ne(&self, other: &ControlBlock) -> bool
This method tests for !=
.
sourceimpl PartialOrd<ControlBlock> for ControlBlock
impl PartialOrd<ControlBlock> for ControlBlock
sourcefn partial_cmp(&self, other: &ControlBlock) -> Option<Ordering>
fn partial_cmp(&self, other: &ControlBlock) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl Serialize for ControlBlock
impl Serialize for ControlBlock
sourceimpl Serialize for ControlBlock
impl Serialize for ControlBlock
impl Eq for ControlBlock
impl StructuralEq for ControlBlock
impl StructuralPartialEq for ControlBlock
Auto Trait Implementations
impl RefUnwindSafe for ControlBlock
impl Send for ControlBlock
impl Sync for ControlBlock
impl Unpin for ControlBlock
impl UnwindSafe for ControlBlock
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more