A minimal, neutral Bitcoin solo-mining client with clean architecture, GPU support, and comprehensive web dashboard.
Features • Quick Start • Documentation • Docker • GPU Mining
- Overview
- Features
- Quick Start
- Installation
- Configuration
- Docker
- GPU Mining
- Web Dashboard
- Project Structure
- Troubleshooting
- Contributing
- Deploy
SatoshiRig is a professional Bitcoin solo-mining client designed for simplicity, reliability, and performance. It features:
- Clean Architecture: Modular design with clear separation of concerns
- GPU Support: CUDA and OpenCL support for accelerated mining
- Web Dashboard: Real-time monitoring and control interface
- Docker Ready: Fully containerized with NVIDIA GPU support
- Configuration: Database-backed configuration with web UI
- Production Ready: Built for long-running mining operations
- ✅ Solo Mining: Direct connection to CKPool for solo Bitcoin mining
- ✅ GPU Support: CUDA and OpenCL backends with automatic fallback to CPU
- ✅ Parallel Batch Hashing: Optimized batch processing (1024 nonces per iteration)
- ✅ Sequential Nonce Counter: Complete coverage of the 32-bit nonce space
- ✅ Block Source: Configurable source (Blockchain Explorer or local Bitcoin Core RPC)
- 📊 Real-time Monitoring: Live hash rate, CPU, memory, and GPU metrics
- 📈 Performance Analytics: Historical charts and trend analysis
- 🧠 Mining Intelligence: Estimated time to block, probability calculations, profitability estimates
- ⚙️ Configuration UI: Web-based settings for all mining parameters (pool, network, compute, database)
- 🎛️ GPU Utilization Control: Configure GPU usage percentage (1-100%) to allow other GPU tasks to run simultaneously
- 💾 Persistent Statistics: Statistics are automatically saved and persist across Docker restarts
- 🔄 CPU/GPU Toggle Control: Independent toggles for CPU and GPU mining with intelligent backend selection
- 🎨 Modern UI: Tabbed interface with dark/light theme support
- 📱 Responsive Design: Works on desktop and mobile devices
- 🔧 Database Configuration: All settings stored in SQLite database, manageable via web UI
- 🐳 Docker Support: Pre-built images on GitHub Container Registry
- 📝 Comprehensive Logging: Configurable log levels with Docker logs integration (stdout/stderr)
- 🚀 CI/CD Ready: Automated builds and releases
# Pull the latest image
docker pull ghcr.io/rokk001/satoshirig:latest
# Run the container (bind-mount data directory for persistent configuration)
docker run -d \
--name satoshirig \
--restart unless-stopped \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/logs:/app/logs" \
-p 5000:5000 \
ghcr.io/rokk001/satoshirig:latestAfter the container is running, open http://localhost:5000, enter your wallet address under Settings → Wallet Configuration, click Save Configuration, and then click Start Mining to begin.
# Clone repository
git clone https://github.com/Rokk001/SatoshiRig.git
cd SatoshiRig
# Install dependencies
pip install -r requirements.txt
# Run miner
python -m SatoshiRig --wallet YOUR_BTC_ADDRESSIf you start the miner without
--wallet, the web dashboard will still launch so you can configure the address, but mining will not begin until you set the wallet and restart the process.
- Python: 3.11 or higher
- Docker: 19.03+ (for containerized deployment)
- NVIDIA Container Toolkit: (for GPU mining with Docker)
The easiest way to run SatoshiRig is using the pre-built Docker image:
docker pull ghcr.io/rokk001/satoshirig:latest-
Clone the repository:
git clone https://github.com/Rokk001/SatoshiRig.git cd SatoshiRig -
Install Python dependencies:
pip install -r requirements.txt
-
Install GPU dependencies (optional):
pip install pycuda>=2023.1 pyopencl>=2023.1.2
All configuration can be done via environment variables:
| Variable | Required | Default | Description |
|---|---|---|---|
COMPUTE_BACKEND |
No | cpu |
Compute backend: cpu, cuda, or opencl |
GPU_DEVICE |
No | 0 |
GPU device index (for CUDA/OpenCL backends) |
GPU_UTILIZATION_PERCENT |
No | 100 |
GPU utilization percentage (1-100%) for time-slicing support |
WEB_PORT |
No | 5000 |
Web dashboard port (set to 0 to disable) |
STATE_DB |
No | ./data/state.db |
Path to the SQLite database used for dynamic settings and statistics |
CORS_ORIGINS |
No | http://localhost:5000,http://127.0.0.1:5000 |
Comma-separated list of allowed CORS origins, or * to allow all origins (less secure) |
LOG_LEVEL |
No | INFO |
Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL (logs go to stdout/stderr for Docker logs) |
NVIDIA_VISIBLE_DEVICES |
No* | all |
NVIDIA GPU visibility (*only for NVIDIA GPU) |
NVIDIA_DRIVER_CAPABILITIES |
No* | compute,utility |
NVIDIA driver capabilities (*only for NVIDIA GPU) |
Note: All configuration is now managed via the web dashboard (Settings → Configuration). The wallet address, pool settings, network configuration, compute settings, and logging configuration are all stored in the SQLite database (
data/state.dbby default, override viaSTATE_DB).
compute.backendrepresents the chosen GPU runtime (CUDA/OpenCL). CPU mining is controlled exclusively via the CPU Mining Enabled toggle in the web UI.All runtime settings (wallet address, pool configuration, compute toggles, statistics, etc.) are persisted in a lightweight SQLite database. By default this file lives at
data/state.db(overridable viaSTATE_DB). Make sure thedata/directory is writable or bind-mounted when running inside Docker.
python -m SatoshiRig --helpAvailable options:
--wallet,-w: Bitcoin wallet address (optional, can be set via web UI)--backend: Compute backend (cpu,cuda,opencl)--gpu: GPU device index--web-port: Web dashboard port (default: 5000)--no-web: Disable web dashboard
Option 1: Use published image from GHCR (recommended):
docker run -d \
--name satoshirig \
--restart unless-stopped \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/logs:/app/logs" \
-p 5000:5000 \
ghcr.io/rokk001/satoshirig:latestConfigure your wallet address via the web UI at
http://localhost:5000(Settings → Wallet Configuration), then click Start Mining.
Option 2: Build locally:
docker build -t satoshirig .
docker run -d \
--name satoshirig \
--restart unless-stopped \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/logs:/app/logs" \
-p 5000:5000 \
satoshirigConfigure your wallet address via the web UI at
http://localhost:5000(Settings → Wallet Configuration), then click Start Mining.
- Published Image:
ghcr.io/rokk001/satoshirig:latest(public, automatically updated) - Base Image: Multi-stage build. Final image uses
nvidia/cuda:11.8.0-runtime-ubuntu22.04(smaller). Build stage briefly usesdevelto compile GPU wheels. - Working Directory:
/app - Default Database:
/app/data/state.db(stores all configuration and statistics) - Default Web Port:
5000
Example docker-compose.yml:
services:
satoshirig:
image: ghcr.io/rokk001/satoshirig:latest
container_name: satoshirig
restart: unless-stopped
runtime: nvidia
gpus: all
environment:
- COMPUTE_BACKEND=cuda
- GPU_DEVICE=0
- WEB_PORT=5000
ports:
- "5000:5000"
volumes:
- ./data:/app/data # Persistent configuration and statistics storage
# Note: Logs are written to stdout/stderr and visible via `docker logs`
### Persistent Statistics
SatoshiRig automatically saves mining statistics to a persistent JSON file (`/app/data/statistics.json` by default). This ensures that your statistics (total hashes, peak hash rate, shares submitted/accepted/rejected) are preserved across Docker container restarts.
The statistics file is automatically:
- **Loaded on startup**: Previous statistics are restored when the container starts
- **Saved periodically**: Statistics are auto-saved every 10 status updates
- **Saved on shutdown**: Final statistics are saved when the container stops
To persist statistics in Docker, mount a volume for the data directory:
```yaml
volumes:
- ./data:/app/dataTo enable GPU access, install the NVIDIA Container Toolkit on the host and run with --gpus all (or runtime: nvidia). The toolkit passes the NVIDIA driver and devices into the container; the image only needs CUDA runtime libraries.
- Docs: NVIDIA Container Toolkit
Notes:
- The image is now significantly smaller because the CUDA developer toolchain is not shipped in the final layer. GPU Python deps are compiled in a build stage and only the wheels are copied into the runtime image.
Start with:
```bash
docker compose up -d
Prerequisites:
- NVIDIA GPU with CUDA support
- NVIDIA Container Toolkit installed
- Docker with GPU support enabled
Method 1: Using --gpus flag (recommended for Docker 19.03+):
docker run -d \
--name satoshirig \
--restart unless-stopped \
--gpus all \
-e COMPUTE_BACKEND=cuda \
-e GPU_DEVICE=0 \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/logs:/app/logs" \
-p 5000:5000 \
ghcr.io/rokk001/satoshirig:latestMethod 2: Using --runtime=nvidia (for older Docker versions):
docker run -d \
--name satoshirig \
--restart unless-stopped \
--runtime=nvidia \
-e COMPUTE_BACKEND=cuda \
-e GPU_DEVICE=0 \
-e NVIDIA_VISIBLE_DEVICES=all \
-e NVIDIA_DRIVER_CAPABILITIES=compute,utility \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/logs:/app/logs" \
-p 5000:5000 \
ghcr.io/rokk001/satoshirig:latestSpecific GPU:
docker run -d \
--name satoshirig \
--gpus device=0 \
-e COMPUTE_BACKEND=cuda \
-e GPU_DEVICE=0 \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/logs:/app/logs" \
-p 5000:5000 \
ghcr.io/rokk001/satoshirig:latestFor AMD GPUs or integrated GPUs using OpenCL:
docker run -d \
--name satoshirig \
--device=/dev/dri:/dev/dri \
-e COMPUTE_BACKEND=opencl \
-e GPU_DEVICE=0 \
-v "$(pwd)/data:/app/data" \
-v "$(pwd)/logs:/app/logs" \
-p 5000:5000 \
ghcr.io/rokk001/satoshirig:latest- Automatic Fallback: The miner automatically falls back to CPU if GPU initialization fails
- Batch Processing: GPU mining uses parallel batch hashing (1024 nonces per iteration)
- Sequential Nonce Counter: Complete coverage of the 32-bit nonce space
- GPU Utilization Control: Configure GPU usage percentage (1-100%) via web UI or config to allow other GPU tasks (e.g., video transcoding) to run simultaneously
- Time-Slicing: When GPU utilization is set below 100%, the miner automatically pauses between batches to free up GPU resources
The web dashboard provides real-time monitoring and control of your mining operation.
Once running, access the dashboard at:
- Local:
http://localhost:5000 - Docker:
http://<container-ip>:5000 - Remote:
http://<host-ip>:5000
- Mining status and basic metrics
- Hash rate, uptime, and shares
- Wallet address with blockchain explorer link
- Pool connection status
- System Resources: CPU, Memory, GPU usage and temperature
- Performance Dashboard: Real-time metrics visualization
- GPU Monitoring: NVIDIA GPU metrics (if available)
- Hash Rate History: Historical hash rate trends
- Difficulty History: Network difficulty over time
- Comparison Charts: Hash rate vs difficulty analysis
- Estimated Time to Block: Formatted in years, months, and days
- Block Found Probability: Probability of finding a block in the next hour
- Estimated Profitability: BTC per day estimate
- Difficulty Trend: Network difficulty trend analysis (increasing/decreasing/stable)
- Share History: Recent share submissions
- Statistics Table: Comprehensive mining statistics
- Wallet Configuration: Bitcoin wallet address management
- Pool Configuration: Host and port settings
- Network Configuration: Block source (web/local), RPC settings
- Compute Configuration:
- GPU Backend selection (CUDA/OpenCL) – defines which GPU runtime is used when GPU mining is enabled
- GPU device, batch size, workers, GPU utilization percentage
- CPU Mining Toggle: Enable/disable CPU mining independently of the backend selection
- GPU Mining Toggle: Enable/disable GPU mining; when enabled the selected GPU backend is used automatically (CUDA by default)
- Both CPU and GPU can be enabled simultaneously for combined mining; if both toggles are off, mining stops completely
- Database Configuration: Retention period in days
Security Note: Sensitive data (wallet address, RPC passwords) are not pre-filled from Docker environment variables for security reasons. You must enter these manually in the web UI.
CSRF Protection: The web dashboard includes CSRF protection. Same-origin requests are automatically allowed. For cross-origin access, set CORS_ORIGINS to a comma-separated list of allowed origins (e.g., http://satoshirig.zhome.ch,http://localhost:5000), or use * to allow all origins (less secure but convenient for local networks).
Configuration values are loaded from:
- SQLite database (
data/state.dbby default) - Docker environment variables (e.g.,
COMPUTE_BACKEND,GPU_DEVICE,LOG_LEVEL) - Default values if not specified
Changes made in the web UI are saved to the database and can be applied to the running miner immediately (logging level changes apply instantly, miner restart may be required for some settings). All logs are written to stdout/stderr and can be viewed with docker logs satoshirig.
- Hash Values: Automatically formatted with magnitude units (K, M, G, T, P, E)
- Example:
145.79 KH/sinstead of145788.53 H/s
- Example:
- Time Estimates: Displayed in years, months, and days
- Example:
143640979699 years, 10 months, 8.5 days
- Example:
- Pause/Resume: Control mining via the web interface
- Theme Toggle: Switch between dark and light themes
- Auto-refresh: Real-time updates via WebSocket
SatoshiRig/
├── src/
│ └── SatoshiRig/
│ ├── __init__.py
│ ├── __main__.py
│ ├── cli.py # Command-line interface
│ ├── config.py # Database-backed configuration loader
│ ├── miner.py # Backward-compatible facade (DEPRECATED)
│ ├── clients/
│ │ ├── __init__.py # Client module exports
│ │ └── pool_client.py # CKPool TCP JSON client
│ ├── core/
│ │ ├── __init__.py # Core module exports
│ │ ├── miner.py # Core mining logic
│ │ ├── state.py # Miner state management
│ │ └── gpu_compute.py # GPU compute (CUDA/OpenCL)
│ ├── utils/
│ │ ├── __init__.py # Utility module exports
│ │ └── formatting.py # Formatting utilities (hash, time)
│ └── web/
│ ├── __init__.py # Web module exports
│ ├── server.py # Flask web server with SocketIO
│ └── status.py # Status management
├── tests/
│ ├── __init__.py
│ ├── unit/ # Unit tests
│ │ └── __init__.py
│ ├── integration/ # Integration tests
│ │ └── __init__.py
│ └── test_smoke.py # Smoke tests
├── data/
│ └── state.db # SQLite database (configuration and statistics)
├── .github/
│ └── workflows/ # CI/CD workflows
├── Dockerfile # Docker image definition
├── docker-compose.yml # Docker Compose configuration
├── pyproject.toml # Python project metadata
├── requirements.txt # Python dependencies
└── README.md # This file
Problem: Build fails with CUDA header errors
Solution: The Docker image uses nvidia/cuda:11.8.0-devel-ubuntu22.04 which includes CUDA development tools. Ensure you're using the latest version of the Dockerfile.
Problem: GPU mining falls back to CPU
Checklist:
- Verify GPU is available:
nvidia-smi(for NVIDIA) - Ensure
--gpus allor--runtime=nvidiais set - Check
COMPUTE_BACKEND=cudaorCOMPUTE_BACKEND=openclis set - Review logs for GPU initialization errors
- Verify NVIDIA Container Toolkit is installed
Problem: Cannot access dashboard at http://localhost:5000
Solution:
- Check if
WEB_PORTis set to0(disabled) - Verify port mapping:
-p 5000:5000orports: ["5000:5000"] - Check firewall settings
- Review container logs for errors
Problem: Docker image not accessible from GHCR
Solution: The package should be automatically set to public. If not:
- Go to GitHub Packages: https://github.com/Rokk001?tab=packages
- Select the
satoshirigpackage - Go to "Package settings" → "Change visibility" → "Make public"
Solution: The TCP client now uses line-buffered reads and tolerates partial frames. If issues persist, check network stability and pool availability.
Note: CI, release, and Docker publish workflows run only via manual trigger (workflow_dispatch). See DEPLOY.md for how to publish the image and create a release.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
- Follow PEP 8 for Python code
- Use type hints where appropriate
- Add docstrings to functions and classes
This project is licensed under the MIT License.
- GitHub Repository: https://github.com/Rokk001/SatoshiRig
- Docker Image:
ghcr.io/rokk001/satoshirig:latest - GitHub Packages: https://github.com/Rokk001?tab=packages&package_name=satoshirig
See DEPLOY.md for manual publish via GitHub Actions and GPU run instructions. Workflows are manual-only; trigger them from Actions when you want to publish.
GPU mining support is implemented with CUDA/OpenCL backends. The Docker image uses NVIDIA CUDA base image (nvidia/cuda:11.8.0-devel-ubuntu22.04) for proper GPU support. The miner automatically uses GPU if available and configured, otherwise falls back to CPU. GPU mining uses parallel batch hashing (1024 nonces per iteration) with sequential nonce counter for complete coverage. Enhanced GPU initialization with better error handling and device validation. For optimal performance, GPU kernels can be further optimized.
- Hash values (Hash Rate, Peak Hash Rate, Average Hash Rate, Total Hashes) are automatically formatted with magnitude units (K, M, G, T, P, E) for better readability.
- Estimated time to block is displayed in years, months, and days for easier comprehension of very large time periods.
Made with ❤️ for the Bitcoin community
⭐ Star this repo if you find it useful!