Expand description
Bitcoin Protocol Engine
This crate provides a Bitcoin protocol abstraction layer that enables:
- Multiple Bitcoin variants (mainnet, testnet, regtest, educational)
- Protocol evolution support (Bitcoin V1, V2, etc.)
- Economic model abstraction (PoW, future variants)
- Educational and research-friendly interfaces
This is Tier 3 of the 5-tier BTCDecoded architecture:
- Orange Paper (mathematical foundation)
- blvm-consensus (pure math implementation)
- blvm-protocol (Bitcoin abstraction) ← THIS CRATE
- blvm-node (full Bitcoin node)
- blvm-sdk (ergonomic API)
Re-exports§
pub use error::ProtocolError;pub use error::Result;pub use node_tcp::ProtocolMessage;pub use node_tcp::TcpFramedParser;pub use commons::BanListMessage;pub use commons::FilterPreferences;pub use commons::FilteredBlockMessage;pub use commons::GetBanListMessage;pub use commons::GetFilteredBlockMessage;pub use commons::GetUTXOProofMessage;pub use commons::GetUTXOSetMessage;pub use commons::UTXOCommitment;pub use commons::UTXOProofMessage;pub use commons::UTXOSetMessage;pub use config::ProtocolConfig;pub use config::ProtocolFeaturesConfig;pub use config::ProtocolValidationConfig;pub use config::ServiceFlagsConfig;pub use network::BlockMessage;pub use network::CompactBlockMessage;pub use network::TxMessage;pub use service_flags::commons as service_flags_commons;pub use service_flags::standard as service_flags_standard;pub use economic::EconomicParameters;pub use features::ActivationMethod;pub use features::FeatureActivation;pub use features::FeatureContext;pub use features::FeatureRegistry;pub use smallvec;pub use lru;pub use rayon;
Modules§
- activation
- address
- BIP350/351: Bech32m Address Encoding
- bip113
- bip119
- bip152
- BIP152 high-level compact block types (wire / serde).
- bip157
- BIP157: Client-Side Block Filtering Network Protocol
- bip158
- BIP158: Compact Block Filters for Light Client Discovery
- bip_
validation - block
- commons
- Commons-specific protocol extensions
- config
- Configuration for blvm-protocol
- consensus_
config - Consensus runtime configuration from
blvm-consensus(distinct from this crate’sconfigmodule). - constants
- Consensus constants (
blvm-primitives/ Orange Paper symbols) — same asblvm_consensus::constants. - crypto
- economic
- Economic Model Parameters
- error
- Protocol-specific error types
- features
- Feature Activation Tracking
- genesis
- Genesis Blocks
- mempool
- mining
- network
- Bitcoin P2P Network Protocol (Orange Paper Section 10)
- network_
params - Network parameters for different Bitcoin variants
- node_
tcp - Framed TCP P2P (mainnet magic, command allowlist supplied by the node). Not BIP324 v2 transport. Bitcoin TCP v1 framed messages: standard header (magic, command, length, checksum) plus payload.
- opcodes
- Script opcodes (re-exported from consensus / primitives) for callers that should not name
blvm-consensusdirectly. Bitcoin Script Opcode Constants - optimizations
- Production-only batch hashing, preallocation, and related optimization helpers from consensus.
- p2p_
commands - Bitcoin P2P command names (payload type tags; 12-byte null-padded on the wire).
- p2p_
frame - Bitcoin P2P message framing: magic, 12-byte command, LE length, 4-byte checksum, payload.
- p2p_
framing - Bitcoin P2P framing constants: magic bytes, max message size, and common count limits.
- payment
- BIP70: Payment Protocol (P2P Variant)
- pow
- script
- Script interpreter (consensus). Exposed so benches/node avoid a direct
blvm-consensusdep where possible. - segwit
- serialization
- service_
flags - Service flags for Bitcoin P2P protocol
- sigop
- spam_
filter - Spam Filtering for UTXO Commitments
- test_
utils - time
- Safe time utilities for fault tolerance
- transaction
- transaction_
hash - Transaction sighash / txid helpers from consensus.
- types
- utxo_
commitments - UTXO Commitments Module
- utxo_
overlay - v2_
transport - BIP324: Version 2 P2P Encrypted Transport Protocol
- validation
- Protocol validation interface
- variants
- Protocol variants implementation
- varint
- Variable-length integer encoding (Bitcoin protocol)
- version_
bits - wire
- Bitcoin P2P wire format serialization
- witness
Macros§
- profile_
log - Forwards to
blvm_consensus::profile_log!so upper layers avoid namingblvm-consensusdirectly. When theprofilefeature is off on consensus, the inner macro expands to a no-op. - tx_
inputs - Helper macro to create Transaction inputs/outputs that works with both Vec and SmallVec
- tx_
outputs
Structs§
- Bitcoin
Protocol Engine - Bitcoin Protocol Engine
- Block
- Block: ℬ = ℋ × 𝒯𝒳*
- Block
Header - Block Header: ℋ = ℤ × ℍ × ℍ × ℕ × ℕ × ℕ
- Consensus
Proof - Consensus Proof - wrapper struct for consensus validation functions
- Network
Message Limits - Network message size limits configuration
- Network
Parameters - Network parameters for different Bitcoin variants
- OutPoint
- OutPoint: 𝒪 = ℍ × ℕ
- Transaction
- Transaction: 𝒯𝒳 = ℕ × ℐ* × 𝒯* × ℕ
- Transaction
Input - Transaction Input: ℐ = 𝒪 × 𝕊 × ℕ
- Transaction
Output - Transaction Output: 𝒯 = ℤ × 𝕊
- UTXO
- UTXO: 𝒰 = ℤ × 𝕊 × ℕ
Enums§
- Consensus
Error - Protocol
Version - Bitcoin protocol versions
- Validation
Result - Validation result
Constants§
- BIP112_
CSV_ ACTIVATION_ MAINNET - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. BIP112/BIP113: CHECKSEQUENCEVERIFY (CSV) - Mainnet activation height - BIP112_
CSV_ ACTIVATION_ REGTEST - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. BIP112/BIP113: CSV - Regtest (active from genesis for typical regtest chains) - BIP112_
CSV_ ACTIVATION_ TESTNET - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. BIP112/BIP113: CSV - Testnet activation height (Bitcoin Core testnet3) - GENESIS_
BLOCK_ HASH_ INTERNAL - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. Genesis block hash in internal / wire byte order. - SEGWIT_
ACTIVATION_ MAINNET - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. SegWit (BIP141) - Mainnet activation height - SEGWIT_
ACTIVATION_ TESTNET - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. SegWit (BIP141) - Testnet activation height (Bitcoin Core testnet3consensus.SegwitHeight) - TAPROOT_
ACTIVATION_ MAINNET - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. Taproot (BIP341) - Mainnet activation height - TAPROOT_
ACTIVATION_ TESTNET - Buried deployment heights (Core chainparams) for RPC / tooling without a direct
blvm-consensusdep. Taproot (BIP341) - Testnet activation height (Bitcoin Core testnet3)
Functions§
- reset_
assume_ valid_ height - Reset assume-valid override (benchmarking).
- set_
assume_ valid_ height - Set assume-valid height for benchmarking (overrides config).
Type Aliases§
- Byte
String - Byte string type
- Consensus
Result - Hash
- Hash type: 256-bit hash
- Integer
- Integer type
- Natural
- Natural number type
- UtxoSet
- UTXO Set: 𝒰𝒮 = 𝒪 → 𝒰
- Witness
- Witness data: stack of witness elements (SegWit/Taproot)