Struct bitcoin_bech32::WitnessProgram
source · pub struct WitnessProgram { /* private fields */ }
Expand description
Witness version and program data
Implementations§
source§impl WitnessProgram
impl WitnessProgram
sourcepub fn new(
version: u5,
program: Vec<u8>,
network: Network
) -> Result<WitnessProgram, Error>
pub fn new( version: u5, program: Vec<u8>, network: Network ) -> Result<WitnessProgram, Error>
Construct a new WitnessProgram given the constituent version, witness program and network version
sourcepub fn to_address(&self) -> String
pub fn to_address(&self) -> String
Converts a Witness Program to a SegWit Address
sourcepub fn from_address(address: &str) -> Result<WitnessProgram, Error>
pub fn from_address(address: &str) -> Result<WitnessProgram, Error>
Decodes a segwit address into a Witness Program
Verifies that the address
contains a known human-readable part
hrp
and decodes as proper Bech32-encoded string. Allowed values of
the human-readable part correspond to the defined types in constants
sourcepub fn to_scriptpubkey(&self) -> Vec<u8>
pub fn to_scriptpubkey(&self) -> Vec<u8>
Converts a WitnessProgram
to a script public key
The format for the output is
[version, program length, <program>]
sourcepub fn from_scriptpubkey(
pubkey: &[u8],
network: Network
) -> Result<WitnessProgram, Error>
pub fn from_scriptpubkey( pubkey: &[u8], network: Network ) -> Result<WitnessProgram, Error>
Extracts a WitnessProgram out of a provided script public key
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 FromStr for WitnessProgram
impl FromStr 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 more