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.
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.
Modules§
- address
- Bitcoin addresses.
- amount
- Bitcoin amounts.
- base58
- Bitcoin base58 encoding and decoding.
- base64
- Correct, fast, and configurable base64 decoding and encoding. Base64 transports binary data efficiently in contexts where only plain text is allowed.
- bech32
- Encoding and decoding of the Bech32 format.
- bip32
- BIP32 implementation.
- bip152
- BIP152 Compact Blocks
- bip158
- BIP 158 Compact Block Filters for Light Clients.
- 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.
- io
- Rust-Bitcoin IO Library
- key
- Bitcoin keys.
- merkle_
tree - Bitcoin merkle tree functions.
- network
- Bitcoin network.
- p2p
- Bitcoin p2p network types.
- parse
- Unit parsing utilities.
- 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
- taproot
- Bitcoin Taproot.
Structs§
- Address
- A Bitcoin address.
- Amount
- Amount
- Block
- Bitcoin block.
- Block
Hash - A bitcoin block hash.
- Compact
Target - Encoding of 256-bit target as 32-bit float.
- Compressed
Public Key - An always-compressed Bitcoin ECDSA public key
- FeeRate
- Represents fee rate.
- Filter
Hash - Filter hash, as defined in BIP-157
- Filter
Header - Filter header, as defined in BIP-157
- Legacy
Sighash - Hash of a transaction according to the legacy signature algorithm.
- Merkle
Block - Data structure that represents a block header paired to a partial merkle tree.
- Opcode
- A script Opcode.
- OutPoint
- A reference to a transaction output.
- Private
Key - A Bitcoin ECDSA private key
- Psbt
- A Partially Signed Transaction.
- Pubkey
Hash - A hash of a public key.
- Public
Key - A Bitcoin ECDSA public key
- Script
- Bitcoin script slice.
- Script
Buf - An owned, growable script.
- Script
Hash - A hash of Bitcoin Script bytecode.
- Segwit
V0Sighash - Hash of a transaction according to the segwit version 0 signature algorithm.
- Sequence
- Bitcoin transaction input sequence number.
- Signed
Amount - SignedAmount
- TapBranch
Tag - The tag used for
TapNodeHash
- TapLeaf
Hash - Taproot-tagged hash with tag "TapLeaf".
- TapLeaf
Tag - The tag used for
TapLeafHash
- TapNode
Hash - Tagged hash used in taproot trees.
- TapSighash
- Taproot-tagged hash with tag "TapSighash".
- TapSighash
Tag - The tag used for
TapSighash
- TapTweak
Hash - Taproot-tagged hash with tag "TapTweak".
- TapTweak
Tag - The tag used for
TapTweakHash
- Target
- A 256 bit integer representing target.
- Transaction
- Bitcoin transaction.
- TxIn
- Bitcoin transaction input.
- TxMerkle
Node - A hash of the Merkle tree branch or root for transactions.
- TxOut
- Bitcoin transaction output.
- Txid
- A bitcoin transaction hash/transaction ID.
- VarInt
- A variable-length unsigned integer.
- WPubkey
Hash - SegWit version of a public key hash.
- WScript
Hash - 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.
- Witness
Commitment - A hash corresponding to the witness structure commitment in the coinbase transaction.
- Witness
Merkle Node - A hash corresponding to the Merkle tree root for witness data.
- Witness
Program - The segregated witness program.
- Work
- A 256 bit integer representing work.
- Wtxid
- A bitcoin witness transaction ID.
- XKey
Identifier - Extended key identifier as defined in BIP-32.
- XOnly
Public Key - An x-only public key, used for verification of Taproot signatures and serialized according to BIP-340.
Enums§
- Address
Type - The different types of addresses.
- Denomination
- A set of denominations in which amounts can be expressed.
- Ecdsa
Sighash Type - Hashtype of an input’s signature, encoded in the last byte of the signature.
- Known
Hrp - Known bech32 human-readable parts.
- Network
- The cryptocurrency network to act on.
- Network
Kind - What kind of network we are on.
- TapSighash
Type - 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.
- Witness
Version - Version of the segregated witness program.