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 hashbrown and core2.

Modules§

bech32
Encoding and decoding of the Bech32 format
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.
error
Contains error types and other error handling tools.
hash_types
Bitcoin hash types.
network
Bitcoin network support.
policy
Bitcoin policy.
util
Utility functions.

Structs§

Address
A Bitcoin address.
Amount
Amount
Block
Bitcoin block.
BlockHash
A bitcoin block hash.
BlockHeader
Bitcoin block header.
EcdsaSig
An ECDSA signature with the corresponding hash type.
FilterHash
Filter hash, as defined in BIP-157
FilterHeader
Filter header, as defined in BIP-157
KeyPair
Opaque data structure that holds a keypair consisting of a secret and a public key.
MerkleBlock
Data structure that represents a block header paired to a partial merkle tree.
OutPoint
A reference to a transaction output.
PackedLockTime
Packed lock time wraps a LockTime consensus value i.e., the raw u32 used by the network.
PrivateKey
A Bitcoin ECDSA private key
PubkeyHash
A hash of a public key.
PublicKey
A Bitcoin ECDSA public key
SchnorrSig
A BIP340-341 serialized schnorr signature with the corresponding hash type.
Script
Bitcoin script.
ScriptHash
A hash of Bitcoin Script bytecode.
Sequence
Bitcoin transaction input sequence number.
Sighash
Hash of the transaction according to the signature algorithm
SignedAmount
SignedAmount
Transaction
Bitcoin transaction.
TxIn
Bitcoin transaction input.
TxMerkleNode
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
WPubkeyHash
SegWit version of a public key hash.
WScriptHash
SegWit version of a Bitcoin Script bytecode hash.
Witness
The Witness is the data used to unlock bitcoins since the segwit upgrade
WitnessCommitment
A hash corresponding to the witness structure commitment in the coinbase transaction
WitnessMerkleNode
A hash corresponding to the Merkle tree root for witness data
Wtxid
A bitcoin witness transaction ID.
XOnlyPublicKey
An x-only public key, used for verification of Schnorr signatures and serialized according to BIP-340.
XpubIdentifier
XpubIdentifier as defined in BIP-32.

Enums§

AddressType
The different types of addresses.
Denomination
A set of denominations in which amounts can be expressed.
EcdsaSigError
A key-related error.
EcdsaSighashType
Hashtype of an input’s signature, encoded in the last byte of the signature.
Error
A general error code, other errors should implement conversions to/from this if appropriate.
LockTime
A lock time value, representing either a block height or a UNIX timestamp (seconds since epoch).
Network
The cryptocurrency to act on
SchnorrSigError
A schnorr sig related error.
SchnorrSighashType
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.

Type Aliases§

SigHashTypeDeprecated
Legacy Hashtype of an input’s signature