Skip to main content

Address

Struct 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 is_liquid(&self) -> bool

Return if the address is for the Liquid network

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<TapNodeHash>, 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 duplicate of the value. Read more
1.0.0 (const: unstable) · 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 Eq for Address

Source§

impl FromStr for Address

Source§

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 PartialEq for Address

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Address

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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 T
where T: Clone,

Source§

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 T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

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

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

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

Source§

fn vzip(self) -> V