mhinparser
A high-performance Bitcoin blockchain parser implementing the My Hash Is Nice protocol.
Built on mhinprotocol, this parser leverages protoblock for blazing-fast block fetching and rollblock for efficient UTXO management with instant rollback support.
Features
- π Maximum Performance β Parallel block fetching via
protoblockwith configurable thread pools - β‘ Instant Rollbacks β
rollblockprovides chain reorganization handling - π Multi-Network β Supports Mainnet, Testnet4, Signet, and Regtest
- π Live Progress β Terminal UI powered by
ratatui - π§ Daemon Mode β Run as a background service with signal handling
Installation
Or build from source:
Quick Start
# Parse mainnet (connects to local Bitcoin Core RPC)
# Parse testnet4
# Run as daemon
# Stop daemon
Configuration
Configuration can be provided via CLI flags, environment variables, or a TOML file.
Default config location: ~/.config/myhashisnice/mhinparser/mhinparser.toml
Example configuration with production-optimized values (defaults are more conservative):
# Network: mainnet, testnet4, signet, regtest
= "mainnet"
# Data directory for SQLite stats and rollblock storage
= "/path/to/data"
[]
= "http://127.0.0.1:8332"
= "bitcoin"
= "password"
= 8 # default: 4
= 256 # default: 10
[]
= "mhin" # change this in production
= "mhin" # change this in production
= 9443
= 16
= 4
= 100_000_000 # default: 5_000_000
The embedded rollblock server binds to 127.0.0.1 with basic authentication. By default it uses the mhin/mhin credentials on port 9443; change these via --rollblock_user, --rollblock_password, and --rollblock_port. The parser emits a startup warning when the defaults are still in use.
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β mhinparser β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β protoblock β β mhinprotocolβ β rollblock β β
β β ββββββββββββ β ββββββββββββ β βββββββββββββββββ β β
β β Fast block β β MHIN β β UTXO store with β β
β β fetching & β β protocol β β instant rollback β β
β β processing β β logic β β support β β
β βββββββββββββββ βββββββββββββββ βββββββββββββββββββββββ β
β β β
β ββββββββ΄βββββββ β
β β SQLite β β
β β (stats) β β
β βββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
CLI Reference
Usage: mhinparser [OPTIONS] [COMMAND]
Commands:
run Start the parser (default)
stop Stop the running daemon
Options:
-c, --config <FILE> Path to config file
-d, --data-dir <DIR> Data directory
-n, --network <NETWORK> Bitcoin network [mainnet|testnet4|signet|regtest]
--daemon Run as background daemon
-h, --help Print help
-V, --version Print version
Requirements
- Rust 1.75+ (2021 edition)
- Bitcoin Core node with RPC enabled
- ~50GB+ disk space for mainnet UTXO set
Data Storage
SQLite Stats Database
The parser stores protocol statistics in mhinstats.sqlite3 with two tables:
-- Individual rewards per block
(
block_index INTEGER NOT NULL,
txid TEXT NOT NULL,
vout INTEGER NOT NULL,
zero_count INTEGER NOT NULL,
reward INTEGER NOT NULL,
PRIMARY KEY (block_index, txid, vout)
);
-- Per-block and cumulative stats (JSON-encoded)
(
block_index INTEGER PRIMARY KEY,
block_stats TEXT NOT NULL, -- {"block_index":..., "total_reward":..., "reward_count":..., ...}
cumul_stats TEXT NOT NULL -- cumulative totals up to this block
);
Example: Query rewards with sqlite3
Rollblock UTXO Store
UTXOs are stored in a rollblock key-value store for O(1) lookups and instant rollbacks.
Key format: Each UTXO is identified by an 8-byte key computed as:
// From mhinprotocol:
Value format: The MHIN UTXO balance stored as a little-endian u64.
Example: Read UTXO balances with rollblock client
use ;
use BasicAuthConfig;
use xxh64;
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.