| Crates.io | brk_cli |
| lib.rs | brk_cli |
| version | 0.0.109 |
| created_at | 2025-02-23 23:54:54.569524+00 |
| updated_at | 2025-09-20 17:22:40.986255+00 |
| description | A command line interface to run a BRK instance |
| homepage | https://bitcoinresearchkit.org |
| repository | https://github.com/bitcoinresearchkit/brk |
| max_upload_size | |
| id | 1566745 |
| size | 170,687 |
Command-line interface orchestrating complete Bitcoin Research Kit instances with automatic configuration and continuous blockchain processing.
This crate provides the primary command-line interface for running Bitcoin Research Kit instances. It orchestrates the entire data processing pipeline from Bitcoin Core block parsing through analytics computation to HTTP API serving, with persistent configuration management, automatic error recovery, and continuous blockchain synchronization.
Key Features:
Target Use Cases:
cargo install brk # or cargo install brk_cli
# First run - configure and start processing
brk --brkdir ./data --bitcoindir ~/.bitcoin --fetch true
# Subsequent runs use saved configuration
brk
# Override specific options
brk --website none --fetch false
Config: Persistent configuration with clap-based CLI parsing and TOML serializationBridge: Interface trait for generating JavaScript bridge files for web interfacesWebsite: Enum for web interface options (None, Bitview, Custom)main() -> color_eyre::Result<()>
Entry point with error handling setup, directory creation, logging initialization, and high-stack thread spawning.
run() -> color_eyre::Result<()>
Core processing loop handling configuration, RPC connection, component initialization, and continuous blockchain monitoring.
Persistent Settings:
~/.brk/config.tomlCLI Parameters:
--bitcoindir, --blocksdir, --brkdir: Directory configuration--fetch, --exchanges: Data source configuration--website: Web interface selection--rpcconnect, --rpcport, --rpccookiefile, --rpcuser, --rpcpassword: RPC settings# Initialize with custom directories
brk --bitcoindir /data/bitcoin --brkdir /data/brk
# Enable all features with custom RPC
brk --fetch true --exchanges true --website bitview \
--rpcuser myuser --rpcpassword mypass
# Minimal setup with API only
brk --website none --fetch false
After first run, settings are saved to ~/.brk/config.toml:
bitcoindir = "/home/user/.bitcoin"
blocksdir = "/home/user/.bitcoin/blocks"
brkdir = "/home/user/brk_data"
fetch = true
exchanges = true
website = "bitview"
rpcconnect = "localhost"
rpcport = 8332
rpccookiefile = "/home/user/.bitcoin/.cookie"
# Use built-in Bitview interface
brk --website bitview
# Use custom web interface
brk --website custom
# API only, no web interface
brk --website none
# Development with local website directory
# Looks for ../../websites directory first
brk --website bitview
# Production with auto-download from GitHub
# Downloads websites from release artifacts
brk --website bitview
Continuous Operation Loop:
headers == blocks for full node synchronizationWebsite Handling:
../../websites directory if availablebrk_bundlerDownload and Bundle Process:
// Automatic website download and bundling
let url = format!("https://github.com/bitcoinresearchkit/brk/archive/refs/tags/v{VERSION}.zip");
let response = minreq::get(url).send()?;
zip::ZipArchive::new(cursor).extract(downloads_path)?;
bundle(&websites_path, website.to_folder_name(), true).await?
Flexible Authentication Methods:
--bitcoindir/.cookie--rpcuser and --rpcpasswordTOML Persistence:
serde and tomldefault_on_error deserializer~ and $HOME environment variablesCross-Platform Path Resolution:
~/.bitcoin for Bitcoin Core, ~/.brk for BRK data~/Library/Application Support/Bitcoin for Bitcoin Core~/.brk/log for application logging~/.brk/downloads for temporary website artifactsMemory Management:
Comprehensive Validation:
Main Structure: Config struct with clap-derived CLI parsing and persistent TOML configuration management
Processing Loop: Continuous Bitcoin Core monitoring with sync detection and incremental block processing
Web Integration: Automatic website download from GitHub releases with JavaScript bundle generation
Component Orchestration: Coordination of parser, indexer, computer, and server with proper dependency management
Error Handling: color_eyre integration with comprehensive validation and user-friendly error messages
Threading: High-stack thread allocation (512MB) with tokio multi-threaded runtime for complex operations
Architecture: Complete BRK pipeline orchestration with persistent configuration and continuous blockchain synchronization
This README was generated by Claude Code