5 unstable releases

0.3.0+0.18.0 Jul 20, 2019
0.2.2 May 31, 2017
0.2.1 May 23, 2017
0.2.0 May 23, 2017
0.1.1 May 21, 2017


124 lines


Rust bindings to libbitcoinconsensus

crates.io docs.rs CircleCI

This project allows Bitcoin software to be written in Rust while using the same library for script verification that Bitcoin Core uses.

cargo build will automatically check out the Bitcoin Core GitHub repository, configure and build it, and build the bindings statically linked to libbitcoinconsensus and libsecp256k1.

Currently building against the consensus library from Bitcoin Core v0.18.0.


Rust bindings to libbitcoinconsensus

use hex::FromHex;
use bitcoin_consensus::{verify_script, ScriptVerificationFlags};

fn main() {
    let pubkey: Vec<u8> = Vec::from_hex("76a9144621d47f08fcb1e6be0b91144202de7a186deade88ac").unwrap();
    let tx: Vec<u8> = Vec::from_hex("01000000015884e5db9de218238671572340b207ee85b628074e7e467096c267266baf77a4000000006a4730440220340f35055aceb14250e4954b23743332f671eb803263f363d1d7272f1d487209022037a0eaf7cb73897ba9069fc538e7275c5ae188e934ae47ca4a70453b64fc836401210234257444bd3aead2b851bda4288d60abe34095a2a8d49aff1d4d19773d22b32cffffffff01a0860100000000001976a9147821c0a3768aa9d1a37e16cf76002aef5373f1a888ac00000000").unwrap();
    match verify_script(&pubkey, &tx, 0, ScriptVerificationFlags::empty()) {
        Ok(_) => println!("transaction verified"),
        Err(e) => panic!("transaction did not verify: {:?}", e)