Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes to support QRL #314

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions lib/pool.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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');
}
};
Expand Down Expand Up @@ -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';
}
Expand All @@ -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]
Expand Down
19 changes: 19 additions & 0 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -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));

Expand Down Expand Up @@ -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
}