diff --git a/cronjobs/archive_cleanup.php b/cronjobs/archive_cleanup.php deleted file mode 100755 index 350d7c3d..00000000 --- a/cronjobs/archive_cleanup.php +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/php -purgeArchive(); -if ($affected_rows === false) { - $log->logError("Failed to delete archived shares, not critical but should be checked: " . $share->getCronError()); - $monitoring->endCronjob($cron_name, 'E0008', 0, false, false); -} else { - $log->logDebug("Deleted $affected_rows archived shares this run"); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/cronjobs/notification_cleanup.php b/cronjobs/notification_cleanup.php deleted file mode 100755 index 566b226f..00000000 --- a/cronjobs/notification_cleanup.php +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/php -cleanupNotifications($setting->getValue('notifications_cleanup_time', 7))) { - $notification->deleted == 0 ? $log->logDebug('Did not delete any old notifications') : $log->logInfo('Deleted ' . $notification->deleted . ' notifications'); -} else { - $log->logError('Failed to delete notifications: ' . $notification->getCronError()); - $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/cronjobs/payouts.php b/cronjobs/payouts.php index c96af16c..24b2629a 100755 --- a/cronjobs/payouts.php +++ b/cronjobs/payouts.php @@ -41,7 +41,7 @@ $sendmanyAvailable = ((strpos($bitcoin->help('sendmany'), 'unknown') === FALSE) if ($sendmanyAvailable) $log->logDebug(' sendmany available in coind help command'); -if (!$dWalletBalance = $bitcoin->getbalance()) +if (!$dWalletBalance = $bitcoin->getrealbalance()) $dWalletBalance = 0; // Fetch outstanding manual-payouts @@ -113,7 +113,7 @@ if ($setting->getValue('disable_manual_payouts') != 1 && $aManualPayouts) { } } -if (!$dWalletBalance = $bitcoin->getbalance()) +if (!$dWalletBalance = $bitcoin->getrealbalance()) $dWalletBalance = 0; // Fetch outstanding auto-payouts diff --git a/cronjobs/run-crons.sh b/cronjobs/run-crons.sh index 66c59c1f..d1cca24b 100755 --- a/cronjobs/run-crons.sh +++ b/cronjobs/run-crons.sh @@ -10,7 +10,7 @@ PHP_BIN=$( which php ) # List of cruns to execute -CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php token_cleanup.php archive_cleanup.php notification_cleanup.php" +CRONS="findblock.php proportional_payout.php pplns_payout.php pps_payout.php blockupdate.php payouts.php tickerupdate.php notifications.php statistics.php tables_cleanup.php" # Output additional runtime information VERBOSE="0" diff --git a/cronjobs/run-maintenance.sh b/cronjobs/run-maintenance.sh index 1161f4cd..54799323 100755 --- a/cronjobs/run-maintenance.sh +++ b/cronjobs/run-maintenance.sh @@ -10,7 +10,7 @@ PHP_BIN=$( which php ) # List of cruns to execute -CRONS="tickerupdate.php notifications.php token_cleanup.php archive_cleanup.php notification_cleanup.php" +CRONS="tickerupdate.php notifications.php tables_cleanup.php" # Output additional runtime information VERBOSE="0" diff --git a/cronjobs/tables_cleanup.php b/cronjobs/tables_cleanup.php new file mode 100755 index 00000000..04386133 --- /dev/null +++ b/cronjobs/tables_cleanup.php @@ -0,0 +1,79 @@ +#!/usr/bin/php +logInfo(sprintf($strLogMask, 'Process', 'Affected', 'Runtime', 'Status', 'Message')); + +// Cleanup old notifications +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = 0; +if ($notification->cleanupNotifications($setting->getValue('notifications_cleanup_time', 7))) { + $affected = $notification->deleted; + $affected == 0 ? $message = 'No notifications deleted' : $message = 'Deleted notifications older than ' . $setting->getValue('notifications_cleanup_time', 7) . ' days'; +} else { + $message = 'Failed to delete notifications: ' . $notification->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); +} +$log->logInfo(sprintf($strLogMask, 'cleanupNotifications', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + +// Cleanup old expired tokens +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = 0; +if ($oToken->cleanupTokens()) { + $affected = $oToken->deleted; + $affected == 0 ? $message = 'No tokens deleted' : $message = 'Deleted expired tokens'; +} else { + $message = 'Failed to delete notifications: ' . $oToken->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0074', 0, false, false); +} +$log->logInfo(sprintf($strLogMask, 'cleanupTokens', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + +// Clenaup shares archive +$start = microtime(true); +$status = 'OK'; +$message = ''; +$affected = $share->purgeArchive(); +if ($affected === false) { + $message = 'Failed to delete notifications: ' . $oToken->getCronError(); + $status = 'ERROR'; + $monitoring->endCronjob($cron_name, 'E0008', 0, false, false); +} else { + $affected == 0 ? $message = 'No shares deleted' : $message = 'Deleted old shares'; +} +$log->logInfo(sprintf($strLogMask, 'purgeArchive', $affected, number_format(microtime(true) - $start, 3), $status, $message)); + + +// Cron cleanup and monitoring +require_once('cron_end.inc.php'); +?> diff --git a/cronjobs/token_cleanup.php b/cronjobs/token_cleanup.php deleted file mode 100755 index dec00bd9..00000000 --- a/cronjobs/token_cleanup.php +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/php -cleanupTokens()) { - $oToken->deleted == 0 ? $log->logDebug('Did not find any expired tokens') : $log->logInfo('Deleted ' . $oToken->deleted . ' expired tokens'); -} else { - $log->logError('Failed to delete expired tokens: ' . $oToken->getCronError()); - // Treat as critical since tokens like password resets will never expire - $monitoring->endCronjob($cron_name, 'E0074', 1, true, true); -} - -// Cron cleanup and monitoring -require_once('cron_end.inc.php'); -?> diff --git a/public/include/classes/bitcoinwrapper.class.php b/public/include/classes/bitcoinwrapper.class.php index ebe1c470..f72f3933 100644 --- a/public/include/classes/bitcoinwrapper.class.php +++ b/public/include/classes/bitcoinwrapper.class.php @@ -31,17 +31,27 @@ class BitcoinWrapper extends BitcoinClient { if ($data = $this->memcache->get(__FUNCTION__)) return $data; return $this->memcache->setCache(__FUNCTION__, parent::getmininginfo(), 30); } - // Wrapper to check our wallet balance from the DEFAULT account only - public function getbalance() { - $this->oDebug->append("STA " . __METHOD__, 4); - $aAccounts = parent::listaccounts(); - return $aAccounts['']; - } public function getblockcount() { $this->oDebug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__)) return $data; return $this->memcache->setCache(__FUNCTION__, parent::getblockcount(), 30); } + // Wrapper method to get the real main account balance + public function getrealbalance() { + $this->oDebug->append("STA " . __METHOD__, 4); + $aAccounts = parent::listaccounts(); + $dBalance = parent::getbalance(); + // Account checks + if (count($aAccounts) == 1) { + // We only have a single account so getbalance will be fine + return $dBalance; + } else { + $dMainBalance = $aAccounts['']; + if ($dMainBalance < 0) return $dMainBalance; + $dUnconfirmed = $dMainBalance - abs($dBalance); + return $dMainBalance - abs($dUnconfirmed); + } + } public function getdifficulty() { $this->oDebug->append("STA " . __METHOD__, 4); if ($data = $this->memcache->get(__FUNCTION__)) return $data; diff --git a/public/include/config/monitor_crons.inc.php b/public/include/config/monitor_crons.inc.php index 5b69d6f1..98b8eb0f 100644 --- a/public/include/config/monitor_crons.inc.php +++ b/public/include/config/monitor_crons.inc.php @@ -2,7 +2,7 @@ // Small helper array that may be used on some page controllers to // fetch the crons we wish to monitor -$aMonitorCrons = array('statistics','payouts','token_cleanup','archive_cleanup','notification_cleanup','blockupdate','findblock','notifications','tickerupdate'); +$aMonitorCrons = array('statistics','payouts','tables_cleanup','blockupdate','findblock','notifications','tickerupdate'); switch ($config['payout_system']) { case 'pplns': diff --git a/public/include/pages/admin/wallet.inc.php b/public/include/pages/admin/wallet.inc.php index 909d05ef..2e150bc9 100644 --- a/public/include/pages/admin/wallet.inc.php +++ b/public/include/pages/admin/wallet.inc.php @@ -11,6 +11,16 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { $debug->append('No cached version available, fetching from backend', 3); if ($bitcoin->can_connect() === true){ $dBalance = $bitcoin->getbalance(); + + $dWalletAccounts = $bitcoin->listaccounts(); + $dAddressCount = count($dWalletAccounts); + + $dAccountAddresses = array(); + foreach($dWalletAccounts as $key => $value) + { + $dAccountAddresses[$key] = $bitcoin->getaddressesbyaccount($key); + } + $aGetInfo = $bitcoin->getinfo(); if (is_array($aGetInfo) && array_key_exists('newmint', $aGetInfo)) { $dNewmint = $aGetInfo['newmint']; @@ -37,6 +47,9 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) { if (! $dColdCoins = $setting->getValue('wallet_cold_coins')) $dColdCoins = 0; $smarty->assign("UNCONFIRMED", $dBlocksUnconfirmedBalance); $smarty->assign("BALANCE", $dBalance); + $smarty->assign("ADDRESSCOUNT", $dAddressCount); + $smarty->assign("ACCOUNTADDRESSES", $dAccountAddresses); + $smarty->assign("ACCOUNTS", $dWalletAccounts); $smarty->assign("COLDCOINS", $dColdCoins); $smarty->assign("LOCKED", $dLockedBalance); $smarty->assign("NEWMINT", $dNewmint); diff --git a/public/templates/mpos/admin/wallet/default.tpl b/public/templates/mpos/admin/wallet/default.tpl index d3485a60..37cf18d2 100644 --- a/public/templates/mpos/admin/wallet/default.tpl +++ b/public/templates/mpos/admin/wallet/default.tpl @@ -1,49 +1,95 @@ -
-

Balance Summary

- - - - - - - - - - - - - - - - - -{if $NEWMINT >= 0} - - - - +{if $ADDRESSCOUNT > 1} +
+

Wallet Information

{/if} -
Wallet Balance{$BALANCE|number_format:"8"}
Locked for users{$LOCKED|number_format:"8"}
Unconfirmed{$UNCONFIRMED|number_format:"8"}
Liquid Assets{($BALANCE - $LOCKED)|number_format:"8"}
PoS New Mint{$NEWMINT|number_format:"8"}
+
+

Balance Summary

+ + + + + + + + + + + + + + + + + +{if $NEWMINT >= 0} + + + + +{/if} +
Wallet Balance{$BALANCE|number_format:"8"}
Locked for users{$LOCKED|number_format:"8"}
Unconfirmed{$UNCONFIRMED|number_format:"8"}
Liquid Assets{($BALANCE - $LOCKED)|number_format:"8"}
PoS New Mint{$NEWMINT|number_format:"8"}
+
+ +
+

Wallet Status

+ + + + + + + + + + + + + + + + + +
VersionProtocol VersionWallet VersionConnectionsErrors
{$COININFO.version|default:""}{$COININFO.protocolversion|default:""}{$COININFO.walletversion|default:""}{$COININFO.connections|default:""}{$COININFO.errors|default:"OK"}
+
+{if $ADDRESSCOUNT > 1}
-
-

Wallet Information

- - - - - - - - - - - - - - - - - -
VersionProtocol VersionWallet VersionConnectionsErrors
{$COININFO.version|default:""}{$COININFO.protocolversion|default:""}{$COININFO.walletversion|default:""}{$COININFO.connections|default:""}{$COININFO.errors|default:"OK"}
+
+

Number of Accounts in Wallet: {$ADDRESSCOUNT|default:"0"}

+{foreach key=NAME item=VALUE from=$ACCOUNTS} +
+

Account: {$NAME|default:"Default"}

+
+

Balance Info

+ + + + + +
Balance{$VALUE|number_format:"8"}
+
+{foreach key=ACCOUNT item=ADDRESS from=$ACCOUNTADDRESSES} +{if $ACCOUNT == $NAME} +
+

Addresses assigned to Account {$ACCOUNT|default:"Default"}

+ + +{foreach from=$ACCOUNTADDRESSES[$ACCOUNT] key=ACCOUNT1 item=ADDRESS1} +{if $ADDRESS1@iteration is even by 1} + + +{else} + + +{/if} +{/foreach} + +
{$ADDRESS1}
{$ADDRESS1}
+
+{/if} +{/foreach} +
+{/foreach}
+{/if} +