Thanks to visit codestin.com
Credit goes to github.com

Skip to content

CL-LLC/night-miner

 
 

Repository files navigation

🌙 Night Miner for Ubuntu/Linux

Python 3.10+ Ubuntu 20.04+ License: MIT

High-performance automated miner for the NIGHT Token Scavenger Mine program, optimized for Ubuntu Linux.

Features: Multi-threading • Native Linux • Automatic backups • Systemd integration • Free & Open Source


🚀 Quick Start

Installation (Ubuntu 20.04+)

# Clone and setup
git clone https://github.com/CL-LLC/night-miner-linux.git
cd night-miner-linux
chmod +x install.sh
./install.sh

# Start mining!
./run_miner.sh

Alternative Installation (Manual)

# Install system dependencies
sudo apt-get update
sudo apt-get install -y python3 python3-venv libsodium-dev libssl-dev libgmp-dev

# Download Cardano CLI tools
wget -q https://github.com/IntersectMBO/cardano-node/releases/download/10.3.1/cardano-node-10.3.1-linux.tar.gz
tar -xzf cardano-node-10.3.1-linux.tar.gz && cp bin/cardano-cli bin/bech32 . && rm -rf bin/ share/ *.tar.gz

# Install Python dependencies
python3 -m venv venv && source venv/bin/activate && pip install requests

# Start mining
python3 night_miner.py --threads 8

📋 System Requirements

Requirement Minimum Recommended
OS Ubuntu 20.04 LTS Ubuntu 22.04+ LTS
CPU 2 cores 4+ cores
RAM 2 GB 4+ GB
Storage 2 GB 4+ GB
Python 3.10+ 3.13+
Network Stable internet Stable fiber

⚙️ Usage

Basic Usage

# Use all available cores
./run_miner.sh

# Use specific number of threads
./run_miner.sh --threads 8

# Show help
./run_miner.sh --help

Advanced Usage

# Run with lower system priority
nice -n 19 ./run_miner.sh --threads 6

# Run in background
nohup ./run_miner.sh --threads 8 > mining.log 2>&1 &

# Monitor mining logs
tail -f mining.log

Configuration Options

Option Description Default
--threads Number of mining threads CPU count
No other options required

🔥 Mining Process

First Time Setup

  1. Terms Agreement: Read and accept NIGHT Token terms and developer agreement
  2. Developer Address: Automatic assignment from developer pool
  3. Wallet Creation: Addresses generated as needed during mining
  4. Backup: Wait 2-4 hours, then backup your wallet

Mining Workflow

📡 Fetch Challenge → 🔍 Multi-threaded Mining → ✅ Find Solution → 📤 Submit → 🔄 Next Challenge

Mining Output Examples

🌙 Starting NIGHT Token Miner with 8 threads
📁 Wallet directory: /path/to/night-miner-ubuntu/auto-mine-wallet
⚠️  CRITICAL: Back up your auto-mine-wallet/ folder regularly!

🔥 Mining with address 0: addr_test1vrku2c0f2qqdcccq4ua03dfl523p5pkkucrhfwhlx68cc6g2q4h90
⛏️  Mining...
✅ Thread 3 found nonce: 8f4a2c1b
✅ Solution submitted successfully! Nonce: 8f4a2c1b | Time: 12.34s
⏳ Waiting 3600 seconds for next challenge...

💼 Wallet Management

⚠️ CRITICAL: Back Up Your Wallet!

Your auto-mine-wallet/ folder contains the keys to claim your rewards. Losing it means losing all mined NIGHT tokens permanently.

What's in Your Wallet

auto-mine-wallet/
├── wallet.json           # Complete address registry
├── addr-0.skey            # Private key #1 (CRITICAL)
├── addr-1.skey            # Private key #2 (CRITICAL)
├── addr-*.skey            # More private keys
├── addr-*.vkey            # Verification keys
├── addr-*.addr            # Address files
├── .priority             # Assigned developer address
└── .agreement            # Terms acceptance record

Backup Commands

# Quick backup
cp -r auto-mine-wallet/ "backup-$(date +%Y-%m-%d-%H%M)"

