Adding support for the latest Bitcoin's changes
- Accounts was removed, instead, now, we have labels
This commit is contained in:
parent
ffa5bb326d
commit
fd0f0fd656
@ -55,15 +55,21 @@ class BitcoinWrapper extends BitcoinClient {
|
|||||||
// Wrapper method to get the real main account balance
|
// Wrapper method to get the real main account balance
|
||||||
public function getrealbalance() {
|
public function getrealbalance() {
|
||||||
$this->oDebug->append("STA " . __METHOD__, 4);
|
$this->oDebug->append("STA " . __METHOD__, 4);
|
||||||
$aAccounts = parent::listaccounts();
|
$aAccounts = [];
|
||||||
$dBalance = parent::getbalance('');
|
|
||||||
|
try {
|
||||||
|
$aAccounts = parent::listaccounts();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if ($e->getCode() == 404)
|
||||||
|
$aAccounts = array( '*' => parent::getbalance("*") );
|
||||||
|
}
|
||||||
|
|
||||||
// Account checks
|
// Account checks
|
||||||
if (count($aAccounts) == 1) {
|
if (count($aAccounts) == 1) {
|
||||||
// We only have a single account so getbalance will be fine
|
// We only have a single account so getbalance will be fine
|
||||||
return $dBalance;
|
return parent::getbalance("*");
|
||||||
} else {
|
} else {
|
||||||
$dMainBalance = $aAccounts[''];
|
return $aAccounts[0];
|
||||||
return $dMainBalance;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public function getdifficulty() {
|
public function getdifficulty() {
|
||||||
|
|||||||
@ -97,7 +97,7 @@ class jsonRPCClient {
|
|||||||
'id' => $this->id
|
'id' => $this->id
|
||||||
);
|
);
|
||||||
$request = json_encode($request);
|
$request = json_encode($request);
|
||||||
if ($this->debug) $this->debug_output[] = 'Request: '.$request;
|
if ($this->debug) $this->debug_output = 'Request: '.$request[0];
|
||||||
|
|
||||||
// performs the HTTP POST
|
// performs the HTTP POST
|
||||||
// extract information from URL for proper authentication
|
// extract information from URL for proper authentication
|
||||||
@ -112,12 +112,12 @@ class jsonRPCClient {
|
|||||||
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
// curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
|
||||||
$response = curl_exec($ch);
|
$response = curl_exec($ch);
|
||||||
if (curl_errno($ch)) throw new Exception('RPC call failed: ' . curl_error($ch));
|
if (curl_errno($ch)) throw new Exception('RPC call failed: ' . curl_error($ch));
|
||||||
if ($this->debug) $this->debug_output[] = 'Response: ' . $response;
|
if ($this->debug) $this->debug_output = 'Response: ' . $response[0];
|
||||||
$response = json_decode($response, true);
|
$response = json_decode($response, true);
|
||||||
$resultStatus = curl_getinfo($ch);
|
$resultStatus = curl_getinfo($ch);
|
||||||
if ($resultStatus['http_code'] != '200') {
|
if ($resultStatus['http_code'] != '200') {
|
||||||
if ($resultStatus['http_code'] == '401') throw new Exception('RPC call did not return 200: Authentication failed');
|
if ($resultStatus['http_code'] == '401') throw new Exception('RPC call did not return 200: Authentication failed');
|
||||||
throw new Exception('RPC call did not return 200: HTTP error: ' . $resultStatus['http_code'] . ' - JSON Response: [' . @$response['error']['code'] . '] ' . @$response['error']['message']);
|
throw new Exception('RPC call did not return 200: HTTP error: ' . $resultStatus['http_code'] . ' - JSON Response: [' . @$response['error']['code'] . '] ' . @$response['error']['message'], $resultStatus['http_code']);
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,13 @@ try {
|
|||||||
$newerror = null;
|
$newerror = null;
|
||||||
}
|
}
|
||||||
// check if there is more than one account set on wallet
|
// check if there is more than one account set on wallet
|
||||||
$accounts = $bitcoin->listaccounts();
|
try {
|
||||||
|
$accounts = $bitcoin->listaccounts();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if ($e->getCode() == 404)
|
||||||
|
$accounts = $bitcoin->listwallets();
|
||||||
|
}
|
||||||
|
|
||||||
if (count($accounts) > 1 && $accounts[''] <= 0) {
|
if (count($accounts) > 1 && $accounts[''] <= 0) {
|
||||||
$newerror = array();
|
$newerror = array();
|
||||||
$newerror['name'] = "Coin daemon";
|
$newerror['name'] = "Coin daemon";
|
||||||
|
|||||||
@ -11,14 +11,32 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
$debug->append('No cached version available, fetching from backend', 3);
|
$debug->append('No cached version available, fetching from backend', 3);
|
||||||
if ($bitcoin->can_connect() === true) {
|
if ($bitcoin->can_connect() === true) {
|
||||||
$dBalance = $bitcoin->getrealbalance();
|
$dBalance = $bitcoin->getrealbalance();
|
||||||
|
$labelsCommand = false;
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dWalletAccounts = $bitcoin->listaccounts();
|
||||||
|
} catch (Exception $e) {
|
||||||
|
if ($e->getCode() == 404) {
|
||||||
|
$dWalletAccounts = $bitcoin->listlabels();
|
||||||
|
$labelsCommand = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$dWalletAccounts = $bitcoin->listaccounts();
|
|
||||||
$dAddressCount = count($dWalletAccounts);
|
$dAddressCount = count($dWalletAccounts);
|
||||||
|
|
||||||
$dAccountAddresses = array();
|
$dAccountAddresses = array();
|
||||||
foreach($dWalletAccounts as $key => $value)
|
foreach($dWalletAccounts as $key => $value)
|
||||||
{
|
{
|
||||||
$dAccountAddresses[$key] = $bitcoin->getaddressesbyaccount((string)$key);
|
if (!($labelsCommand))
|
||||||
|
$dAccountAddresses[$key] = $bitcoin->getaddressesbyaccount((string)$key);
|
||||||
|
else {
|
||||||
|
if (strlen($value) == 0)
|
||||||
|
$value = "";
|
||||||
|
|
||||||
|
foreach ($bitcoin->getaddressesbylabel((string)$value) as $key2 => $value2) {
|
||||||
|
$dAccountAddresses[$key][$key2] = $value2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$aGetInfo = $bitcoin->getinfo();
|
$aGetInfo = $bitcoin->getinfo();
|
||||||
@ -26,7 +44,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
if ($aGetInfo['connections'] == 0) $aGetInfo['errors'] = 'No peers';
|
if ($aGetInfo['connections'] == 0) $aGetInfo['errors'] = 'No peers';
|
||||||
# Check if daemon is downloading the blockchain, estimated
|
# Check if daemon is downloading the blockchain, estimated
|
||||||
if ($dDownloadPercentage = $bitcoin->getblockchaindownload()) $aGetInfo['errors'] = "Downloading: $dDownloadPercentage%";
|
if ($dDownloadPercentage = $bitcoin->getblockchaindownload()) $aGetInfo['errors'] = "Downloading: $dDownloadPercentage%";
|
||||||
$aGetTransactions = $bitcoin->listtransactions('', (int)$setting->getValue('wallet_transaction_limit', 25));
|
$aGetTransactions = $bitcoin->listtransactions('*', (int)$setting->getValue('wallet_transaction_limit', 25));
|
||||||
if (is_array($aGetInfo) && array_key_exists('newmint', $aGetInfo)) {
|
if (is_array($aGetInfo) && array_key_exists('newmint', $aGetInfo)) {
|
||||||
$dNewmint = $aGetInfo['newmint'];
|
$dNewmint = $aGetInfo['newmint'];
|
||||||
} else {
|
} else {
|
||||||
@ -69,6 +87,7 @@ if (!$smarty->isCached('master.tpl', $smarty_cache_key)) {
|
|||||||
$smarty->assign("PEERINFO", $aGetPeerInfo);
|
$smarty->assign("PEERINFO", $aGetPeerInfo);
|
||||||
$smarty->assign('PRECISION', $coin->getCoinValuePrevision());
|
$smarty->assign('PRECISION', $coin->getCoinValuePrevision());
|
||||||
$smarty->assign("TRANSACTIONS", $aGetTransactions);
|
$smarty->assign("TRANSACTIONS", $aGetTransactions);
|
||||||
|
$smarty->assign("LABELSCOMMAND", $labelsCommand);
|
||||||
} else {
|
} else {
|
||||||
$debug->append('Using cached page', 3);
|
$debug->append('Using cached page', 3);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,50 +2,75 @@
|
|||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="panel panel-info">
|
<div class="panel panel-info">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="fa fa-users fa-fw"></i> Wallet Accounts
|
{if $LABELSCOMMAND}
|
||||||
|
<i class="fa fa-users fa-fw"></i> Wallet Labels
|
||||||
|
{else}
|
||||||
|
<i class="fa fa-users fa-fw"></i> Wallet Accounts
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body ">
|
<div class="panel-body ">
|
||||||
<div class="panel-group">
|
<div class="panel-group">
|
||||||
{foreach key=NAME item=VALUE from=$ACCOUNTS}
|
{foreach key=NAME item=VALUE from=$ACCOUNTS}
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="fa fa-user fa-fw"></i> Account: {$NAME|default:"Default"}
|
{if $LABELSCOMMAND}
|
||||||
|
<i class="fa fa-user fa-fw"></i> Label: {$VALUE|default:"Default"}
|
||||||
|
{else}
|
||||||
|
<i class="fa fa-user fa-fw"></i> Account: {$NAME|default:"Default"}
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
<div class="col-lg-4">
|
{if (not ($LABELSCOMMAND))}
|
||||||
<div class="panel panel-info">
|
<div class="col-lg-4">
|
||||||
<div class="panel-heading">
|
<div class="panel panel-info">
|
||||||
<i class="fa fa-money fa-fw"></i> Balance Info
|
<div class="panel-heading">
|
||||||
</div>
|
<i class="fa fa-money fa-fw"></i> Balance Info
|
||||||
<div class="table-responsive panel-body no-padding">
|
</div>
|
||||||
<table class="table table-striped table-bordered table-hover">
|
<div class="table-responsive panel-body no-padding">
|
||||||
<tr>
|
<table class="table table-striped table-bordered table-hover">
|
||||||
<td class="col-lg-4">Balance</td>
|
<tr>
|
||||||
<td class="col-lg-12">{$VALUE|number_format:"8"}</td>
|
<td class="col-lg-4">Balance</td>
|
||||||
</tr>
|
<td class="col-lg-12">{$VALUE|number_format:"8"}</td>
|
||||||
</table>
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
{/if}
|
||||||
|
|
||||||
{foreach key=ACCOUNT item=ADDRESS from=$ACCOUNTADDRESSES}
|
{foreach key=ACCOUNT item=ADDRESS from=$ACCOUNTADDRESSES}
|
||||||
{if $ACCOUNT == $NAME}
|
{if $ACCOUNT == $NAME}
|
||||||
|
{if $LABELSCOMMAND}
|
||||||
|
<div class="col-lg-12">
|
||||||
|
{else}
|
||||||
<div class="col-lg-8">
|
<div class="col-lg-8">
|
||||||
|
{/if}
|
||||||
<div class="panel panel-info">
|
<div class="panel panel-info">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<i class="fa fa-book fa-fw"></i> Addresses assigned to Account {$ACCOUNT|default:"Default"}
|
{if $LABELSCOMMAND}
|
||||||
|
<i class="fa fa-book fa-fw"></i> Addresses assigned to Label {$VALUE|default:"Default"}
|
||||||
|
{else}
|
||||||
|
<i class="fa fa-book fa-fw"></i> Addresses assigned to Account {$ACCOUNT|default:"Default"}
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="table-responsive panel-body no-padding">
|
<div class="table-responsive panel-body no-padding">
|
||||||
<table class="table table-striped table-bordered table-hover">
|
<table class="table table-striped table-bordered table-hover">
|
||||||
<tbody>
|
<tbody>
|
||||||
{foreach from=$ACCOUNTADDRESSES[$ACCOUNT] key=ACCOUNT1 item=ADDRESS1}
|
{foreach from=$ACCOUNTADDRESSES[$ACCOUNT] key=ACCOUNT1 item=ADDRESS1}
|
||||||
{if $ADDRESS1@iteration is even by 1}
|
{if not $LABELSCOMMAND}
|
||||||
<td>{$ADDRESS1}</td>
|
{if $ADDRESS1@iteration is even by 1}
|
||||||
</tr>
|
<td>{$ADDRESS1}</td>
|
||||||
|
</tr>
|
||||||
|
{else}
|
||||||
|
<tr>
|
||||||
|
<td>{$ADDRESS1}</td>
|
||||||
|
{/if}
|
||||||
{else}
|
{else}
|
||||||
<tr>
|
{foreach from=$ACCOUNT1 key=ACCOUNT2 item=ADDRESS2}
|
||||||
<td>{$ADDRESS1}</td>
|
<tr>
|
||||||
|
<td>{$ADDRESS2}</td>
|
||||||
|
</tr>
|
||||||
|
{/foreach}
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@ -14,7 +14,11 @@
|
|||||||
<th>Peers</th>
|
<th>Peers</th>
|
||||||
<th>Status</th>
|
<th>Status</th>
|
||||||
<th>Blocks</th>
|
<th>Blocks</th>
|
||||||
<th>Accounts</th>
|
{if $LABELSCOMMAND}
|
||||||
|
<th>Labels</th>
|
||||||
|
{else}
|
||||||
|
<th>Accounts</th>
|
||||||
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|||||||
@ -9,7 +9,11 @@
|
|||||||
<table class="table table-striped table-bordered table-hover">
|
<table class="table table-striped table-bordered table-hover">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-center">Account</th>
|
{if $LABELSCOMMAND}
|
||||||
|
<th class="text-center">Label</th>
|
||||||
|
{else}
|
||||||
|
<th class="text-center">Account</th>
|
||||||
|
{/if}
|
||||||
<th class="text-center">Address</th>
|
<th class="text-center">Address</th>
|
||||||
<th class="text-center">Category</th>
|
<th class="text-center">Category</th>
|
||||||
<th class="text-right">Amount</th>
|
<th class="text-right">Amount</th>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user