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 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.no-std
- enables additional features required for this crate to be usable without std. Does not disablestd
. Depends onhashbrown
andcore2
.
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.
- Block
Hash - A bitcoin block hash.
- Block
Header - Bitcoin block header.
- Ecdsa
Sig - An ECDSA signature with the corresponding hash type.
- Filter
Hash - Filter hash, as defined in BIP-157
- Filter
Header - Filter header, as defined in BIP-157
- KeyPair
- Opaque data structure that holds a keypair consisting of a secret and a public key.
- Merkle
Block - Data structure that represents a block header paired to a partial merkle tree.
- OutPoint
- A reference to a transaction output.
- Packed
Lock Time - Packed lock time wraps a
LockTime
consensus value i.e., the rawu32
used by the network. - Private
Key - A Bitcoin ECDSA private key
- Pubkey
Hash - A hash of a public key.
- Public
Key - A Bitcoin ECDSA public key
- Schnorr
Sig - A BIP340-341 serialized schnorr signature with the corresponding hash type.
- Script
- Bitcoin script.
- Script
Hash - A hash of Bitcoin Script bytecode.
- Sequence
- Bitcoin transaction input sequence number.
- Sighash
- Hash of the transaction according to the signature algorithm
- Signed
Amount - SignedAmount
- 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.
- Witness
- The Witness is the data used to unlock bitcoins 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
- Wtxid
- A bitcoin witness transaction ID.
- XOnly
Public Key - An x-only public key, used for verification of Schnorr signatures and serialized according to BIP-340.
- Xpub
Identifier - XpubIdentifier as defined in BIP-32.
Enums§
- Address
Type - The different types of addresses.
- Denomination
- A set of denominations in which amounts can be expressed.
- Ecdsa
SigError - A key-related error.
- Ecdsa
Sighash Type - 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.
- Lock
Time - A lock time value, representing either a block height or a UNIX timestamp (seconds since epoch).
- Network
- The cryptocurrency to act on
- Schnorr
SigError - A schnorr sig related error.
- Schnorr
Sighash 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.
Type Aliases§
- SigHash
Type Deprecated - Legacy Hashtype of an input’s signature