#bitcoin #base32 #bech32 #encoding

bitcoin-bech32

Encodes and decodes Bitcoin Segregated Witness addresses in Bech32

17 releases (11 breaking)

Uses old Rust 2015

0.12.1 Feb 23, 2021
0.11.0 Aug 8, 2019
0.10.0 Jul 10, 2019
0.9.0 Feb 14, 2019
0.2.0 May 20, 2017

#107 in Encoding

Download history 667/week @ 2021-05-27 805/week @ 2021-06-03 616/week @ 2021-06-10 595/week @ 2021-06-17 573/week @ 2021-06-24 479/week @ 2021-07-01 305/week @ 2021-07-08 474/week @ 2021-07-15 741/week @ 2021-07-22 517/week @ 2021-07-29 633/week @ 2021-08-05 741/week @ 2021-08-12 181/week @ 2021-08-19 99/week @ 2021-08-26 104/week @ 2021-09-02 211/week @ 2021-09-09

1,076 downloads per month
Used in 16 crates (2 directly)

MIT license

26KB
444 lines

Bitcoin Bech32

Docs.rs badge Continuous Integration

Encodes and decodes Bitcoin Segregated Witness addresses in the Bech32 format described in BIP-0173.

Example

use bitcoin_bech32::{WitnessProgram, u5};
use bitcoin_bech32::constants::Network;

let witness_program = WitnessProgram::new(
    u5::try_from_u8(0).unwrap(),
    vec![
        0x00, 0x00, 0x00, 0xc4, 0xa5, 0xca, 0xd4, 0x62,
        0x21, 0xb2, 0xa1, 0x87, 0x90, 0x5e, 0x52, 0x66,
        0x36, 0x2b, 0x99, 0xd5, 0xe9, 0x1c, 0x6c, 0xe2,
        0x4d, 0x16, 0x5d, 0xab, 0x93, 0xe8, 0x64, 0x33],
    Network::Testnet,
).unwrap();

let address = witness_program.to_address();
assert_eq!(address,
           "tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy".to_string());

let decoded = WitnessProgram::from_address(&address).unwrap();
assert_eq!(decoded, witness_program);

Dependencies

~33KB