Crate bellscoin

Source
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 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.

Re-exports§

pub extern crate base64;
pub extern crate bech32;
pub extern crate bitcoinconsensus;
pub extern crate hashes;
pub extern crate hex;
pub extern crate secp256k1;
pub use crate::address::Address;
pub use crate::address::AddressType;
pub use crate::amount::Amount;
pub use crate::amount::Denomination;
pub use crate::amount::SignedAmount;
pub use crate::bip32::XKeyIdentifier;
pub use crate::blockdata::block;
pub use crate::blockdata::block::Block;
pub use crate::blockdata::constants;
pub use crate::blockdata::fee_rate::FeeRate;
pub use crate::blockdata::locktime;
pub use crate::blockdata::locktime::absolute;
pub use crate::blockdata::locktime::relative;
pub use crate::blockdata::opcodes;
pub use crate::blockdata::opcodes::Opcode;
pub use crate::blockdata::script::witness_program;
pub use crate::blockdata::script::witness_program::WitnessProgram;
pub use crate::blockdata::script::witness_version;
pub use crate::blockdata::script::witness_version::WitnessVersion;
pub use crate::blockdata::script;
pub use crate::blockdata::script::Script;
pub use crate::blockdata::script::ScriptBuf;
pub use crate::blockdata::script::ScriptHash;
pub use crate::blockdata::script::WScriptHash;
pub use crate::blockdata::transaction;
pub use crate::blockdata::transaction::OutPoint;
pub use crate::blockdata::transaction::Sequence;
pub use crate::blockdata::transaction::Transaction;
pub use crate::blockdata::transaction::TxIn;
pub use crate::blockdata::transaction::TxOut;
pub use crate::blockdata::weight::Weight;
pub use crate::blockdata::witness;
pub use crate::blockdata::witness::Witness;
pub use crate::consensus::encode::VarInt;
pub use crate::hash_types::BlockHash;
pub use crate::hash_types::FilterHash;
pub use crate::hash_types::FilterHeader;
pub use crate::hash_types::TxMerkleNode;
pub use crate::hash_types::Txid;
pub use crate::hash_types::WitnessCommitment;
pub use crate::hash_types::Wtxid;
pub use crate::merkle_tree::MerkleBlock;
pub use crate::network::Network;
pub use crate::pow::CompactTarget;
pub use crate::pow::Target;
pub use crate::pow::Work;
pub use crate::psbt::Psbt;
pub use crate::taproot::TapBranchTag;
pub use crate::taproot::TapLeafHash;
pub use crate::taproot::TapLeafTag;
pub use crate::taproot::TapNodeHash;
pub use crate::taproot::TapTweakHash;
pub use crate::taproot::TapTweakTag;

Modules§

address
Bitcoin addresses.
amount
Bitcoin amounts.
base58
Base58 encoder and decoder.
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.
key
Bitcoin keys.
merkle_tree
Bitcoin merkle tree functions.
network
Bitcoin network.
p2p
Bitcoin p2p network types.
policy
Bitcoin policy.
pow
Proof-of-work related integer types.
psbt
Partially Signed Bitcoin Transactions.
sighash
Signature hash implementation (used in transaction signing).
sign_message
Signature
string
Bitcoin string parsing utilities.
taproot
Bitcoin Taproot.

Structs§

LegacySighash
Hash of a transaction according to the legacy signature algorithm.
PrivateKey
A Bitcoin ECDSA private key
PubkeyHash
A hash of a public key.
PublicKey
A Bitcoin ECDSA public key
SegwitV0Sighash
Hash of a transaction according to the segwit version 0 signature algorithm.
TapSighash
Taproot-tagged hash with tag "TapSighash".
TapSighashTag
The tag used for TapSighash
WPubkeyHash
SegWit version of a public key hash.
XOnlyPublicKey
An x-only public key, used for verification of Taproot signatures and serialized according to BIP-340.

Enums§

EcdsaSighashType
Hashtype of an input’s signature, encoded in the last byte of the signature.
TapSighashType
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.