# Automated backup (recommended)
./backup_wallet.sh

# Verify backup
ls -la backup-*/

Backup Strategy

  1. Wait 2-4 hours: Let the miner generate addresses first
  2. Initial backup: Your first backup should be substantial
  3. Regular backups: Every 6-12 hours during active mining
  4. Multiple locations: Store backups externally (cloud + USB)
  5. Test restoration: Verify you can restore from backup

🔧 Installation Details

Automatic Installation (install.sh)

The installer handles:

  • ✅ Python environment setup (venv for newer Ubuntu)
  • ✅ System dependency checking
  • ✅ Cardano CLI binary download & setup
  • ✅ Permissions configuration
  • ✅ Service file preparation

Manual Installation Steps

  1. System Dependencies

    sudo apt-get update
    sudo apt-get install -y python3 python3-venv libsodium-dev libssl-dev libgmp-dev
  2. Cardano CLI Tools

    wget -q https://github.com/IntersectMBO/cardano-node/releases/download/10.3.1/cardano-node-10.3.1-linux.tar.gz
    tar -xzf cardano-node-10.3.1-linux.tar.gz
    cp bin/cardano-cli bin/bech32 ./
    rm -rf bin/ share/ *.tar.gz
    chmod +x cardano-cli bech32
  3. Python Dependencies

    python3 -m venv venv
    source venv/bin/activate
    pip install requests

Verification

# Test Cardano CLI
./cardano-cli --version
./bech32 --version

# Test Miner
./run_miner.sh --help

🖥️ System Integration

Background Service (Optional)

# Install as systemd service
./systemd_setup.sh

# Start/stop service
sudo systemctl start night-miner
sudo systemctl stop night-miner

# View logs
sudo journalctl -f -u night-miner

Performance Tuning

# CPU performance mode
echo performance | sudo tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

# Disable swap temporarily
sudo swapoff -a

# Process priority adjustment
nice -n 19 ./run_miner.sh --threads 6

File Structure

night-miner-ubuntu/
├── src/
│   ├── night_miner.py        # Main miner script
│   └── requirements.txt       # Python dependencies
├── bin/
│   ├── cardano-cli            # Cardano CLI binary
│   └── bech32                 # Bech32 tool
├── venv/                      # Python virtual environment
├── auto-mine-wallet/          # Mining wallet (created during mining)
├── install.sh                # Installation script
├── run_miner.sh             # Miner launcher
├── backup_wallet.sh         # Backup utility
├── systemd_setup.sh         # Service setup
├── README.md                 # This file
└── miner.log                # Mining logs

🛠️ Troubleshooting

Common Issues

"externally-managed-environment" Error

# The install.sh script handles this automatically
# If you see this error manually:
python3 -m venv venv
source venv/bin/activate
pip install -r src/requirements.txt

Permission Denied

# Make scripts executable
chmod +x *.sh src/night_miner.py bin/cardano-cli bin/bech32

Missing System Libraries

# Install required packages
sudo apt-get install -y libsodium-dev libssl-dev libgmp-dev

Cardano CLI Errors

# Test binaries directly
./cardano-cli --version
./bech32 --version

# Re-download if broken
rm -f cardano-cli bech32
# Re-run installation script or manual steps

Network Issues

# Test API connectivity
curl -I https://scavenger-api.midnight.network

# Check firewall
sudo ufw status
# If blocked: sudo ufw allow out 443

Debug Mode

# Run with verbose logging
python3 src/night_miner.py --threads 2

# Check system resources
htop                     # CPU usage
free -h                   # Memory usage
df -h                     # Disk space

Performance Issues

Symptom Solution
High CPU usage Normal - mining is CPU-intensive
Low success rate Check network, try more threads
System sluggish Use nice priority, reduce threads
Frequent timeouts Check internet stability

📊 Mining Performance

Thread Configuration Guidelines

CPU Cores Recommended Threads Reasoning
2 cores 2-3 threads Physical cores + 1 hyperthread
4 cores 6 threads All physical + 2 hyperthreads
8 cores 12 threads Physical + half hyperthreads
16+ cores CPU cores × 0.75 Leave some cores for system

