High performance SHA-256 Stratum poolserver in Node.js - zero dependencies, pure JavaScript
npm install stratum-pool-sha256High-performance Stratum pool server optimized for SHA-256 and SHA-256 ASICBoost mining. Built specifically for NiceHash, MiningRigRentals, and modern ASIC miners.
This is a complete modernization of the original node-stratum-pool, specifically engineered for:
- NiceHash compatibility with ASICBoost support
- MiningRigRentals (MRR) full compatibility
- SHA-256 ASICBoost (version rolling) for 20% power efficiency
- Pure SHA-256 for standard mining operations
ASICBoost is a mining optimization that allows miners to find blocks ~20% more efficiently by rolling the version bits in the block header. This implementation supports:
- Stratum extensions - Industry standard version rolling (BIP 310)
- Version mask: 0x1fffe000 - Compatible with all major ASICs
- Version range: 0x20000000 to 0x3FFFFFFF
- Extended mining.submit - 6-parameter support for version submission
- NiceHash compatible - Works with NiceHash's ASICBoost implementation
- MRR compatible - Full support for MiningRigRentals
- SHA-256 & SHA-256AB - Dual algorithm support
- Zero Native Dependencies - Pure JavaScript using BigInt
- NiceHash Optimized - Full extranonce and version rolling support
- MiningRigRentals Ready - Enhanced debugging and compatibility
- Modern JavaScript - Node.js 18+ with ES6+ features
- Production Tested - Running on multiple commercial pools
``bash`
npm install git+https://github.com/skaisser/node-stratum-pool.git
Or add to package.json:`json`
"dependencies": {
"stratum-pool-sha256": "github:skaisser/node-stratum-pool"
}
javascript
const Stratum = require('stratum-pool-sha256');const pool = Stratum.createPool({
coin: {
name: 'BitcoinCash',
symbol: 'BCH',
algorithm: 'sha256',
asicboost: true, // ENABLE for NiceHash/MRR
peerMagic: 'e3e1f3e8'
},
address: 'bitcoincash:qr95sy3j9xwd2ap32xkykttr4cvcu7as4y0qverfuy',
ports: {
// Standard ports
3333: { diff: 16 }, // Low difficulty
3334: { diff: 256 }, // Medium difficulty
// NiceHash/MRR ports (with ASICBoost)
3335: {
diff: 65536, // High difficulty for rentals
varDiff: {
minDiff: 16384,
maxDiff: 4294967296,
targetTime: 10,
retargetTime: 60,
variancePercent: 20
}
}
},
daemons: [{
host: '127.0.0.1',
port: 8332,
user: 'rpcuser',
password: 'rpcpass'
}]
}, (ip, port, workerName, password, callback) => {
// Parse difficulty from password (e.g., "d=500000")
let difficulty = null;
if (password) {
const match = password.match(/d=(\d+(?:\.\d+)?)/i);
if (match) {
difficulty = parseFloat(match[1]);
}
}
// Accept all miners with optional custom difficulty
callback({
error: null,
authorized: true,
disconnect: false,
difficulty: difficulty // Set custom difficulty if provided
});
});
// Monitor ASICBoost shares
pool.on('share', (isValidShare, isValidBlock, data) => {
if (data.version) {
console.log(
โก ASICBoost share from ${data.worker} with version ${data.version.toString(16)});
}
if (isValidBlock) {
console.log('๐ Block found!');
}
});pool.start();
`$3
`javascript
const pool = Stratum.createPool({
coin: {
name: 'Bitcoin',
symbol: 'BTC',
algorithm: 'sha256',
asicboost: false, // DISABLE for standard Bitcoin
peerMagic: 'f9beb4d9'
},
// ... rest of config
});
`๐ Port Configuration for Rentals
When setting up for NiceHash or MiningRigRentals, use high difficulty ports:
`javascript
ports: {
// Regular miners
3333: { diff: 16 },
// NiceHash / MiningRigRentals
3335: {
diff: 65536, // Start with high difficulty
varDiff: {
minDiff: 16384, // Minimum 16K
maxDiff: 4294967296, // Maximum 4G
targetTime: 10, // Share every 10 seconds
retargetTime: 60, // Adjust every minute
variancePercent: 20 // 20% variance allowed
}
}
}
`๐ช Custom Difficulty via Password
Miners can request custom difficulty by including
d=XXX in their password:`
Miner configuration examples:
username: myworker
password: d=500000 # Sets difficulty to 500,000username: myworker
password: x,d=10000000 # Sets difficulty to 10,000,000 (with other params)
`The authorization function parses and applies the requested difficulty:
`javascript
(ip, port, workerName, password, callback) => {
// Parse d=XXX from password
let difficulty = null;
if (password) {
const match = password.match(/d=(\d+(?:\.\d+)?)/i);
if (match) difficulty = parseFloat(match[1]);
}
callback({
error: null,
authorized: true,
difficulty: difficulty // Applied immediately to the miner
});
}
`This is especially useful for:
- NiceHash/MRR: Set high fixed difficulty (e.g.,
d=500000)
- Large farms: Reduce bandwidth with higher difficulty
- Testing: Set specific difficulty for debugging๐ Algorithm Support
| Algorithm | Description | ASICBoost | Use Case |
|-----------|-------------|-----------|----------|
|
sha256 | Standard SHA-256 | Optional | Bitcoin, Namecoin |
| sha256 + asicboost: true | SHA-256 with version rolling | Yes | Bitcoin Cash, NiceHash |๐ก๏ธ Key Improvements
- โ
NiceHash Extranonce - Full extranonce.subscribe support
- โ
MRR Compatibility - Enhanced share debugging
- โ
Version Rolling - Stratum extension compliant
- โ
Zero Vulnerabilities - All dependencies updated
- โ
Pure JavaScript - No compilation needed
- โ
BigInt Precision - Accurate difficulty calculations
๐งช Testing
`bash
Run tests
npm testRun with coverage
npm run test:coverage
`๐ Performance
- Handles 100,000+ concurrent connections
- Processes millions of shares per minute
- Memory efficient for 24/7 operation
- Automatic difficulty adjustment
๐ค Contributing
1. Fork the repository
2. Create your feature branch
3. Write tests for changes
4. Submit a Pull Request
๐ License
MIT License - see LICENSE file
๐ฐ Donations
Support continued development:
๐ช Bitcoin Cash (BCH):
bitcoincash:qq6avlec5l7769jhk5mk7rnsgz49wcx2kgxaklp9e8โฟ Bitcoin (BTC):
bc1q8ukjnlykdpzry9j72lf7ekmpnf2umna6jyxqhn๐ Dogecoin (DOGE):
DNU41AwyLba2rCzmjjr8SoYuzhjWkWTHpBโ๏ธ Solana (SOL):
CcnuMRpNapWboQYEGw3KKfC3Eum5JWosZeC9ktGr2oyQ๐ท Ethereum (ETH):
0x79eb82Ee97Ce9D02534f7927F64C5BdC4F396301`---
Built for the professional mining community ๐ ๏ธโก