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.
Except for its dependency on libsecp256k1 (and optionally libbitcoinconsensus), this library is written entirely in Rust. It illustrates 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 onstd
(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), implementsserde
-based serialization and deserialization.secp-lowmemory
- optimizations for low-memory devices.bitcoinconsensus-std
- enablesstd
inbitcoinconsensus
and communicates it to this crate so it knows how to implementstd::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.ordered
- (dependency), adds implementations ofArbitraryOrdOrd
to some structs.
Re-exports§
pub extern crate base58;
pub extern crate base64;
pub extern crate bech32;
pub extern crate hashes;
pub extern crate hex;
pub extern crate io;
pub extern crate ordered;
pub extern crate secp256k1;
Modules§
- Provides type
LockTime
that implements the logic around nLockTime/OP_CHECKLOCKTIMEVERIFY. - Bitcoin addresses.
- Bitcoin amounts.
- BIP32 implementation.
- BIP152 Compact Blocks
- BIP 158 Compact Block Filters for Light Clients.
- Bitcoin blocks.
- Bitcoin block data.
- Bitcoin consensus.
- Blockdata constants.
- ECDSA Bitcoin signatures.
- Contains error types and other error handling tools.
- Bitcoin hash types.
- Bitcoin keys.
- Provides absolute and relative locktimes.
- Bitcoin merkle tree functions.
- Bitcoin network.
- Bitcoin script opcodes.
- Bitcoin p2p network types.
- Bitcoin consensus parameters.
- Unit parsing utilities.
- Bitcoin policy.
- Proof-of-work related integer types.
- Partially Signed Bitcoin Transactions.
- Provides type
LockTime
that implements the logic around nSequence/OP_CHECKSEQUENCEVERIFY. - Bitcoin scripts.
- Signature hash implementation (used in transaction signing).
- Signature
- Bitcoin Taproot.
- Bitcoin transactions.
- Witness
- The segregated witness program as defined by BIP141.
- The segregated witness version byte as defined by BIP141.
Structs§
- A Bitcoin address.
- Amount
- Bitcoin block.
- A bitcoin block hash.
- Encoding of 256-bit target as 32-bit float.
- An always-compressed Bitcoin ECDSA public key
- Re-export everything from the
units::fee_rate
module. Represents fee rate. - Filter hash, as defined in BIP-157
- Filter header, as defined in BIP-157
- Hash of a transaction according to the legacy signature algorithm.
- Data structure that represents a block header paired to a partial merkle tree.
- A script Opcode.
- A reference to a transaction output.
- A Bitcoin ECDSA private key
- A Partially Signed Transaction.
- A hash of a public key.
- A Bitcoin ECDSA public key
- Bitcoin script slice.
- An owned, growable script.
- A hash of Bitcoin Script bytecode.
- Hash of a transaction according to the segwit version 0 signature algorithm.
- Bitcoin transaction input sequence number.
- SignedAmount
- The tag used for
TapNodeHash
- Taproot-tagged hash with tag "TapLeaf".
- The tag used for
TapLeafHash
- Tagged hash used in taproot trees.
- Taproot-tagged hash with tag "TapSighash".
- The tag used for
TapSighash
- Taproot-tagged hash with tag "TapTweak".
- The tag used for
TapTweakHash
- A 256 bit integer representing target.
- Bitcoin transaction.
- Bitcoin transaction input.
- A hash of the Merkle tree branch or root for transactions.
- Bitcoin transaction output.
- A bitcoin transaction hash/transaction ID.
- A variable-length unsigned integer.
- SegWit version of a public key hash.
- SegWit version of a Bitcoin Script bytecode hash.
- Re-export everything from the
units::weight
module. Represents block weight - the weight of a transaction or block. - The Witness is the data used to unlock bitcoin since the segwit upgrade.
- A hash corresponding to the witness structure commitment in the coinbase transaction.
- A hash corresponding to the Merkle tree root for witness data.
- The segregated witness program.
- A 256 bit integer representing work.
- A bitcoin witness transaction ID.
- Extended key identifier as defined in BIP-32.
- An x-only public key, used for verification of Taproot signatures and serialized according to BIP-340.
Enums§
- The different types of addresses.
- A set of denominations in which amounts can be expressed.
- Hashtype of an input’s signature, encoded in the last byte of the signature.
- Known bech32 human-readable parts.
- The cryptocurrency network to act on.
- What kind of network we are on.
- Hashtype of an input’s signature, encoded in the last byte of the signature. Fixed values so they can be cast as integer types for encoding.
- Version of the segregated witness program.