diff --git a/lib/coins/aeon-rebase.js b/lib/coins/aeon-rebase.js index 08972d6..5517c3f 100644 --- a/lib/coins/aeon-rebase.js +++ b/lib/coins/aeon-rebase.js @@ -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); diff --git a/lib/coins/aeon.js b/lib/coins/aeon.js index c68082d..825155b 100644 --- a/lib/coins/aeon.js +++ b/lib/coins/aeon.js @@ -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); diff --git a/lib/coins/krb.js b/lib/coins/krb.js index 1494da8..5bbc020 100644 --- a/lib/coins/krb.js +++ b/lib/coins/krb.js @@ -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); diff --git a/lib/coins/xmr.js b/lib/coins/xmr.js index b51cd2d..5cc1244 100644 --- a/lib/coins/xmr.js +++ b/lib/coins/xmr.js @@ -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); } } diff --git a/lib/pool.js b/lib/pool.js index 0721368..25e76c7 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -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) {