php-mpos/public/include/pages/admin/wallet.inc.php
Sebastian Grewe 7e4c5dab4e Adding unconfirmed blocks to wallet
First attempt addressing #610, still missing a detection for the actual
confirmation limit required for each block in case one lowers it in the
config.
2013-08-19 09:31:53 +02:00

48 lines
1.5 KiB
PHP

<?php
// Make sure we are called from index.php
if (!defined('SECURITY')) die('Hacking attempt');
// Check user to ensure they are admin
if (!$user->isAuthenticated() || !$user->isAdmin($_SESSION['USERDATA']['id'])) {
header("HTTP/1.1 404 Page not found");
die("404 Page not found");
}
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->query('getbalance');
$dGetInfo = $bitcoin->query('getinfo');
if (is_array($dGetInfo) && array_key_exists('newmint', $dGetInfo)) {
$dNewmint = $dGetInfo['newmint'];
} else {
$dNewmint = -1;
}
} else {
$dBalance = 0;
$dNewmint = -1;
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to wallet RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg');
}
// Fetch unconfirmed amount from blocks table
$aBlocksUnconfirmed = $block->getAllUnconfirmed();
$dBlocksUnconfirmedBalance = 0;
if (!empty($aBlocksUnconfirmed))
foreach ($aBlocksUnconfirmed as $aData) $dBlocksUnconfirmedBalance += $aData['amount'];
// Fetch locked balance from transactions
$dLockedBalance = $transaction->getLockedBalance();
} else {
$debug->append('Using cached page', 3);
}
$smarty->assign("UNCONFIRMED", $dBlocksUnconfirmedBalance);
$smarty->assign("BALANCE", $dBalance);
$smarty->assign("LOCKED", $dLockedBalance);
$smarty->assign("NEWMINT", $dNewmint);
// Tempalte specifics
$smarty->assign("CONTENT", "default.tpl");
?>