Success Metrics

  • Nonce Finding: 1-5 solutions per hour (varies by difficulty)
  • Address Generation: 1 new address per successful submission
  • Network Latency: <500ms response time optimal

🔒 Security Considerations

🔐 Critical Security Practices

  1. Private Key Protection

    • Never share .skey files
    • Store backups in encrypted locations
    • Consider hardware wallet integration
  2. Access Control

    # Restrict wallet directory permissions
    chmod 700 auto-mine-wallet/
    chmod 600 auto-mine-wallet/*.skey
  3. Network Security

    • Use VPN if in restrictive regions
    • Monitor API connections
    • Verify binary checksums
  4. System Hardening

    # Create dedicated mining user (optional)
    sudo useradd -r -s /bin/false nightminer
    sudo chown -R nightminer:nightminer night-miner-ubuntu/

🚨 Security Warnings

  • ⚠️ NEVER share your auto-mine-wallet/ folder
  • ⚠️ NEVER commit wallet files to version control
  • ⚠️ ALWAYS verify binary authenticity
  • ⚠️ BACKUP EARLY AND OFTEN

📱 Community & Support

🤝 Getting Help

📚 Resources

🗣️ Community Channels

  • Discord: Midnight Network community
  • Telegram: NIGHT token discussions
  • Reddit: r/Cardano and r/CryptoCurrency

🔬 Technical Details

Mining Algorithm

# Simplified nonce finding logic
for nonce in range(start_range, end_range):
    hash_input = f"{address}{nonce}{challenge_id}".encode()
    hash_result = sha256(hash_input).hexdigest()
    
    if hash_result.startswith("0" * difficulty):
        return nonce  # Solution found!

API Integration

Endpoint Method Purpose
/api/v1/challenge GET Get current challenge
/api/v1/submit POST Submit solution
/api/v1/register POST Register address
/api/v1/status GET Check system status

Address Generation

# Cardano CLI command used
cardano-cli address key-gen \
  --verification-key-file payment.vkey \
  --signing-key-file payment.skey

cardano-cli address build \
  --payment-verification-key-file payment.vkey \
  --testnet-magic 1 \
  --out-file payment.addr

📄 License & Warranty

📜 License

MIT License - Free for personal and commercial use

⚖️ Disclaimer

  • This software is provided "as is" without warranty
  • Mining results are not guaranteed and vary by:
    • Network difficulty and competition
    • Internet connection stability
    • Hardware performance and luck
  • Use at your own risk - you accept full responsibility

🤝 Developer Compensation

By using this miner, you agree to:

  1. Mine 1 solution per challenge for the developer
  2. Keep remaining solutions for your generated addresses
  3. Accept terms displayed during initial setup

🚀 Roadmap & Future Development

📋 Planned Enhancements

  • GPU Acceleration - CUDA/OpenCL support
  • Advanced Monitoring - Web dashboard interface
  • Package Distribution - APT repository support
  • Multi-distro Support - Fedora, Arch, Debian packages
  • ARM Compatibility - Raspberry Pi, ARM servers

🔄 Version History

  • v1.0.0 - Initial Ubuntu release with full Windows feature parity
  • Full changelog available on GitHub Releases

🎯 Quick Installation Checklist

  • System Requirements Met: Ubuntu 20.04+, Python 3.10+
  • Dependencies Installed: ./install.sh completed successfully
  • Binaries Working: cardano-cli --version returns output
  • Mining Started: ./run_miner.sh shows active mining
  • Terms Accepted: You typed "agree" during setup
  • Backup Plan: Automated backup script ready to run
  • Monitoring: Mining output showing solution attempts

🌟 Thank You!

Happy Mining! 🌙

Your participation helps strengthen the Midnight Network. Remember to secure your wallet keys and join our community for updates and support!


Last updated: November 2024
Made with ❤️ for the Midnight Network community

About

A NIGHT miner for the Midnight Scavenger Hunt

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 77.5%
  • Python 22.5%