[][src]Struct bitcoin_bech32::WitnessProgram

pub struct WitnessProgram { /* fields omitted */ }

Witness version and program data

Methods

impl WitnessProgram[src]

pub fn new(
    version: u5,
    program: Vec<u8>,
    network: Network
) -> Result<WitnessProgram, Error>
[src]

Construct a new WitnessProgram given the constituent version, witness program and network version

pub fn to_address(&self) -> String[src]

Converts a Witness Program to a SegWit Address

pub fn from_address(address: &str) -> Result<WitnessProgram, Error>[src]

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

pub fn to_scriptpubkey(&self) -> Vec<u8>[src]

Converts a WitnessProgram to a script public key

The format for the output is [version, program length, <program>]

pub fn from_scriptpubkey(
    pubkey: &[u8],
    network: Network
) -> Result<WitnessProgram, Error>
[src]

Extracts a WitnessProgram out of a provided script public key

pub fn validate(&self) -> Result<(), Error>[src]

Validates the WitnessProgram against version and length constraints

pub fn version(&self) -> u5[src]

Witness program version

pub fn program(&self) -> &[u8][src]

Witness program serialized as 8-bit bytes

pub fn network(&self) -> Network[src]

Which network this witness program is intended to be run on

Trait Implementations

impl Eq for WitnessProgram[src]

impl Ord for WitnessProgram[src]

fn max(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self
1.21.0
[src]

Compares and returns the minimum of two values. Read more

impl Clone for WitnessProgram[src]

fn clone_from(&mut self, source: &Self)
1.0.0
[src]

Performs copy-assignment from source. Read more

impl PartialEq<WitnessProgram> for WitnessProgram[src]

impl PartialOrd<WitnessProgram> for WitnessProgram[src]

impl ToString for WitnessProgram[src]

impl Hash for WitnessProgram[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0
[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for WitnessProgram[src]

impl FromStr for WitnessProgram[src]

type Err = Error

The associated error which can be returned from parsing.

Auto Trait Implementations

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

impl<T> From for T[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom for T where
    U: Into<T>, 
[src]

type Error = !

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Borrow for T where
    T: ?Sized
[src]

impl<T> BorrowMut for T where
    T: ?Sized
[src]

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

impl<T> Any for T where
    T: 'static + ?Sized
[src]