A knots-inspired Bitcoin node implementation written in Rust.
- Actor-based Architecture - Built with Actix for modular, concurrent processing
- RocksDB Storage - High-performance persistent storage with configurable compression
- Structured Logging - JSON logging with OpenTelemetry integration
- Prometheus Metrics - Comprehensive Bitcoin node metrics
- Multi-format Events - ZMQ, Kubernetes Events, and Webhook publishing
- JSON-RPC API - Bitcoin Core compatible RPC interface
- REST API - Modern HTTP API for blockchain data
- P2P Networking - Bitcoin protocol implementation (planned)
- Transaction Pool - Mempool management with fee estimation
- Block Validation - Full block and transaction validation (planned)
- Kubernetes Integration - Native K8s event publishing
- Configuration Management - TOML-based configuration with CLI overrides
- Health Checks - Built-in health endpoints
- Graceful Shutdown - Proper resource cleanup
- Comprehensive Test Suite - 18+ unit tests covering all core components
- Development Tooling - 50+ Just commands for streamlined workflow
- API Testing - Built-in commands for testing REST and RPC endpoints
- Database Management - Tools for initialization, backup, and reset
- Code Quality - Automated formatting, linting, and coverage reporting
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β REST API β β JSON-RPC β β Metrics β
β :8332 β β :18443 β β :9090 β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βββββββββββββββββββββββββΌββββββββββββββββββββββββ
β
βββββββββββββββββββ
β Event Manager β
β ZMQ β K8s β WH β
βββββββββββββββββββ
β
βββββββββββββββββββ
β Actor System β
βββββββββββββββββββ
β
βββββββββββββ¬ββββββββββββββββββ¬ββββββββββββ¬ββββββββββββββ
β β β β β
βββββββββββ βββββββββββ βββββββββββββββ βββββββββββ βββββββββββββββ
β Storage β β Network β β Mempool β β Chain β β Metrics β
β Actor β β Actor β β Actor β β Actor β β Actor β
βββββββββββ βββββββββββ βββββββββββββββ βββββββββββ βββββββββββββββ
β
βββββββββββ
β RocksDB β
βββββββββββ
- Rust 1.70+
- RocksDB development libraries
git clone https://github.com/your-org/bitknotsrs.git
cd bitknotsrs
cargo build --release
./target/release/bitknotsrs --generate-config
# Start with default configuration
./target/release/bitknotsrs
# Start with custom config
./target/release/bitknotsrs --config custom.toml
# Override network
./target/release/bitknotsrs --network mainnet
# Override data directory
./target/release/bitknotsrs --datadir /var/lib/bitcoin
# Build image
docker build -t bitknotsrs .
# Run container
docker run -p 8332:8332 -p 18443:18443 -p 9090:9090 \
-v $(pwd)/data:/app/data \
bitknotsrs
apiVersion: apps/v1
kind: Deployment
metadata:
name: bitknotsrs
spec:
replicas: 1
selector:
matchLabels:
app: bitknotsrs
template:
metadata:
labels:
app: bitknotsrs
spec:
containers:
- name: bitknotsrs
image: bitknotsrs:latest
ports:
- containerPort: 8332
- containerPort: 18443
- containerPort: 9090
env:
- name: RUST_LOG
value: "info"
volumeMounts:
- name: data
mountPath: /app/data
volumes:
- name: data
persistentVolumeClaim:
claimName: bitknotsrs-data
Available at http://localhost:9090/metrics
:
bitcoin_chain_height
- Current blockchain heightbitcoin_blocks_processed_total
- Total blocks processedbitcoin_transactions_processed_total
- Total transactions processedbitcoin_peers_connected
- Number of connected peersbitcoin_mempool_size
- Current mempool sizebitcoin_storage_size_bytes
- Storage size in bytes
{
"timestamp": "2024-01-15T10:30:00Z",
"level": "INFO",
"target": "bitknotsrs::actors::storage",
"message": "Stored block: 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"block_hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
"height": 0,
"event_type": "block"
}
# Subscribe to block events
zmq_sub tcp://localhost:28333 block
# Subscribe to transaction events
zmq_sub tcp://localhost:28333 transaction
# View Bitcoin node events
kubectl get events --field-selector involvedObject.name=bitknotsrs-node
[network_config]
listen_port = 18444
max_peers = 8
connection_timeout_secs = 30
[network_config.zmq]
enabled = true
pub_port = 28332
topics = ["hashblock", "hashtx", "rawblock", "rawtx"]
[storage]
rocks_db_path = "./data/rocksdb"
cache_size = 268435456 # 256MB
compression = "lz4"
backup_enabled = true
backup_interval_hours = 24
[events]
enabled_publishers = ["zmq", "k8s", "webhook"]
[events.k8s]
enabled = true
namespace = "bitcoin"
node_name = "bitknotsrs-node"
event_types = ["block", "transaction", "peer", "chain"]
[events.webhook]
enabled = true
endpoints = ["https://your-webhook.com/bitcoin-events"]
timeout_secs = 10
retry_attempts = 3
GET /health
- Health checkGET /api/v1/info
- Node informationGET /api/v1/stats
- Node statisticsGET /api/v1/peers
- Connected peersGET /api/v1/mempool
- Mempool informationGET /api/v1/block?hash=<hash>
- Get block by hashGET /api/v1/transaction?txid=<txid>
- Get transactionPOST /api/v1/sendrawtransaction
- Broadcast transaction
Compatible with Bitcoin Core RPC:
getblockchaininfo
getbestblockhash
getblock <hash>
getblockhash <height>
getrawtransaction <txid>
sendrawtransaction <hex>
getmempoolinfo
getpeerinfo
- Just command runner (recommended)
- Radicle for decentralized issue management
- Rust 1.70+
- RocksDB development libraries
# List all available commands
just --list
# Run all tests
just test
# Quick development check (format, lint, test)
just quick-check
# Development workflow with Radicle sync
just dev-workflow
# Build and run in regtest mode
just build
just run-regtest
This project uses Radicle for decentralized issue management and collaboration:
# Issue Management
just issues # List all issues
just issue <id> # View specific issue
just draft-issue <name> # Create issue draft locally
just create-issue "<title>" <draft> # Create Radicle issue from draft
# Patch Management
just patches # List all patches
just patch <id> # View specific patch
just patch-prep # Prepare code for patch submission
just patch-new # Create new patch
# Collaboration
just sync # Sync with Radicle network
just rad-peers # Show connected Radicle peers
just rad-status # Show Radicle node status
The project uses a local .issues/
workspace for drafting before creating Radicle issues:
.issues/
βββ README.md # Workflow documentation
βββ templates/ # Issue and patch templates
β βββ issue-template.md # Standard issue format
β βββ patch-template.md # Standard patch format
βββ drafts/ # Work-in-progress (git-ignored)
βββ temp/ # Temporary files (git-ignored)
Workflow:
- Draft locally:
just draft-issue networking-feature
- Edit draft:
.issues/drafts/networking-feature.md
- Create in Radicle:
just create-issue "Networking Feature" networking-feature
- Track progress:
just issue <issue-id>
- Clean up:
just clean-drafts
This approach gives you local file editing benefits while keeping Radicle as the source of truth.
The project includes comprehensive unit tests covering all core components:
# Run all tests (18 tests)
just test
# Run tests with verbose output
just test-verbose
# Run only unit tests
just test-unit
# Run specific test
just test-one test_storage_initialization
# Run tests with coverage (requires cargo-tarpaulin)
just test-coverage
Test Coverage:
- β Configuration parsing and validation
- β Error handling and display
- β Storage operations (blocks, transactions, UTXOs, mempool)
- β Actor message serialization
- β Database initialization and statistics
# Format code
just fmt
# Run linter
just lint
# Fix linting issues
just fix
# Watch for changes and run tests
just watch
# Generate project statistics
just stats
# Clean build artifacts and data
just clean
# Test REST API endpoints
just test-api-health
just test-api-info
just test-api-stats
# Test JSON-RPC endpoints
just test-rpc-info
just test-rpc-hash
# Initialize database with test data
just init-db
# Reset database
just reset-db
# Backup database
just backup-db
If you prefer using Cargo directly:
# Run tests
cargo test
# Development mode
RUST_LOG=debug cargo run
# Run with specific config
cargo run -- --config dev.toml --network regtest
Most commonly used commands:
Command | Description |
---|---|
just test |
Run all tests |
just build |
Build in debug mode |
just run-regtest |
Run in regtest mode |
just quick-check |
Format, lint, and test |
just dev |
Run with auto-reload |
just clean |
Clean all artifacts |
just stats |
Show project statistics |
just --list |
Show all available commands |
Active Issue: Implement P2P Networking and Peer Discovery
Issue ID: 09a530958b8db3b8899b9531edc4ae4cea041f7b
Current Phase: Network Foundation
- Create network constants module with magic bytes, ports, DNS seeds per network
- Enhance configuration for network-specific settings
- Generate network-specific config files (mainnet.toml, testnet.toml)
- Add network-aware Just commands
Next Phases: Peer Discovery β Connection Management β Protocol Messages β Integration
This project uses Radicle for decentralized collaboration:
π Radicle Project: https://app.radicle.xyz/nodes/seed.radicle.garden/rad:zz8CzpVqLxYXKHsiKzDBPBa474HQ
- Check active issues:
just issues
- Create feature branch:
git checkout -b feature/your-feature
- Draft your work:
just draft-issue your-feature
(optional) - Make your changes and add tests
- Prepare patch:
just patch-prep
- Submit patch:
just patch-new
- Sync with network:
just sync
For traditional Git workflows, you can still create pull requests, but we encourage using Radicle patches for a truly decentralized experience.
- Actor system architecture
- RocksDB storage layer
- Configuration management
- Logging and metrics
- Event publishing (ZMQ, K8s, Webhook)
- Comprehensive testing suite (18+ unit tests)
- Development tooling (50+ Just commands)
- API testing infrastructure
- P2P networking implementation
- Block and transaction validation
- UTXO set management
- Mempool fee estimation
- Initial block download
- Pruning support
- Compact block filters
- Lightning Network integration
- Advanced monitoring dashboards
This project is licensed under the MIT License - see the LICENSE file for details.
- Inspired by Bitcoin Knots
- Built with the Rust Bitcoin ecosystem
- Powered by Actix and RocksDB
BitKnotsRS - A modern, observable, cloud-native Bitcoin node implementation.