Struct bitcoin::WitnessProgram
source · pub struct WitnessProgram { /* private fields */ }
Expand description
The segregated witness program.
The segregated witness program is technically only the program bytes excluding the witness
version, however we maintain length invariants on the program
that are governed by the version
number, therefore we carry the version number around along with the program bytes.
Implementations§
source§impl WitnessProgram
impl WitnessProgram
sourcepub fn new(version: WitnessVersion, bytes: &[u8]) -> Result<Self, Error>
pub fn new(version: WitnessVersion, bytes: &[u8]) -> Result<Self, Error>
Creates a new witness program, copying the content from the given byte slice.
sourcepub fn p2wpkh(pk: &CompressedPublicKey) -> Self
pub fn p2wpkh(pk: &CompressedPublicKey) -> Self
Creates a WitnessProgram
from pk
for a P2WPKH output.
sourcepub fn p2wsh(script: &Script) -> Self
pub fn p2wsh(script: &Script) -> Self
Creates a WitnessProgram
from script
for a P2WSH output.
sourcepub fn p2tr<C: Verification>(
secp: &Secp256k1<C>,
internal_key: UntweakedPublicKey,
merkle_root: Option<TapNodeHash>
) -> Self
pub fn p2tr<C: Verification>( secp: &Secp256k1<C>, internal_key: UntweakedPublicKey, merkle_root: Option<TapNodeHash> ) -> Self
Creates a pay to taproot address from an untweaked key.
sourcepub fn p2tr_tweaked(output_key: TweakedPublicKey) -> Self
pub fn p2tr_tweaked(output_key: TweakedPublicKey) -> Self
Creates a pay to taproot address from a pre-tweaked output key.
sourcepub fn version(&self) -> WitnessVersion
pub fn version(&self) -> WitnessVersion
Returns the witness program version.
Trait Implementations§
source§impl Clone for WitnessProgram
impl Clone for WitnessProgram
source§fn clone(&self) -> WitnessProgram
fn clone(&self) -> WitnessProgram
Returns a copy 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 moresource§impl Debug for WitnessProgram
impl Debug for WitnessProgram
source§impl Hash for WitnessProgram
impl Hash for WitnessProgram
source§impl Ord for WitnessProgram
impl Ord for WitnessProgram
source§fn cmp(&self, other: &WitnessProgram) -> Ordering
fn cmp(&self, other: &WitnessProgram) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere Self: Sized,
Compares and returns the maximum of two values. Read more
source§impl PartialEq<WitnessProgram> for WitnessProgram
impl PartialEq<WitnessProgram> for WitnessProgram
source§fn eq(&self, other: &WitnessProgram) -> bool
fn eq(&self, other: &WitnessProgram) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd<WitnessProgram> for WitnessProgram
impl PartialOrd<WitnessProgram> for WitnessProgram
source§fn partial_cmp(&self, other: &WitnessProgram) -> Option<Ordering>
fn partial_cmp(&self, other: &WitnessProgram) -> Option<Ordering>
1.0.0 · source§fn 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 moreimpl Copy for WitnessProgram
impl Eq for WitnessProgram
impl StructuralEq for WitnessProgram
impl StructuralPartialEq for WitnessProgram
Auto Trait Implementations§
impl RefUnwindSafe for WitnessProgram
impl Send for WitnessProgram
impl Sync for WitnessProgram
impl Unpin for WitnessProgram
impl UnwindSafe for WitnessProgram
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