Crates.io | cash_addr |
lib.rs | cash_addr |
version | 0.1.0 |
source | src |
created_at | 2019-03-09 19:44:10.033882 |
updated_at | 2019-03-09 19:44:10.033882 |
description | cash_addr format implementation inspired by cashaddrjs. |
homepage | |
repository | https://github.com/haryu703/rust-cash-addr |
max_upload_size | |
id | 119642 |
size | 17,362 |
cash_addr format implementation inspired by cashaddrjs.
use cash_addr::{encode, decode, AddressType};
let data = [0xF5, 0xBF, 0x48, 0xB3, 0x97, 0xDA, 0xE7, 0x0B, 0xE8, 0x2B, 0x3C, 0xCA, 0x47, 0x93, 0xF8, 0xEB, 0x2B, 0x6C, 0xDA, 0xC9];
let prefix = "bitcoincash";
let addr_type = AddressType::P2PKH;
let address = encode(prefix, addr_type, &data).unwrap();
assert_eq!(address, "bitcoincash:qr6m7j9njldwwzlg9v7v53unlr4jkmx6eylep8ekg2");
let (prefix, addr_type, hash) = decode(&address).unwrap();
assert_eq!(prefix, "bitcoincash");
assert_eq!(addr_type, AddressType::P2PKH);
assert_eq!(hash, data);