[][src]Module bitcoin::util::address

Addresses

Support for ordinary base58 Bitcoin addresses and private keys

Example: creating a new address from a randomly-generated key pair

extern crate rand;
extern crate secp256k1;
extern crate bitcoin;
 
use bitcoin::network::constants::Network;
use bitcoin::util::address::Address;
use bitcoin::util::key;
use secp256k1::Secp256k1;
use rand::thread_rng;
 
fn main() {
    // Generate random key pair
    let s = Secp256k1::new();
    let public_key = key::PublicKey {
        compressed: true,
        key: s.generate_keypair(&mut thread_rng()).1,
    };
 
    // Generate pay-to-pubkey-hash address
    let address = Address::p2pkh(&public_key, Network::Bitcoin);
}

Structs

Address

A Bitcoin address

Enums

Payload

The method used to produce an address