Crate bitcoin

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.
  • rand - (dependency), makes it more convenient to generate random values.
  • 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 core2.
  • bitcoinconsensus-std - enables std in bitcoinconsensus and communicates it to this crate so it knows how to implement std::error::Error. At this time there’s a hack to achieve the same without this feature but it could happen the implementations diverge one day.

Modules§

address
Bitcoin addresses.
amount
Bitcoin amounts.
base58
Base58 encoder and decoder.
bech32
Encoding and decoding of the Bech32 format
bip32
BIP32 implementation.
bip152
BIP152 Compact Blocks
bip158
BIP 158 Compact Block Filters for Light Clients.
bitcoinconsensus
This project builds the libbitcoinconsensus library from Bitcoin’s C++ sources using Cargo and provides Rust bindings to its API.
blockdata
Bitcoin block data.
consensus
Bitcoin consensus.
ecdsa
ECDSA Bitcoin signatures.
error
Contains error types and other error handling tools.
hash_types
Bitcoin hash types.
hashes
Rust hashes library.
key
Bitcoin keys.
merkle_tree
Bitcoin merkle tree functions.
network
Bitcoin network support.
policy
Bitcoin policy.
pow
Proof-of-work related integer types.
psbt
Partially Signed Bitcoin Transactions.
secp256k1
Rust bindings for Pieter Wuille’s secp256k1 library, which is used for fast and accurate manipulation of ECDSA signatures on the secp256k1 curve. Such signatures are used extensively by the Bitcoin network and its derivatives.
sighash
Signature hash implementation (used in transaction signing).
sign_message
Signature
string
Bitcoin string parsing utilities.
taproot
Bitcoin Taproot.
util
Utility functions.

Structs§

Address
A Bitcoin address.
Amount
Amount
Block
Bitcoin block.
BlockHash
A bitcoin block hash.
CompactTarget
Encoding of 256-bit target as 32-bit float.
FeeRate
Represents fee rate.
MerkleBlock
Data structure that represents a block header paired to a partial merkle tree.
OutPoint
A reference to a transaction output.
PrivateKey
A Bitcoin ECDSA private key
PubkeyHash
A hash of a public key.
PublicKey
A Bitcoin ECDSA public key
Script
Bitcoin script slice.
ScriptBuf
An owned, growable script.
ScriptHash
A hash of Bitcoin Script bytecode.
Sequence
Bitcoin transaction input sequence number.
SignedAmount
SignedAmount
Target
A 256 bit integer representing target.
Transaction
Bitcoin transaction.
TxIn
Bitcoin transaction input.
TxOut
Bitcoin transaction output.
Txid
A bitcoin transaction hash/transaction ID.
VarInt
A variable-length unsigned integer.
WPubkeyHash
SegWit version of a public key hash.
WScriptHash
SegWit version of a Bitcoin Script bytecode hash.
Weight
Represents block weight - the weight of a transaction or block.
Witness
The Witness is the data used to unlock bitcoin since the segwit upgrade.
Work
A 256 bit integer representing work.
Wtxid
A bitcoin witness transaction ID.

Enums§

AddressType
The different types of addresses.
Denomination
A set of denominations in which amounts can be expressed.
Error
A general error code, other errors should implement conversions to/from this if appropriate.
Network
The cryptocurrency network to act on.