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"] }

Structs§

Address
A Bitcoin address.
AddressEncoding
A utility struct to encode an address payload with the given parameters. This is a low-level utility struct. Consider using Address instead.
WitnessProgram
Witness program as defined in BIP141.

Enums§

AddressType
The different types of addresses.
Error
Address error.
NetworkChecked
Marker that address’s network has been successfully validated. See section Parsing addresses on Address for details.
NetworkUnchecked
Marker that address’s network has not yet been validated. See section Parsing addresses on Address for details.
Payload
The method used to produce an address.
WitnessVersion
Version of the witness program.

Traits§

NetworkValidation
Marker of status of address’s network validation. See section Parsing addresses on Address for details.