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 const fn p2a() -> Self
Available on rust_v_1_61 only.
pub const fn p2a() -> Self
rust_v_1_61 only.Constructs a new pay to anchor address
Note: the function is only const in Rust
1.61
.
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 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 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 for WitnessProgram
impl PartialEq for WitnessProgram
Source§impl PartialOrd for WitnessProgram
impl PartialOrd for WitnessProgram
impl Copy for WitnessProgram
impl Eq for WitnessProgram
impl StructuralPartialEq for WitnessProgram
Auto Trait Implementations§
impl Freeze for WitnessProgram
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