Code Monkey home page Code Monkey logo

rust-bech32-bitcoin's Introduction

Bitcoin Bech32

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);

rust-bech32-bitcoin's People

Contributors

clarkmoody avatar apoelstra avatar d4nte avatar sgeisler avatar stevenroose avatar hashengineering avatar kallewoof avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.