bitcoin-explorer
bitcoin_explorer is an efficient library for decoding transaction information from
bitcoin blockchain.
Support bitcoin MainNet, might support other networks in the future.
Features
1. Block & Script Decoding
- Query blocks based on block heights.
- Decode Bitcoin Core native levelDB info.
- Decode addresses from output scripts (supporting all standard scripts, including Multi-Sig scripts).
- Find input addresses using on-disk UTXO cache (iter_connected_block()).
2. Concurrency + Iterator + Sequential Output
- Fast concurrent reading but producing sequential output.
- Work-stealing with registry to maximize efficiency.
- Native Iterator interface (support
for insyntax). - Robust exception handling in multi-threading.
- Data racing and deadlock free data model.
3. Small Memory Footprint (< 4 GB RAM)
- Compress 256-bit TxID to u128 keys in UTXO.
- Use a fast on-disk UTXO storage (RocksDB).
- Configurable in-memory UTXO cache (non-default feature).
4. Generic User Interface
- Use static generic to offer different output formats for various APIs.
5. Thorough Testing
- Thoroughly tested for correctness using rust integration tests.
6. Build for Rust + Python (Multi-OS PyPI wheels)
- Built and published PyPI wheels for
python 3.6-3.10acrossWindows x86/x64,MacOS x86_64/arm64, andLinux x86_64. - Rust library on crates.io called bitcoin-explorer.
Documentation
Examples
Get total number of blocks and transactions available on disk
use ;
use Path;
Get a block (i.e., see doc for what is full/simple format (FBlock/SBlock) )
use ;
use Path;
Get a transaction (in different formats)
Note: this requires building tx index with --txindex=1 flag using Bitcoin Core.
use ;
use Path;
Iterate through all blocks (in different formats)
use ;
use Path;
Iterate through all blocks with Input Addresses Found (ConnectedBlock)
use ;
use Path;
Hardware Requirements
Memory Requirement
Memory requirement: 8 GB physical RAM.
Disk Requirement
SSD for better performance.
Benchmarking
- OS:
x86_64Windows 10 - CPU: Intel i7-9700 @ 3.00GHZ (4-core, 8-threads)
- Memory: 16 GB 2667 Mhz
- Disk: WDC SN730 512GB (SSD)
Iteration Through All Blocks (0 - 700000)
db.
- Time: about 10 minutes
- Peak Memory: <= 500 MB
Iteration Through All Blocks (0 - 700000) With Input Addresses
db.
Using default configuration
Compile with default features (Cargo.toml):
= "^2.1"
- Time: about 2.5 hours
- Peak Memory: 4 GB
Using non-default configuration (large RAM for good performance)
Compile with non-default features (Cargo.toml):
= { = "^2.1", = false }
- Time: about 30 minutes
- Peak Memory: 32 GB
Notes
Compatibility
This package deals with the binary file of another software Bitcoin Core.
It might not be compatible with older Bitcoin Core versions.
Tested on
Bitcoin Core version v0.21.1.0-g194b9b8792d9b0798fdb570b79fa51f1d1f5ebaf Copyright (C) 2009-2020 The Bitcoin Core developers.
Non-Default Feature (In-Memory-UTXO cache)
If you have more than 32 GB memory, you might try default-features = false
for faster performance on db.iter_connected_block()
= { = "^2.1", = false }