Struct elements::address::Address

source ·
pub struct Address {
    pub params: &'static AddressParams,
    pub payload: Payload,
    pub blinding_pubkey: Option<PublicKey>,
}
Expand description

An Elements address.

Fields§

§params: &'static AddressParams

the network

§payload: Payload

the traditional non-confidential payload

§blinding_pubkey: Option<PublicKey>

the blinding pubkey

Implementations§

source§

impl Address

source

pub fn is_blinded(&self) -> bool

Inspect if the address is a blinded address.

source

pub fn p2pkh( pk: &PublicKey, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Creates a pay to (compressed) public key hash address from a public key This is the preferred non-witness type address

source

pub fn p2sh( script: &Script, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Creates a pay to script hash P2SH address from a script This address type was introduced with BIP16 and is the popular type to implement multi-sig these days.

source

pub fn p2wpkh( pk: &PublicKey, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Create a witness pay to public key address from a public key This is the native segwit address type for an output redeemable with a single signature

source

pub fn p2shwpkh( pk: &PublicKey, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Create a pay to script address that embeds a witness pay to public key This is a segwit address type that looks familiar (as p2sh) to legacy clients

source

pub fn p2wsh( script: &Script, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Create a witness pay to script hash address

source

pub fn p2shwsh( script: &Script, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Create a pay to script address that embeds a witness pay to script hash address This is a segwit address type that looks familiar (as p2sh) to legacy clients

source

pub fn p2tr<C: Verification>( secp: &Secp256k1<C>, internal_key: UntweakedPublicKey, merkle_root: Option<TapBranchHash>, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Creates a pay to taproot address from an untweaked key.

source

pub fn p2tr_tweaked( output_key: TweakedPublicKey, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Address

Creates a pay to taproot address from a pre-tweaked output key.

This method is not recommended for use, Address::p2tr() should be used where possible.

source

pub fn from_script( script: &Script, blinder: Option<PublicKey>, params: &'static AddressParams ) -> Option<Address>

Get an Address from an output script.

source

pub fn script_pubkey(&self) -> Script

Generates a script pubkey spending to this address

source

pub fn to_unconfidential(&self) -> Address

Convert this address to an unconfidential address.

source

pub fn to_confidential(&self, blinding_pubkey: PublicKey) -> Address

Convert this address to a confidential address with the given blinding pubkey.

source

pub fn parse_with_params( s: &str, params: &'static AddressParams ) -> Result<Address, AddressError>

Parse the address using the given parameters. When using the built-in parameters, you can use FromStr.

Trait Implementations§

source§

impl Clone for Address

source§

fn clone(&self) -> Address

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Address

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for Address

source§

fn fmt(&self, fmt: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl FromStr for Address

§

type Err = AddressError

The associated error which can be returned from parsing.
source§

fn from_str(s: &str) -> Result<Address, AddressError>

Parses a string s to return a value of this type. Read more
source§

impl Hash for Address

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Address

source§

fn cmp(&self, other: &Address) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Selfwhere Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Selfwhere Self: Sized + PartialOrd<Self>,

Restrict a value to a certain interval. Read more
source§

impl PartialEq<Address> for Address

source§

fn eq(&self, other: &Address) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd<Address> for Address

source§

fn partial_cmp(&self, other: &Address) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Eq for Address

source§

impl StructuralEq for Address

source§

impl StructuralPartialEq for Address

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V