Update for the Oct 2018 XMR hardfork.

Upgrade Instructions: git pull && npm install --upgrade nan && rm -rfv node_modules/cryptonight-hashing && npm i git+https://github.com/MoneroOcean/node-cryptonight-hashing.git

Thanks to MoneroOcean for maintaining the CN Hashing lib!
master
Alexander Blair 6 years ago
parent 4853b1b983
commit 3d6755e4fc

@ -8,6 +8,7 @@ const debug = require('debug')('coinFuncs');
let hexChars = new RegExp("[0-9a-f]+");
function Coin(data){
this.isxmr = false;
this.bestExchange = global.config.payout.bestExchange;
this.data = data;
let instanceId = crypto.randomBytes(4);

@ -8,6 +8,7 @@ const debug = require('debug')('coinFuncs');
let hexChars = new RegExp("[0-9a-f]+");
function Coin(data){
this.isxmr = false;
this.bestExchange = global.config.payout.bestExchange;
this.data = data;
let instanceId = crypto.randomBytes(4);

@ -8,6 +8,7 @@ const debug = require('debug')('coinFuncs');
let hexChars = new RegExp("[0-9a-f]+");
function Coin(data){
this.isxmr = false;
this.bestExchange = global.config.payout.bestExchange;
this.data = data;
let instanceId = crypto.randomBytes(4);

@ -8,6 +8,7 @@ const debug = require('debug')('coinFuncs');
let hexChars = new RegExp("[0-9a-f]+");
function Coin(data){
this.isxmr = true;
this.bestExchange = global.config.payout.bestExchange;
this.data = data;
let instanceId = crypto.randomBytes(4);
@ -163,7 +164,7 @@ function Coin(data){
};
this.cryptoNight = function(convertedBlob) {
return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0);
return multiHashing.cryptonight(convertedBlob, convertedBlob[0] >= 8 ? 8 : 1);
}
}

@ -9,6 +9,7 @@ const async = require('async');
const net = require('net');
const tls = require('tls');
const fs = require('fs');
const multiHashing = require("cryptonight-hashing");
let nonceCheck = new RegExp("^[0-9a-f]{8}$");
let bannedIPs = [];
@ -216,6 +217,7 @@ function Miner(id, login, pass, ipAddress, startingDiff, messageSender, protoVer
// prevent pool crash when pass is null
if (!pass) pass = 'x';
let pass_split = pass.split(":");
this.oldVersion = false;
this.error = "";
this.identifier = pass_split[0];
this.proxy = false;
@ -589,6 +591,11 @@ function recordShareData(miner, job, shareDiff, blockCandidate, hashHex, shareTy
}
function processShare(miner, job, blockTemplate, params) {
if (miner.oldVersion) {
sendReply("Incorrect hashing protocol in use. Please upgrade/fix your miner");
process.send({type: "invalidShare"});
return false;
}
let nonce = params.nonce;
let resultHash = params.result;
let template = new Buffer(blockTemplate.buffer.length);
@ -618,6 +625,22 @@ function processShare(miner, job, blockTemplate, params) {
shareType = false;
}
if (hash.toString('hex') !== resultHash) {
if (job.height >= 1546000 && coinFuncs.isxmr) {
hash = multiHashing.cryptonight(convertedBlob, 0);
if (hash.toString("hex") === resultHash) {
console.error(threadName + "Bad hashing algo (CN/0) from miner " + miner.logString);
process.send({type: "invalidShare"});
miner.oldVersion = true;
return false;
}
hash = multiHashing.cryptonight(convertedBlob, 1);
if (hash.toString("hex") === resultHash) {
console.error(threadName + "Bad hashing algo (CN/1) from miner " + miner.logString);
process.send({type: "invalidShare"});
miner.oldVersion = true;
return false;
}
}
console.error(threadName + "Bad share from miner " + miner.logString);
process.send({type: 'invalidShare'});
if (miner.incremented === false) {

Loading…
Cancel
Save