Expand description

Rust Bitcoin Library

This is a library that supports the Bitcoin network protocol and associated primitives. It is designed for Rust programs built to work with the Bitcoin network.

It is also written entirely in Rust to illustrate the benefits of strong type safety, including ownership and lifetime, for financial and/or cryptographic software.

See README.md for detailed documentation about development and supported environments.

Available feature flags

  • std - the usual dependency on std (default).
  • secp-recovery - enables calculating public key from a signature and message.
  • base64 - (dependency), enables encoding of PSBTs and message signatures.
  • unstable - enables unstable features for testing.
  • rand - (dependency), makes it more convenient to generate random values.
  • use-serde - (dependency), implements serde-based serialization and deserialization.
  • secp-lowmemory - optimizations for low-memory devices.
  • no-std - enables additional features required for this crate to be usable without std. Does not disable std. Depends on hashbrown and core2.


pub extern crate base64;
pub extern crate bech32;
pub extern crate bitcoin_hashes as hashes;
pub extern crate secp256k1;
pub use hash_types::*;
pub use blockdata::block::Block;
pub use blockdata::block::BlockHeader;
pub use blockdata::script::Script;
pub use blockdata::transaction::Transaction;
pub use blockdata::transaction::TxIn;
pub use blockdata::transaction::TxOut;
pub use blockdata::transaction::OutPoint;
pub use blockdata::transaction::EcdsaSigHashType;
pub use blockdata::witness::Witness;
pub use consensus::encode::VarInt;
pub use network::constants::Network;
pub use util::Error;
pub use util::address::Address;
pub use util::address::AddressType;
pub use util::amount::Amount;
pub use util::amount::Denomination;
pub use util::amount::SignedAmount;
pub use util::merkleblock::MerkleBlock;
pub use util::sighash::SchnorrSigHashType;
pub use util::ecdsa;
pub use util::ecdsa::EcdsaSig;
pub use util::ecdsa::EcdsaSigError;
pub use util::schnorr;
pub use util::schnorr::SchnorrSig;
pub use util::schnorr::SchnorrSigError;
pub use util::key::PrivateKey;
pub use util::key::PublicKey;
pub use util::psbt;
pub use blockdata::transaction::SigHashType;


Bitcoin block data.

Bitcoin consensus.

Bitcoin hash types.

Bitcoin network support.

Bitcoin policy.

Utility functions.


Opaque data structure that holds a keypair consisting of a secret and a public key.

An x-only public key, used for verification of Schnorr signatures and serialized according to BIP-340.