From 67361fbfb578ca8603e603cf05cd85bec943aa52 Mon Sep 17 00:00:00 2001 From: Shawn <43627985+leshacat@users.noreply.github.com> Date: Tue, 30 Oct 2018 22:57:07 -0400 Subject: [PATCH] Update paymentProcessor.js Fix for issuehttps://github.com/foxer666/node-open-mining-portal/issues/145 You will need to test this, as your code is different from BootNOMP and I had to adjust the validation procedure. --- libs/paymentProcessor.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libs/paymentProcessor.js b/libs/paymentProcessor.js index 9e0fc8447..3c757951e 100644 --- a/libs/paymentProcessor.js +++ b/libs/paymentProcessor.js @@ -371,6 +371,31 @@ function SetupForPool(logger, poolOptions, setupFinished){ var addressAmounts = {}; var totalSent = 0; for (var w in workers) { + + // LeshaCat: If the address is not valid, skip calculation + // for all workers and callback() to resume + // https://github.com/foxer666/node-open-mining-portal/issues/145 + // *!*UNTESTED *!* due to different code base, this was modified (again) + var isValid = function() { + daemon.cmd('validateaddress', [address], function(results) { + if (result.error || !result.response){ + logger.error('Skipping validation, error with payment processing daemon ' + JSON.stringify(result.error)); + return true; + } + else if (!result.response.isvalid) { + logger.error('Address is not valid: ' + JSON.stringify(result.response)); + return false; + } + else{ + return false; + } + }, true); + } + if (!isValid) { + callback(null, workers, rounds); + return; + } + var worker = workers[w]; worker.balance = worker.balance || 0; worker.reward = worker.reward || 0; @@ -385,6 +410,7 @@ function SetupForPool(logger, poolOptions, setupFinished){ worker.balanceChange = Math.max(toSend - worker.balance, 0); worker.sent = 0; } + } if (Object.keys(addressAmounts).length === 0){