pub struct Address {
pub payload: Payload,
pub network: Network,
pub prefix_bech32_mainnet: String,
pub prefix_bech32_testnet: String,
pub version_pubkeyhash_mainnet: Vec<u8>,
pub version_pubkeyhash_testnet: Vec<u8>,
pub version_scripthash_mainnet: Vec<u8>,
pub version_scripthash_testnet: Vec<u8>,
}
Expand description
A Bitcoin address
Fields§
§payload: Payload
The type of the address
network: Network
The network on which this address is usable
prefix_bech32_mainnet: String
Bech32 mainnet prefix
prefix_bech32_testnet: String
Bech32 testnet prefix
version_pubkeyhash_mainnet: Vec<u8>
Checksum: Mainnet Pubkey Hash address
version_pubkeyhash_testnet: Vec<u8>
Checksum: Testnet Pubkey Hash address
version_scripthash_mainnet: Vec<u8>
Checksum: Mainnet Script Hash address
version_scripthash_testnet: Vec<u8>
Checksum: Testnet Script Hash address
Implementations§
Source§impl Address
impl Address
Sourcepub fn p2pkh(
self,
secp: &Secp256k1,
pk: &PublicKey,
network: Network,
) -> Address
pub fn p2pkh( self, secp: &Secp256k1, 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(self, script: &Script, network: Network) -> Address
pub fn p2sh(self, 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(
self,
secp: &Secp256k1,
pk: &PublicKey,
network: Network,
) -> Result<Address, Error>
pub fn p2wpkh( self, secp: &Secp256k1, 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(
self,
secp: &Secp256k1,
pk: &PublicKey,
network: Network,
) -> Result<Address, Error>
pub fn p2shwpkh( self, secp: &Secp256k1, 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(self, script: &Script, network: Network) -> Address
pub fn p2wsh(self, script: &Script, network: Network) -> Address
Create a witness pay to script hash address
Sourcepub fn p2shwsh(self, script: &Script, network: Network) -> Address
pub fn p2shwsh(self, 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(self, script: &Script, network: Network) -> Option<Address>
pub fn from_script(self, 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