Payment processing seems to be working. Does not withdrawal profit yet though

This commit is contained in:
Matt 2014-03-20 17:05:13 -06:00
parent eba32adde9
commit 74e4827057
1 changed files with 30 additions and 4 deletions

View File

@ -89,7 +89,7 @@ function SetupForPool(logger, poolOptions){
redisClient.smembers(coin + '_blocksPending', function(error, results){
if (error){
logger.error('redis', 'Could get blocks from redis ' + JSON.stringify(error));
paymentLogger.error('redis', 'Could get blocks from redis ' + JSON.stringify(error));
callback('done - redis error for getting blocks');
return;
}
@ -356,7 +356,7 @@ function SetupForPool(logger, poolOptions){
console.log(JSON.stringify(workerPayments, null, 4));
console.log(JSON.stringify(sendManyCmd, null, 4));
return; //not yet...
//return callback('not yet...');
daemon.cmd('sendmany', sendManyCmd, function(results){
if (results[0].error){
callback('done - error with sendmany ' + JSON.stringify(results[0].error));
@ -376,15 +376,41 @@ function SetupForPool(logger, poolOptions){
}
], function(error, result){
if (error)
logger.debug(error)
paymentLogger.debug('system', error)
else{
logger.debug(result);
paymentLogger.debug('system', result);
withdrawalProfit();
}
});
};
var withdrawalProfit = function(){
try{
daemon.cmd('getbalance', [], function(results){
var totalBalance = results[0].response;
var withdrawalAmount = totalBalance - processingConfig.minimumReserve;
var leftOverBalance = totalBalance - withdrawalAmount;
if (leftOverBalance < processingConfig.minimumReserve || withdrawalAmount < processingConfig.feeWithdrawalThreshold){
paymentLogger.debug('system', 'Not enough profit to withdrawal yet');
}
else{
//Need to figure out how much of the balance is profit... ???
paymentLogger.debug('system', 'Can send profit');
}
});
}
catch(e){
throw e;
}
};
setInterval(processPayments, processingConfig.paymentInterval * 1000);
setTimeout(processPayments, 100);