[−][src]Module bch::address
Address encoding and decoding
Examples
Extract the public key hash and address type from a cashaddr address:
use bch::address::cashaddr_decode; use bch::network::Network; let addr = "bitcoincash:qr6m7j9njldwwzlg9v7v53unlr4jkmx6eylep8ekg2"; let (pubkeyhash, addr_type) = cashaddr_decode(&addr, Network::Mainnet).unwrap();
Encode a public key hash into a legacy base-58 address:
use bch::address::{legacyaddr_encode, AddressType}; use bch::network::Network; use bch::util::hash160; let pubkeyhash = hash160(&[0; 33]); let legacyaddr = legacyaddr_encode(&pubkeyhash, AddressType::P2PKH, Network::Mainnet);
Enums
AddressType |
Address type which is either P2PKH or P2SH |
Functions
cashaddr_decode |
Decodes a cashaddr address to a public key hash |
cashaddr_encode |
Converts a public key hash to its cashaddr address |
legacyaddr_decode |
Decodes a legacy address to a public key hash |
legacyaddr_encode |
Converts a public key hash to its legacy address |