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 p2upkh(pk: &PublicKey, network: Network) -> Address
pub fn p2upkh(pk: &PublicKey, network: Network) -> Address
Creates a pay to uncompressed public key hash address from a public key This address type is discouraged as it uses more space but otherwise equivalent to p2pkh therefore only adds ambiguity
Sourcepub fn p2pk(pk: &PublicKey, network: Network) -> Address
pub fn p2pk(pk: &PublicKey, network: Network) -> Address
Creates a pay to public key address from a public key This address type was used in the early history of Bitcoin. Satoshi’s coins are still on addresses of this type.
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 ty implement multi-sig these days.
Sourcepub fn p2wpkh(pk: &PublicKey, network: Network) -> Address
pub fn p2wpkh(pk: &PublicKey, network: Network) -> 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
Sourcepub fn p2shwpkh(pk: &PublicKey, network: Network) -> Address
pub fn p2shwpkh(pk: &PublicKey, network: Network) -> 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
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 script_pubkey(&self) -> Script
pub fn script_pubkey(&self) -> Script
Generates a script pubkey spending to this address