Struct ControlBlock
pub struct ControlBlock {
pub leaf_version: LeafVersion,
pub output_key_parity: Parity,
pub internal_key: XOnlyPublicKey,
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: XOnlyPublicKeyThe internal key.
merkle_branch: TaprootMerkleBranchThe merkle proof of a script associated with this leaf.
Implementations§
§impl ControlBlock
impl ControlBlock
pub fn decode(sl: &[u8]) -> Result<ControlBlock, TaprootError>
pub fn decode(sl: &[u8]) -> Result<ControlBlock, TaprootError>
Decodes bytes representing a ControlBlock.
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
TaprootError::InvalidControlBlockSizeifslis not of size 1 + 32 + 32N for any N >= 0.TaprootError::InvalidTaprootLeafVersionif first byte ofslis not a valid leaf version.TaprootError::InvalidInternalKeyif internal key is invalid (first 32 bytes after the parity byte).TaprootError::InvalidMerkleTreeDepthif merkle tree is too deep (more than 128 levels).
pub fn size(&self) -> usize
pub fn size(&self) -> usize
Returns the size of control block. Faster and more efficient than calling
Self::serialize().len(). Can be handy for fee estimation.
pub fn serialize(&self) -> Vec<u8> ⓘ
pub fn serialize(&self) -> Vec<u8> ⓘ
Serializes 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 crate::VarInt prefix that would
be applied when encoding this element as a witness.
pub fn verify_taproot_commitment<C>(
&self,
secp: &Secp256k1<C>,
output_key: XOnlyPublicKey,
script: &Script,
) -> boolwhere
C: Verification,
pub fn verify_taproot_commitment<C>(
&self,
secp: &Secp256k1<C>,
output_key: XOnlyPublicKey,
script: &Script,
) -> boolwhere
C: Verification,
Verifies that a control block is correct proof for a given output key and script.
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§
§impl Clone for ControlBlock
impl Clone for ControlBlock
§fn clone(&self) -> ControlBlock
fn clone(&self) -> ControlBlock
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for ControlBlock
impl Debug for ControlBlock
§impl<'de> Deserialize<'de> for ControlBlock
impl<'de> Deserialize<'de> for ControlBlock
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ControlBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ControlBlock, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Hash for ControlBlock
impl Hash for ControlBlock
§impl Ord for ControlBlock
impl Ord for ControlBlock
§impl PartialEq for ControlBlock
impl PartialEq for ControlBlock
§impl PartialOrd for ControlBlock
impl PartialOrd for ControlBlock
§impl Serialize for ControlBlock
impl Serialize for ControlBlock
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Eq for ControlBlock
impl StructuralPartialEq for ControlBlock
Auto Trait Implementations§
impl Freeze for ControlBlock
impl RefUnwindSafe for ControlBlock
impl Send for ControlBlock
impl Sync for ControlBlock
impl Unpin for ControlBlock
impl UnwindSafe for ControlBlock
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
§impl<T> AnySync for T
impl<T> AnySync for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request