From 016329ce431039f9ad79c2f96c22b13ace52bfa4 Mon Sep 17 00:00:00 2001 From: cyyber Date: Fri, 30 Mar 2018 16:53:41 +0530 Subject: [PATCH 1/2] Added Address Validation Function for QRL address format --- lib/utils.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/utils.js b/lib/utils.js index 334cfbe42..2b5d69531 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -1,5 +1,6 @@ var base58 = require('base58-native'); var cnUtil = require('cryptonote-util'); +var crypto = require('crypto'); var addressBase58Prefix = cnUtil.address_decode(new Buffer(config.poolServer.poolAddress)); @@ -57,3 +58,21 @@ exports.isValidAddress = function(addr){ return addressBase58Prefix === cnUtil.address_decode(new Buffer(addr)); }; + +function qrlAddressValidator(addr) { + + + if(addr.length != 79) + return false; + + var address = addr.substring(1); + var addr_buff = new Buffer(address, 'hex'); + + const hash = crypto.createHash('sha256').update(addr_buff.slice(0, 35)); + + return hash.digest('hex').slice(56) === addr_buff.slice(35).toString('hex') +}; + +if(config.symbol === "QRL") { + exports.isValidAddress = qrlAddressValidator +} From b2a2dc74b9191f61bfc307c71a8a11c555795779 Mon Sep 17 00:00:00 2001 From: cyyber Date: Sat, 31 Mar 2018 17:16:24 +0530 Subject: [PATCH 2/2] Adjusted pool.js to support QRL --- lib/pool.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index ee7f1ab09..ed34eec7f 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -52,7 +52,7 @@ var shareTrustMinFloat = shareTrustEnabled ? config.poolServer.shareTrust.min / var banningEnabled = config.poolServer.banning && config.poolServer.banning.enabled; var isMonero = config.coin === "monero"; - +var isQRL = config.symbol === "QRL"; setInterval(function(){ var now = Date.now() / 1000 | 0; @@ -127,6 +127,8 @@ function BlockTemplate(template){ BlockTemplate.prototype = { nextBlob: function(){ this.buffer.writeUInt32BE(++this.extraNonce, this.reserveOffset); + if(isQRL) + return this.buffer.toString('hex'); return cnUtil.convert_blob(this.buffer).toString('hex'); } }; @@ -435,8 +437,14 @@ function processShare(miner, job, blockTemplate, nonce, resultHash){ shareType = 'trusted'; } else { - convertedBlob = cnUtil.convert_blob(shareBuffer); - var cn_variant = isMonero && convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0; + if(isQRL) { + convertedBlob = shareBuffer; + var cn_variant = 1; + } + else { + convertedBlob = cnUtil.convert_blob(shareBuffer); + var cn_variant = isMonero && convertedBlob[0] >= 7 ? convertedBlob[0] - 6 : 0; + } hash = cryptoNight(convertedBlob, cn_variant); shareType = 'valid'; } @@ -462,7 +470,12 @@ function processShare(miner, job, blockTemplate, nonce, resultHash){ recordShareData(miner, job, hashDiff.toString(), false, null, shareType); } else{ - var blockFastHash = cryptoNightFast(convertedBlob || cnUtil.convert_blob(shareBuffer)).toString('hex'); + if(isQRL) { + var blockFastHash = hash.toString('hex') + } + else { + var blockFastHash = cryptoNightFast(convertedBlob || cnUtil.convert_blob(shareBuffer)).toString('hex'); + } log('info', logSystem, 'Block %s found at height %d by miner %s@%s - submit result: %j', [blockFastHash.substr(0, 6), job.height, miner.login, miner.ip, result]