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.
This commit is contained in:
parent
b5b40620f0
commit
7e4c5dab4e
@ -10,9 +10,10 @@ class Block {
|
|||||||
// This defines each block
|
// This defines each block
|
||||||
public $height, $blockhash, $confirmations, $time, $accounted;
|
public $height, $blockhash, $confirmations, $time, $accounted;
|
||||||
|
|
||||||
public function __construct($debug, $mysqli, $salt) {
|
public function __construct($debug, $mysqli, $config) {
|
||||||
$this->debug = $debug;
|
$this->debug = $debug;
|
||||||
$this->mysqli = $mysqli;
|
$this->mysqli = $mysqli;
|
||||||
|
$this->config = $config;
|
||||||
$this->debug->append("Instantiated Block class", 2);
|
$this->debug->append("Instantiated Block class", 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,9 +121,9 @@ class Block {
|
|||||||
* @param confirmations int Required confirmations to consider block confirmed
|
* @param confirmations int Required confirmations to consider block confirmed
|
||||||
* @return data array Array with database fields as keys
|
* @return data array Array with database fields as keys
|
||||||
**/
|
**/
|
||||||
public function getAllUnconfirmed($confirmations='120') {
|
public function getAllUnconfirmed() {
|
||||||
$stmt = $this->mysqli->prepare("SELECT id, height, blockhash, confirmations FROM $this->table WHERE confirmations < ? AND confirmations > -1");
|
$stmt = $this->mysqli->prepare("SELECT * FROM $this->table WHERE confirmations < ? AND confirmations > -1");
|
||||||
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $confirmations) && $stmt->execute() && $result = $stmt->get_result())
|
if ($this->checkStmt($stmt) && $stmt->bind_param("i", $this->config['confirmations']) && $stmt->execute() && $result = $stmt->get_result())
|
||||||
return $result->fetch_all(MYSQLI_ASSOC);
|
return $result->fetch_all(MYSQLI_ASSOC);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -267,4 +268,4 @@ class Block {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Automatically load our class for furhter usage
|
// Automatically load our class for furhter usage
|
||||||
$block = new Block($debug, $mysqli, SALT);
|
$block = new Block($debug, $mysqli, $config);
|
||||||
|
|||||||
@ -24,16 +24,24 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
$dNewmint = -1;
|
$dNewmint = -1;
|
||||||
$_SESSION['POPUP'][] = array('CONTENT' => 'Unable to connect to wallet RPC service: ' . $bitcoin->can_connect(), 'TYPE' => 'errormsg');
|
$_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
|
// Fetch locked balance from transactions
|
||||||
$dLockedBalance = $transaction->getLockedBalance();
|
$dLockedBalance = $transaction->getLockedBalance();
|
||||||
} else {
|
} else {
|
||||||
$debug->append('Using cached page', 3);
|
$debug->append('Using cached page', 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$smarty->assign("UNCONFIRMED", $dBlocksUnconfirmedBalance);
|
||||||
$smarty->assign("BALANCE", $dBalance);
|
$smarty->assign("BALANCE", $dBalance);
|
||||||
$smarty->assign("LOCKED", $dLockedBalance);
|
$smarty->assign("LOCKED", $dLockedBalance);
|
||||||
$smarty->assign("NEWMINT", $dNewmint);
|
$smarty->assign("NEWMINT", $dNewmint);
|
||||||
|
|
||||||
// Tempalte specifics
|
// Tempalte specifics
|
||||||
$smarty->assign("CONTENT", "default.tpl");
|
$smarty->assign("CONTENT", "default.tpl");
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@ -8,6 +8,10 @@
|
|||||||
<th>Locked for users</th>
|
<th>Locked for users</th>
|
||||||
<td class="right">{$LOCKED|number_format:"8"}</td>
|
<td class="right">{$LOCKED|number_format:"8"}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Unconfirmed</th>
|
||||||
|
<td class="right">{$UNCONFIRMED|number_format:"8"}</td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Liquid Assets</th>
|
<th>Liquid Assets</th>
|
||||||
<td class="right">{($BALANCE - $LOCKED)|number_format:"8"}</td>
|
<td class="right">{($BALANCE - $LOCKED)|number_format:"8"}</td>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user