From 91d225e340d4215fe9aca4c5e3809fb3e3e6e2a1 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 4 Jun 2013 14:03:46 +0200 Subject: [PATCH 1/2] Adding wallet information in Admin panel Fixes #63 and adds proper wallet information: * Wallet balance * Locked balance for users * Liquid assets available to pool owner --- public/include/pages/admin/wallet.inc.php | 25 +++++++++++++++++++ .../templates/mmcFE/admin/wallet/default.tpl | 16 ++++++++++++ public/templates/mmcFE/global/navigation.tpl | 1 + 3 files changed, 42 insertions(+) create mode 100644 public/include/pages/admin/wallet.inc.php create mode 100644 public/templates/mmcFE/admin/wallet/default.tpl diff --git a/public/include/pages/admin/wallet.inc.php b/public/include/pages/admin/wallet.inc.php new file mode 100644 index 00000000..cb094fe9 --- /dev/null +++ b/public/include/pages/admin/wallet.inc.php @@ -0,0 +1,25 @@ +isAdmin($_SESSION['USERDATA']['id'])) { + header("HTTP/1.1 404 Page not found"); + die(); +} + +if ($bitcoin->can_connect() === true){ + $dBalance = $bitcoin->query('getbalance'); +} else { + $dBalance = 0; + $_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to litecoind RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg'); +} + +$smarty->assign("BALANCE", $dBalance); +$smarty->assign("LOCKED", $transaction->getLockedBalance()); + +// Tempalte specifics +$smarty->assign("CONTENT", "default.tpl"); +?> diff --git a/public/templates/mmcFE/admin/wallet/default.tpl b/public/templates/mmcFE/admin/wallet/default.tpl new file mode 100644 index 00000000..42b8c8b3 --- /dev/null +++ b/public/templates/mmcFE/admin/wallet/default.tpl @@ -0,0 +1,16 @@ +{include file="global/block_header.tpl" BLOCK_HEADER="Wallet Information"} + + + + + + + + + + + + + +
Wallet Balance{$BALANCE|number_format:"8"}
Locked for users{$LOCKED|number_format:"8"}
Liquid Assets{($BALANCE - $LOCKED)|number_format:"8"}
+{include file="global/block_footer.tpl"} diff --git a/public/templates/mmcFE/global/navigation.tpl b/public/templates/mmcFE/global/navigation.tpl index 13172478..6a0cdb37 100644 --- a/public/templates/mmcFE/global/navigation.tpl +++ b/public/templates/mmcFE/global/navigation.tpl @@ -14,6 +14,7 @@
  • Admin Panel
  • {/if} From af3252abb20aa7ec4cfacb03ff046e770fb25886 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Tue, 4 Jun 2013 14:28:34 +0200 Subject: [PATCH 2/2] Find ALL transactions, even unconfirmed * This ensures that credits are not unlocked and available to the pool --- public/include/classes/transaction.class.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/public/include/classes/transaction.class.php b/public/include/classes/transaction.class.php index 15f29c77..020140d3 100644 --- a/public/include/classes/transaction.class.php +++ b/public/include/classes/transaction.class.php @@ -130,6 +130,7 @@ class Transaction { /** * Get total balance for all users locked in wallet + * This includes any outstanding unconfirmed transactions! * @param none * @return data double Amount locked for users **/ @@ -141,9 +142,7 @@ class Transaction { ( SELECT sum(t.amount) AS credit FROM $this->table AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id WHERE t.type = 'Credit' - AND b.confirmations >= ? ) AS t1, ( SELECT sum(t.amount) AS debit @@ -152,12 +151,10 @@ class Transaction { ) AS t2, ( SELECT sum(t.amount) AS other - FROM transactions AS t - LEFT JOIN " . $this->block->getTableName() . " AS b ON t.block_id = b.id + FROM " . $this->table . " AS t WHERE t.type IN ('Donation','Fee') - AND b.confirmations >= ? ) AS t3"); - if ($this->checkStmt($stmt) && $stmt->bind_param('ii', $this->config['confirmations'], $this->config['confirmations']) && $stmt->execute() && $stmt->bind_result($dBalance) && $stmt->fetch()) + if ($this->checkStmt($stmt) && $stmt->execute() && $stmt->bind_result($dBalance) && $stmt->fetch()) return $dBalance; // Catchall $this->setErrorMessage('Unable to find locked credits for all users');