Added reward address account detection in payment processing so addresses not under the default account of "" (empty string) will work.
This commit is contained in:
parent
a279fb486f
commit
432af28a78
@ -109,6 +109,7 @@ If your pool uses NOMP let us know and we will list your website here.
|
|||||||
* http://hashfaster.com
|
* http://hashfaster.com
|
||||||
* http://miningpoolhub.com
|
* http://miningpoolhub.com
|
||||||
* http://teamdoge.com
|
* http://teamdoge.com
|
||||||
|
* http://miningwith.us
|
||||||
* http://kryptochaos.com
|
* http://kryptochaos.com
|
||||||
* http://pool.uberpools.org
|
* http://pool.uberpools.org
|
||||||
|
|
||||||
|
|||||||
@ -216,6 +216,8 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
return ['gettransaction', [r.txHash]];
|
return ['gettransaction', [r.txHash]];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
batchRPCcommand.push(['getaccount', [poolOptions.address]]);
|
||||||
|
|
||||||
daemon.batchCmd(batchRPCcommand, function(error, txDetails){
|
daemon.batchCmd(batchRPCcommand, function(error, txDetails){
|
||||||
|
|
||||||
if (error || !txDetails){
|
if (error || !txDetails){
|
||||||
@ -224,7 +226,15 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var addressAccount;
|
||||||
|
|
||||||
txDetails.forEach(function(tx, i){
|
txDetails.forEach(function(tx, i){
|
||||||
|
|
||||||
|
if (i === txDetails.length - 1){
|
||||||
|
addressAccount = tx.result;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var round = rounds[i];
|
var round = rounds[i];
|
||||||
|
|
||||||
if (tx.error && tx.error.code === -5 || round.blockHash !== tx.result.blockhash){
|
if (tx.error && tx.error.code === -5 || round.blockHash !== tx.result.blockhash){
|
||||||
@ -273,7 +283,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
rpc.gettransaction.amount tells us how much we get in whole coin units. Therefore,
|
rpc.gettransaction.amount tells us how much we get in whole coin units. Therefore,
|
||||||
we simply divide the two to get the magnitude. I don't know math, there is probably
|
we simply divide the two to get the magnitude. I don't know math, there is probably
|
||||||
a better term than 'magnitude'. Sue me or do a pull request to fix it. */
|
a better term than 'magnitude'. Sue me or do a pull request to fix it. */
|
||||||
var roundMagnitude = r.reward / r.amount;
|
var roundMagnitude = Math.round(r.reward / r.amount);
|
||||||
|
|
||||||
if (!magnitude) {
|
if (!magnitude) {
|
||||||
magnitude = roundMagnitude;
|
magnitude = roundMagnitude;
|
||||||
@ -303,7 +313,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
callback('Check finished - no confirmed or orphaned blocks found');
|
callback('Check finished - no confirmed or orphaned blocks found');
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
callback(null, rounds, magnitude);
|
callback(null, rounds, magnitude, addressAccount);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -311,7 +321,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
|
|
||||||
/* Does a batch redis call to get shares contributed to each round. Then calculates the reward
|
/* Does a batch redis call to get shares contributed to each round. Then calculates the reward
|
||||||
amount owned to each miner for each round. */
|
amount owned to each miner for each round. */
|
||||||
function(rounds, magnitude, callback){
|
function(rounds, magnitude, addressAccount, callback){
|
||||||
|
|
||||||
|
|
||||||
var shareLookups = rounds.map(function(r){
|
var shareLookups = rounds.map(function(r){
|
||||||
@ -370,13 +380,13 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
callback(null, rounds, magnitude, workerRewards, orphanMergeCommands);
|
callback(null, rounds, magnitude, workerRewards, orphanMergeCommands, addressAccount);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
/* Does a batch call to redis to get worker existing balances from coin_balances*/
|
/* Does a batch call to redis to get worker existing balances from coin_balances*/
|
||||||
function(rounds, magnitude, workerRewards, orphanMergeCommands, callback){
|
function(rounds, magnitude, workerRewards, orphanMergeCommands, addressAccount, callback){
|
||||||
|
|
||||||
var workers = Object.keys(workerRewards);
|
var workers = Object.keys(workerRewards);
|
||||||
|
|
||||||
@ -394,7 +404,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
callback(null, rounds, magnitude, workerRewards, orphanMergeCommands, workerBalances);
|
callback(null, rounds, magnitude, workerRewards, orphanMergeCommands, workerBalances, addressAccount);
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -406,12 +416,11 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
when deciding the sent balance, it the difference should be -1*amount they had in db,
|
when deciding the sent balance, it the difference should be -1*amount they had in db,
|
||||||
if not sending the balance, the differnce should be +(the amount they earned this round)
|
if not sending the balance, the differnce should be +(the amount they earned this round)
|
||||||
*/
|
*/
|
||||||
function(rounds, magnitude, workerRewards, orphanMergeCommands, workerBalances, callback){
|
function(rounds, magnitude, workerRewards, orphanMergeCommands, workerBalances, addressAccount, callback){
|
||||||
|
|
||||||
//number of satoshis in a single coin unit - this can be different for coins so we calculate it :)
|
//number of satoshis in a single coin unit - this can be different for coins so we calculate it :)
|
||||||
|
|
||||||
|
daemon.cmd('getbalance', [addressAccount || ''], function(results){
|
||||||
daemon.cmd('getbalance', [''], function(results){
|
|
||||||
|
|
||||||
var totalBalance = results[0].response * magnitude;
|
var totalBalance = results[0].response * magnitude;
|
||||||
var toBePaid = 0;
|
var toBePaid = 0;
|
||||||
@ -474,9 +483,9 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
/* TODO: Need to convert all these variables into whole coin units before displaying because
|
/* TODO: Need to convert all these variables into whole coin units before displaying because
|
||||||
humans aren't good at reading satoshi units. */
|
humans aren't good at reading satoshi units. */
|
||||||
callback('Check finished - payments would wipe out minimum reserve, tried to pay out ' +
|
callback('Check finished - payments would wipe out minimum reserve, tried to pay out ' +
|
||||||
toBePaid + ' and collect ' + feeAmountToBeCollected + ' as fees' +
|
(toBePaid/magnitude) + ' and collect ' + (feeAmountToBeCollected/magnitude) + ' as fees' +
|
||||||
' but only have ' + totalBalance + '. Left over balance would be ' + balanceLeftOver +
|
' but only have ' + (totalBalance/magnitude) + '. Left over balance would be ' + (balanceLeftOver/magnitude) +
|
||||||
', needs to be at least ' + minReserveSatoshis);
|
', needs to be at least ' + (minReserveSatoshis/magnitude));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -522,23 +531,23 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
|
|
||||||
finalRedisCommands.push(['bgsave']);
|
finalRedisCommands.push(['bgsave']);
|
||||||
|
|
||||||
callback(null, magnitude, workerPayments, finalRedisCommands);
|
callback(null, magnitude, workerPayments, finalRedisCommands, addressAccount);
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
function(magnitude, workerPayments, finalRedisCommands, callback) {
|
function(magnitude, workerPayments, finalRedisCommands, addressAccount, callback) {
|
||||||
/* Save final redis cleanout commands in case something goes wrong during payments */
|
/* Save final redis cleanout commands in case something goes wrong during payments */
|
||||||
redisClient.set(coin + '_finalRedisCommands', JSON.stringify(finalRedisCommands), function(error, reply) {
|
redisClient.set(coin + '_finalRedisCommands', JSON.stringify(finalRedisCommands), function(error, reply) {
|
||||||
if (error){
|
if (error){
|
||||||
callback('Check finished - error with saving finalRedisCommands' + JSON.stringify(error));
|
callback('Check finished - error with saving finalRedisCommands' + JSON.stringify(error));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callback(null, magnitude, workerPayments, finalRedisCommands);
|
callback(null, magnitude, workerPayments, finalRedisCommands, addressAccount);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
function(magnitude, workerPayments, finalRedisCommands, callback){
|
function(magnitude, workerPayments, finalRedisCommands, addressAccount, callback){
|
||||||
|
|
||||||
//This does the final all-or-nothing atom transaction if block deamon sent payments
|
//This does the final all-or-nothing atom transaction if block deamon sent payments
|
||||||
var finalizeRedisTx = function(){
|
var finalizeRedisTx = function(){
|
||||||
@ -570,7 +579,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
logger.debug(logSystem, logComponent, 'Payments to be sent to: ' + JSON.stringify(addressAmounts));
|
logger.debug(logSystem, logComponent, 'Payments to be sent to: ' + JSON.stringify(addressAmounts));
|
||||||
|
|
||||||
processingPayments = true;
|
processingPayments = true;
|
||||||
daemon.cmd('sendmany', ['', addressAmounts], function(results){
|
daemon.cmd('sendmany', [addressAccount || '', addressAmounts], function(results){
|
||||||
|
|
||||||
if (results[0].error){
|
if (results[0].error){
|
||||||
callback('Check finished - error with sendmany ' + JSON.stringify(results[0].error));
|
callback('Check finished - error with sendmany ' + JSON.stringify(results[0].error));
|
||||||
@ -591,7 +600,7 @@ function SetupForPool(logger, poolOptions, setupFinished){
|
|||||||
}
|
}
|
||||||
var feeAmountUnits = parseFloat((totalAmountUnits / (1 - processingConfig.feePercent) * processingConfig.feePercent).toFixed(coinPrecision));
|
var feeAmountUnits = parseFloat((totalAmountUnits / (1 - processingConfig.feePercent) * processingConfig.feePercent).toFixed(coinPrecision));
|
||||||
var poolFees = feeAmountUnits - results[0].response.fee;
|
var poolFees = feeAmountUnits - results[0].response.fee;
|
||||||
daemon.cmd('move', ['', processingConfig.feeCollectAccount, poolFees], function(results){
|
daemon.cmd('move', [addressAccount || '', processingConfig.feeCollectAccount, poolFees], function(results){
|
||||||
if (results[0].error){
|
if (results[0].error){
|
||||||
callback('Check finished - error with move ' + JSON.stringify(results[0].error));
|
callback('Check finished - error with move ' + JSON.stringify(results[0].error));
|
||||||
return;
|
return;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user