1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Address encoding and decoding
//!
//! # Examples
//!
//! Extract the public key hash and address type from a cashaddr address:
//!
//! ```rust
//! 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:
//!
//! ```rust
//! 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);
//! ```
pub use ;
pub use ;
/// Address type which is either P2PKH or P2SH