pub struct Address {
pub payload: Payload,
pub network: Network,
}Expand description
A Bitcoin address
Fields§
§payload: PayloadThe type of the address
network: NetworkThe network on which this address is usable
Implementations§
Source§impl Address
impl Address
Sourcepub fn p2pkh(pk: &PublicKey, network: Network) -> Address
pub fn p2pkh(pk: &PublicKey, network: Network) -> Address
Creates a pay to (compressed) public key hash address from a public key This is the preferred non-witness type address
Sourcepub fn p2sh(script: &Script, network: Network) -> Address
pub fn p2sh(script: &Script, network: Network) -> 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.
Sourcepub fn p2wpkh(pk: &PublicKey, network: Network) -> Result<Address, Error>
pub fn p2wpkh(pk: &PublicKey, network: Network) -> Result<Address, Error>
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
Will only return an Error when an uncompressed public key is provided.
Sourcepub fn p2shwpkh(pk: &PublicKey, network: Network) -> Result<Address, Error>
pub fn p2shwpkh(pk: &PublicKey, network: Network) -> Result<Address, Error>
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
Will only return an Error when an uncompressed public key is provided.
Sourcepub fn p2wsh(script: &Script, network: Network) -> Address
pub fn p2wsh(script: &Script, network: Network) -> Address
Create a witness pay to script hash address
Sourcepub fn p2shwsh(script: &Script, network: Network) -> Address
pub fn p2shwsh(script: &Script, network: Network) -> 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
Sourcepub fn address_type(&self) -> Option<AddressType>
pub fn address_type(&self) -> Option<AddressType>
Get the address type of the address. None if unknown or non-standard.
Sourcepub fn is_standard(&self) -> bool
pub fn is_standard(&self) -> bool
Check whether or not the address is following Bitcoin standardness rules.
Segwit addresses with unassigned witness versions or non-standard program sizes are considered non-standard.
Sourcepub fn from_script(script: &Script, network: Network) -> Option<Address>
pub fn from_script(script: &Script, network: Network) -> Option<Address>
Get an Address from an output script (scriptPubkey).
Sourcepub fn script_pubkey(&self) -> Script
pub fn script_pubkey(&self) -> Script
Generates a script pubkey spending to this address
Sourcepub fn to_qr_uri(&self) -> String
pub fn to_qr_uri(&self) -> String
Creates a URI string bitcoin:address optimized to be encoded in QR codes.
If the address is bech32, both the schema and the address become uppercase. If the address is base58, the schema is lowercase and the address is left mixed case.
Quoting BIP 173 “inside QR codes uppercase SHOULD be used, as those permit the use of alphanumeric mode, which is 45% more compact than the normal byte mode.”
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Address
impl<'de> Deserialize<'de> for Address
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Address, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Address, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Ord for Address
impl Ord for Address
Source§impl PartialOrd for Address
impl PartialOrd for Address
Source§impl<'de> Serialize for Address
impl<'de> Serialize for Address
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl Eq for Address
impl StructuralPartialEq for Address
Auto Trait Implementations§
impl Freeze for Address
impl RefUnwindSafe for Address
impl Send for Address
impl Sync for Address
impl Unpin for Address
impl UnwindSafe for Address
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more