pub struct ControlBlock {
pub leaf_version_and_parity: u8,
pub internal_key: [u8; 32],
pub merkle_path: Vec<[u8; 32]>,
}Expand description
A BIP-341 control block for script-path spending.
Fields§
§leaf_version_and_parity: u8The leaf version (high 7 bits) combined with parity bit (low bit).
internal_key: [u8; 32]The 32-byte x-only internal public key.
merkle_path: Vec<[u8; 32]>The merkle proof path (0 to 128 hashes of 32 bytes each).
Implementations§
Source§impl ControlBlock
impl ControlBlock
Sourcepub fn new(
internal_key: [u8; 32],
tree: &TapTree,
leaf: &TapLeaf,
output_key_parity: bool,
) -> Option<Self>
pub fn new( internal_key: [u8; 32], tree: &TapTree, leaf: &TapLeaf, output_key_parity: bool, ) -> Option<Self>
Create a control block for a specific leaf in a tree.
§Arguments
internal_key- The 32-byte x-only internal public keytree- The TapTreeleaf- The target leaf to create a proof foroutput_key_parity- Whether the output key Q has odd y
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Serialize the control block to bytes.
Format: control_byte || internal_key (32) || merkle_path (32 * m)
Sourcepub fn from_bytes(data: &[u8]) -> Option<Self>
pub fn from_bytes(data: &[u8]) -> Option<Self>
Parse a control block from bytes.
Trait Implementations§
Source§impl Clone for ControlBlock
impl Clone for ControlBlock
Source§fn clone(&self) -> ControlBlock
fn clone(&self) -> ControlBlock
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ControlBlock
impl RefUnwindSafe for ControlBlock
impl Send for ControlBlock
impl Sync for ControlBlock
impl Unpin for ControlBlock
impl UnsafeUnpin for ControlBlock
impl UnwindSafe for ControlBlock
Blanket Implementations§
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
Mutably borrows from an owned value. Read more