Module address
Expand description
Bitcoin addresses.
Support for ordinary base58 Bitcoin addresses and private keys.
§Example: creating a new address from a randomly-generated key pair
use bitcoin::{Address, PublicKey, Network};
use bitcoin::secp256k1::{rand, Secp256k1};
// Generate random key pair.
let s = Secp256k1::new();
let public_key = PublicKey::new(s.generate_keypair(&mut rand::thread_rng()).1);
// Generate pay-to-pubkey-hash address.
let address = Address::p2pkh(&public_key, Network::Bitcoin);
§Note: creating a new address requires the rand-std feature flag
bitcoin = { version = "...", features = ["rand-std"] }
Modules§
- error
- Error code for the address module.
Structs§
- Address
- A Bitcoin address.
- Invalid
Base58 Payload Length Error - Decoded base58 data was an invalid length.
- Invalid
Legacy Prefix Error - Invalid legacy address prefix in decoded base58 data.
- Legacy
Address TooLong Error - Legacy base58 address was too long, max 50 characters.
- Network
Validation Error - Address’s network differs from required one.
- Unknown
Address Type Error - Address type is either invalid or not supported in rust-bitcoin.
- Unknown
HrpError - Unknown HRP error.
Enums§
- Address
Data - The data encoded by an
Address
. - Address
Type - The different types of addresses.
- From
Script Error - Error while generating address from script.
- Known
Hrp - Known bech32 human-readable parts.
- Network
Checked - Marker that address’s network has been successfully validated. See section Parsing addresses
on
Address
for details. - Network
Unchecked - Marker that address’s network has not yet been validated. See section Parsing addresses
on
Address
for details. - P2sh
Error - Error while generating address from a p2sh script.
- Parse
Error - Address parsing error.
Traits§
- Network
Validation - Marker of status of address’s network validation. See section Parsing addresses
on
Address
for details.