diff --git a/README.md b/README.md index 0238b3ff..4fdbff00 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ These people have supported this project with a donation: * [PCFiL](https://github.com/PCFiL) * [rog1121](https://github.com/rog1121)(https://rapidhash.net) * [Wow, Much Pool](http://www.wowmuchpool.com/) +* webxassDE (https://www.suchcoins.com/) Pools running MPOS ================== diff --git a/cronjobs/blockupdate.php b/cronjobs/blockupdate.php index f7938dee..c1ef23b5 100755 --- a/cronjobs/blockupdate.php +++ b/cronjobs/blockupdate.php @@ -54,10 +54,18 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $aBlockInfo['confirmations'], $status)); continue; } - if ($aBlock['confirmations'] == $aBlockInfo['confirmations']) { + if (isset($aBlockInfo['confirmations'])) { + $iRPCConfirmations = $aBlockInfo['confirmations']; + } else if (isset($aTxDetails['confirmations'])) { + $iRPCConfirmations = $aTxDetails['confirmations']; + } else { + $log->logFatal(' RPC does not return any usable block confirmation information'); + $monitoring->endCronjob($cron_name, 'E0082', 1, true); + } + if ($iRPCConfirmations == $aBlock['confirmations']) { continue; } else { - if (!$block->setConfirmations($aBlock['id'], $aBlockInfo['confirmations'])) { + if (!$block->setConfirmations($aBlock['id'], $iRPCConfirmations)) { $log->logError(' Failed to update block confirmations: ' . $block->getCronMessage()); $status = 'ERROR'; } else { @@ -67,7 +75,7 @@ foreach ($aAllBlocks as $iIndex => $aBlock) { $log->logInfo(sprintf($strLogMask, 'ID', 'Height', 'Blockhash', 'Old', 'New', 'Status')); $header = true; } - $log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $aBlockInfo['confirmations'], $status)); + $log->logInfo(sprintf($strLogMask, $aBlock['id'], $aBlock['height'], $aBlock['blockhash'], $aBlock['confirmations'], $iRPCConfirmations, $status)); } } diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index 91af6ad2..4777a87c 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -74,6 +74,10 @@ class BitcoinWrapper extends BitcoinClient { if (is_array($dNetworkHashrate)) { if (array_key_exists('networkhashps', $dNetworkHashrate)) { $dNetworkHashrate = $dNetworkHashrate['networkhashps']; + } else if (array_key_exists('networkmhps', $dNetworkHashrate)) { + $dNetworkHashrate = $dNetworkHashrate['networkmhps'] * 1000; + } else if (array_key_exists('networkghps', $dNetworkHashrate)) { + $dNetworkHashrate = $dNetworkHashrate['networkghps'] * 1000 * 1000; } else if (array_key_exists('hashespersec', $dNetworkHashrate)) { $dNetworkHashrate = $dNetworkHashrate['hashespersec']; } else if (array_key_exists('netmhashps', $dNetworkHashrate)) { diff --git a/public/include/classes/notification.class.php b/public/include/classes/notification.class.php old mode 100644 new mode 100755 diff --git a/public/include/config/admin_settings.inc.php b/public/include/config/admin_settings.inc.php index 0411cf45..55b9583c 100644 --- a/public/include/config/admin_settings.inc.php +++ b/public/include/config/admin_settings.inc.php @@ -413,6 +413,7 @@ $aSettings['monitoring'][] = array( ); $aSettings['notifications'][] = array( 'display' => 'Notification Cleanup Time', 'type' => 'text', + 'size' => 10, 'default' => 7, 'name' => 'notifications_cleanup_time', 'value' => $setting->getValue('notifications_cleanup_time'), 'tooltip' => 'Maximum age in days of notifications before cleaned from database.' diff --git a/public/include/config/error_codes.inc.php b/public/include/config/error_codes.inc.php index b6e720ee..7d24bdae 100644 --- a/public/include/config/error_codes.inc.php +++ b/public/include/config/error_codes.inc.php @@ -77,4 +77,5 @@ $aErrorCodes['E0078'] = 'RPC method did not return 200 OK'; $aErrorCodes['E0079'] = 'Wallet does not cover payouts total amount'; $aErrorCodes['E0080'] = 'No new unaccounted shares since last run'; $aErrorCodes['E0081'] = 'Failed to insert new block into database'; +$aErrorCodes['E0082'] = 'Block does not supply any usable confirmation information'; ?> diff --git a/public/include/pages/account/notifications.inc.php b/public/include/pages/account/notifications.inc.php old mode 100644 new mode 100755 index 03621a0a..9768abd2 --- a/public/include/pages/account/notifications.inc.php +++ b/public/include/pages/account/notifications.inc.php @@ -19,7 +19,7 @@ if ($user->isAuthenticated()) { } // Fetch notifications - $aNotifications = $notification->getNofifications($_SESSION['USERDATA']['id']); + $aNotifications = $notification->getNotifications($_SESSION['USERDATA']['id']); if (!$aNotifications) $_SESSION['POPUP'][] = array('CONTENT' => 'Could not find any notifications', 'TYPE' => 'alert alert-danger'); // Fetch global settings diff --git a/public/include/pages/api/getusertransactions.inc.php b/public/include/pages/api/getusertransactions.inc.php index 403ff929..3903deba 100644 --- a/public/include/pages/api/getusertransactions.inc.php +++ b/public/include/pages/api/getusertransactions.inc.php @@ -8,13 +8,13 @@ $api->isActive(); $user_id = $api->checkAccess($user->checkApiKey($_REQUEST['api_key']), @$_REQUEST['id']); // Fetch transactions -if (isset($_REQUEST['limit']) && $_REQUEST['limit'] < 30) { +if (isset($_REQUEST['limit']) && $_REQUEST['limit'] <= 100) { $limit = $_REQUEST['limit']; } else { // Force limit - $limit = 5; + $limit = 100; } -$data['transactions'] = $transaction->getTransactions(0, NULL, 30, $user_id); +$data['transactions'] = $transaction->getTransactions(0, NULL, $limit, $user_id); // Fetch summary if enabled if (!$setting->getValue('disable_transactionsummary')) { diff --git a/public/include/smarty_globals.inc.php b/public/include/smarty_globals.inc.php index 9ad35c01..ec85083d 100644 --- a/public/include/smarty_globals.inc.php +++ b/public/include/smarty_globals.inc.php @@ -142,6 +142,7 @@ if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata']['rawhashrate'] = $aUserMiningStats['hashrate']; $aGlobal['userdata']['hashrate'] = $aGlobal['userdata']['rawhashrate'] * $dPersonalHashrateModifier; $aGlobal['userdata']['sharerate'] = $aUserMiningStats['sharerate']; + $aGlobal['userdata']['sharedifficulty'] = $aUserMiningStats['avgsharediff']; switch ($config['payout_system']) { case 'prop': @@ -163,7 +164,6 @@ if (@$_SESSION['USERDATA']['id']) { $aGlobal['userdata']['pps']['unpaidshares'] = $statistics->getUserUnpaidPPSShares($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id'], $setting->getValue('pps_last_share_id')); $aGlobal['ppsvalue'] = number_format($statistics->getPPSValue(), 12); $aGlobal['poolppsvalue'] = $aGlobal['ppsvalue'] * pow(2, $config['difficulty'] - 16); - $aGlobal['userdata']['sharedifficulty'] = $statistics->getUserShareDifficulty($_SESSION['USERDATA']['username'], $_SESSION['USERDATA']['id']); $aGlobal['userdata']['estimates'] = $statistics->getUserEstimates($aGlobal['userdata']['sharerate'], $aGlobal['userdata']['sharedifficulty'], $aGlobal['userdata']['donate_percent'], $aGlobal['userdata']['no_fees'], $aGlobal['ppsvalue']); break; } diff --git a/scripts/validate_blocks.php b/scripts/validate_blocks.php new file mode 100755 index 00000000..eed93e43 --- /dev/null +++ b/scripts/validate_blocks.php @@ -0,0 +1,48 @@ +#!/usr/bin/php +can_connect() !== true ) + die("Failed to connect to RPC server". PHP_EOL); + + echo "Validating blocks in database against coind..". PHP_EOL; + + $mask = "| %6s | %8s | %13s | %20s | %10s |". PHP_EOL;; + printf($mask, 'DB-ID', 'Height', 'Confirmations', 'Time', 'Status'); + + // fetch all blocks + $allBlocks = $block->getAll(); + foreach ($allBlocks as $block) + { + try { + if($block['confirmations']== -1) // mark orphan blocks. + $status = 'ORPHAN'; + else + { + $blockInfo = $bitcoin->getblock($block['blockhash']); + $status = 'VALID'; // if the getblock() call didn't throw an exception, it's a valid block then. + } + } + catch(Exception $e) + { + if($e->getMessage() == 'RPC call did not return 200: HTTP error: 500 - JSON Response: [-5] Block not found') + { + $status = 'INVALID'; + } + else + { + $status = 'UNKNOWN'; + } + } + + printf($mask, $block['id'], $block['height'], $block['confirmations'], strftime("%Y-%m-%d %H:%M:%S", $block['time']), $status); + } + + echo "Done..". PHP_EOL; +?> \ No newline at end of file diff --git a/scripts/validate_users.php b/scripts/validate_users.php new file mode 100755 index 00000000..bc44971c --- /dev/null +++ b/scripts/validate_users.php @@ -0,0 +1,56 @@ +#!/usr/bin/php +getAllAssoc(); + + $mask = "| %6s | %20s | %16s | %20s | %12.12s | %5s | %5s | %12s | %5s | \n"; + printf($mask, 'ID', 'Username', 'LoggedIP', 'Last Login','Days Since', 'Ever', 'Trans', 'Balance','Stale'); + + $currentTime = time(); + $totalSavings = 0; + + foreach ($users as $user) + { + $id = $user['id']; + $isAdmin = $user['is_admin']; + $username = $user['username']; + $loggedIp = $user['loggedIp']; + $lastLogin = $user['last_login']; + $coinAddress = $user['coin_address']; + + $everLoggedIn = !empty($lastLogin); + $timeDelta = $currentTime - $lastLogin; + $lastLoginInDays = round(abs($timeDelta)/60/60/24, 0); + + if($lastLoginInDays < $timeLimitInDays) + continue; + + // get transactions summary for the user + $summary = $transaction->getTransactionSummary($id); + $transactions_exists = !empty($summary); + + // get balances + $balances = $transaction->getBalance($id); + $confirmedBalance = $balances['confirmed']; + $totalSavings += $confirmedBalance; + + $staleAccount = $everLoggedIn == false && $transactions_exists == false; + + printf($mask, $id, $username, + $loggedIp, strftime("%Y-%m-%d %H:%M:%S", $lastLogin), $lastLoginInDays, $everLoggedIn ? 'yes' : 'no', + $transactions_exists ? 'yes' : 'no', round($confirmedBalance,8), + $staleAccount ? 'yes' : 'no' ); + } + + echo "Total balance of stale accounts: $totalSavings" . PHP_EOL; +?> \ No newline at end of file