diff --git a/cronjobs/findblock.php b/cronjobs/findblock.php index 4ee9f644..42e347a0 100755 --- a/cronjobs/findblock.php +++ b/cronjobs/findblock.php @@ -26,7 +26,7 @@ chdir(dirname(__FILE__)); require_once('shared.inc.php'); // Fetch our last block found from the DB as a starting point -$aLastBlock = @$block->getLast(); +$aLastBlock = @$block->getLastValid(); $strLastBlockHash = $aLastBlock['blockhash']; if (!$strLastBlockHash) $strLastBlockHash = ''; @@ -58,6 +58,15 @@ if (empty($aTransactions['transactions'])) { $aBlockRPCInfo = $bitcoin->getblock($aData['blockhash']); $config['reward_type'] == 'block' ? $aData['amount'] = $aData['amount'] : $aData['amount'] = $config['reward']; $aData['height'] = $aBlockRPCInfo['height']; + $aTxDetails = $bitcoin->gettransaction($aBlockRPCInfo['tx'][0]); + if (!isset($aBlockRPCInfo['confirmations'])) { + $aData['confirmations'] = $aBlockRPCInfo['confirmations']; + } else if (isset($aTxDetails['confirmations'])) { + $aData['confirmations'] = $aTxDetails['confirmations']; + } else { + $log->logFatal(' RPC does not return any usable block confirmation information'); + $monitoring->endCronjob($cron_name, 'E0082', 1, true); + } $aData['difficulty'] = $aBlockRPCInfo['difficulty']; $log->logInfo(sprintf($strLogMask, substr($aData['blockhash'], 0, 17)."...", $aData['height'], $aData['amount'], $aData['confirmations'], $aData['difficulty'], strftime("%Y-%m-%d %H:%M:%S", $aData['time']))); if ( ! empty($aBlockRPCInfo['flags']) && preg_match('/proof-of-stake/', $aBlockRPCInfo['flags']) ) { diff --git a/public/include/classes/block.class.php b/public/include/classes/block.class.php index 76ccf43d..cf0ea7ee 100644 --- a/public/include/classes/block.class.php +++ b/public/include/classes/block.class.php @@ -15,6 +15,18 @@ class Block extends Base { return $result->fetch_assoc(); return $this->sqlError(); } + + /** + * Specific method to fetch the latest block found that is VALID + * @param none + * @return data array Array with database fields as keys + **/ + public function getLastValid() { + $stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE confirmations > -1 ORDER BY height DESC LIMIT 1"); + if ($this->checkStmt($stmt) && $stmt->execute() && $result = $stmt->get_result()) + return $result->fetch_assoc(); + return $this->sqlError(); + } /** * Get a specific block, by block height diff --git a/public/include/config/global.inc.dist.php b/public/include/config/global.inc.dist.php index aeca9b89..a73e294b 100644 --- a/public/include/config/global.inc.dist.php +++ b/public/include/config/global.inc.dist.php @@ -84,6 +84,13 @@ $config['ap_threshold']['max'] = 250; **/ $config['mp_threshold'] = 1; +/** + * Minimum manual Payout Threshold + * Minimum manual payout amount + * https://github.com/MPOS/php-mpos/wiki/Config-Setup#wiki-manual-payout-threshold + **/ +$config['mp_threshold'] = 1; + /** * Donation thresholds * Minimum donation amount in percent diff --git a/public/include/pages/account/edit.inc.php b/public/include/pages/account/edit.inc.php index 25ea149a..0c50dafd 100644 --- a/public/include/pages/account/edit.inc.php +++ b/public/include/pages/account/edit.inc.php @@ -94,6 +94,8 @@ if ($user->isAuthenticated()) { } else { switch (@$_POST['do']) { case 'cashOut': + $aBalance = $transaction->getBalance($_SESSION['USERDATA']['id']); + $dBalance = $aBalance['confirmed']; if ($setting->getValue('disable_payouts') == 1 || $setting->getValue('disable_manual_payouts') == 1) { $_SESSION['POPUP'][] = array('CONTENT' => 'Manual payouts are disabled.', 'TYPE' => 'alert alert-warning'); } else if ($aBalance['confirmed'] < $config['mp_threshold']) { @@ -101,8 +103,6 @@ if ($user->isAuthenticated()) { } else if (!$user->getCoinAddress($_SESSION['USERDATA']['id'])) { $_SESSION['POPUP'][] = array('CONTENT' => 'You have no payout address set.', 'TYPE' => 'alert alert-danger'); } else { - $aBalance = $transaction->getBalance($_SESSION['USERDATA']['id']); - $dBalance = $aBalance['confirmed']; $user->log->log("info", $_SESSION['USERDATA']['username']." requesting manual payout"); if ($dBalance > $config['txfee_manual']) { if (!$oPayout->isPayoutActive($_SESSION['USERDATA']['id'])) { diff --git a/public/templates/mpos/account/edit/default.tpl b/public/templates/mpos/account/edit/default.tpl index 4b7053f5..0f6e48b4 100644 --- a/public/templates/mpos/account/edit/default.tpl +++ b/public/templates/mpos/account/edit/default.tpl @@ -89,6 +89,9 @@
Please note: a {if $GLOBAL.config.txfee_manual > 0.00001}{$GLOBAL.config.txfee_manual}{else}{$GLOBAL.config.txfee_manual|number_format:"8"}{/if} {$GLOBAL.config.currency} transaction will apply when processing "On-Demand" manual payments
+ Minimum Cashout: {$GLOBAL.config.mp_threshold} {$GLOBAL.config.currency} +