Added client-side mining key generation script for coin-switching port mining
This commit is contained in:
parent
33d5b9ccf6
commit
5ea852d369
|
@ -502,7 +502,8 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
}
|
||||
})();
|
||||
movePendingCommands.push(['smove', coin + '_blocksPending', coin + destinationSet, r.serialized]);
|
||||
roundsToDelete.push(coin + '_shares:round' + r.height)
|
||||
if (r.category === 'generate')
|
||||
roundsToDelete.push(coin + '_shares:round' + r.height)
|
||||
});
|
||||
|
||||
var finalRedisCommands = [];
|
||||
|
@ -660,7 +661,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||
|
||||
daemon.cmd('sendmany', [processingConfig.feeCollectAccount, withdrawal], function(results){
|
||||
if (results[0].error){
|
||||
logger.debug(logSystem, logComponent, 'Profit withdrawal finished - error with sendmany '
|
||||
logger.debug(logSystem, logComponent, 'Profit withdrawal of ' + withdrawalAmount + ' failed - error with sendmany '
|
||||
+ JSON.stringify(results[0].error));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3,18 +3,24 @@ var fs = require('fs');
|
|||
var path = require('path');
|
||||
|
||||
var async = require('async');
|
||||
var watch = require('node-watch');
|
||||
var redis = require('redis');
|
||||
|
||||
var dot = require('dot');
|
||||
var express = require('express');
|
||||
var bodyParser = require('body-parser');
|
||||
var compress = require('compression');
|
||||
|
||||
var watch = require('node-watch');
|
||||
var Stratum = require('stratum-pool');
|
||||
var util = require('stratum-pool/lib/util.js');
|
||||
|
||||
var api = require('./api.js');
|
||||
|
||||
|
||||
module.exports = function(logger){
|
||||
|
||||
dot.templateSettings.strip = false;
|
||||
|
||||
var portalConfig = JSON.parse(process.env.portalConfig);
|
||||
var poolConfigs = JSON.parse(process.env.pools);
|
||||
|
||||
|
@ -33,7 +39,8 @@ module.exports = function(logger){
|
|||
'stats.html': 'stats',
|
||||
'tbs.html': 'tbs',
|
||||
'api.html': 'api',
|
||||
'admin.html': 'admin'
|
||||
'admin.html': 'admin',
|
||||
'mining_key.html': 'mining_key'
|
||||
};
|
||||
|
||||
var pageTemplates = {};
|
||||
|
@ -41,6 +48,9 @@ module.exports = function(logger){
|
|||
var pageProcessed = {};
|
||||
var indexesProcessed = {};
|
||||
|
||||
var keyScriptTemplate = '';
|
||||
var keyScriptProcessed = '';
|
||||
|
||||
|
||||
var processTemplates = function(){
|
||||
|
||||
|
@ -113,6 +123,87 @@ module.exports = function(logger){
|
|||
setInterval(buildUpdatedWebsite, websiteConfig.stats.updateInterval * 1000);
|
||||
|
||||
|
||||
var buildKeyScriptPage = function(){
|
||||
async.waterfall([
|
||||
function(callback){
|
||||
var client = redis.createClient(portalConfig.redis.port, portalConfig.redis.host);
|
||||
client.hgetall('coinVersionBytes', function(err, coinBytes){
|
||||
if (err){
|
||||
client.quit();
|
||||
return callback('Failed grabbing coin version bytes from redis ' + JSON.stringify(err));
|
||||
}
|
||||
callback(null, client, coinBytes || {});
|
||||
});
|
||||
},
|
||||
function (client, coinBytes, callback){
|
||||
var enabledCoins = Object.keys(poolConfigs).map(function(c){return c.toLowerCase()});
|
||||
var missingCoins = [];
|
||||
enabledCoins.forEach(function(c){
|
||||
if (!(c in coinBytes))
|
||||
missingCoins.push(c);
|
||||
});
|
||||
callback(null, client, coinBytes, missingCoins);
|
||||
},
|
||||
function(client, coinBytes, missingCoins, callback){
|
||||
var coinsForRedis = {};
|
||||
async.each(missingCoins, function(c, cback){
|
||||
var coinInfo = (function(){
|
||||
for (var pName in poolConfigs){
|
||||
if (pName.toLowerCase() === c)
|
||||
return {
|
||||
daemon: poolConfigs[pName].shareProcessing.internal.daemon,
|
||||
address: poolConfigs[pName].address
|
||||
}
|
||||
}
|
||||
})();
|
||||
var daemon = new Stratum.daemon.interface([coinInfo.daemon]);
|
||||
daemon.cmd('dumpprivkey', [coinInfo.address], function(result){
|
||||
if (result[0].error){
|
||||
logger.error(logSystem, 'daemon', 'Could not dumpprivkey for ' + c + ' ' + JSON.stringify(result[0].error));
|
||||
cback();
|
||||
return;
|
||||
}
|
||||
|
||||
var vBytePub = util.getVersionByte(coinInfo.address)[0];
|
||||
var vBytePriv = util.getVersionByte(result[0].response)[0];
|
||||
|
||||
coinBytes[c] = vBytePub.toString() + ',' + vBytePriv.toString();
|
||||
coinsForRedis[c] = coinBytes[c];
|
||||
cback();
|
||||
});
|
||||
}, function(err){
|
||||
callback(null, client, coinBytes, coinsForRedis);
|
||||
});
|
||||
},
|
||||
function(client, coinBytes, coinsForRedis, callback){
|
||||
if (Object.keys(coinsForRedis).length > 0){
|
||||
client.hmset('coinVersionBytes', coinsForRedis, function(err){
|
||||
if (err)
|
||||
logger.error(logSystem, 'Init', 'Failed inserting coin byte version into redis ' + JSON.stringify(err));
|
||||
client.quit();
|
||||
});
|
||||
}
|
||||
else{
|
||||
client.quit();
|
||||
}
|
||||
callback(null, coinBytes);
|
||||
}
|
||||
], function(err, coinBytes){
|
||||
if (err){
|
||||
logger.error(logSystem, 'Init', err);
|
||||
return;
|
||||
}
|
||||
try{
|
||||
keyScriptTemplate = dot.template(fs.readFileSync('website/key.html', {encoding: 'utf8'}));
|
||||
keyScriptProcessed = keyScriptTemplate({coins: coinBytes});
|
||||
}
|
||||
catch(e){
|
||||
logger.error(logSystem, 'Init', 'Failed to read key.html file');
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
buildKeyScriptPage();
|
||||
|
||||
var getPage = function(pageId){
|
||||
if (pageId in pageProcessed){
|
||||
|
@ -147,6 +238,10 @@ module.exports = function(logger){
|
|||
next();
|
||||
});
|
||||
|
||||
app.get('/key.html', function(reg, res, next){
|
||||
res.end(keyScriptProcessed);
|
||||
});
|
||||
|
||||
app.get('/:page', route);
|
||||
app.get('/', route);
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,25 @@
|
|||
<style>
|
||||
#miningKeyPage{
|
||||
margin: 15px;
|
||||
}
|
||||
#keyFrame{
|
||||
padding: 0;
|
||||
border: 0;
|
||||
width: 100%;
|
||||
height: 750px;
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div id="miningKeyPage">
|
||||
|
||||
<p>
|
||||
This script run client-side (in your browser). For maximum security <a href="/key.html" download="key.html">download</a> the script and run it locally and
|
||||
offline in a modern web browser.
|
||||
</p>
|
||||
|
||||
<iframe id="keyFrame" src="/key.html">
|
||||
|
||||
</iframe>
|
||||
|
||||
</div>
|
Loading…
Reference in New Issue