add lbc image, fix wallet balance #43

Merged
lemsmyth merged 3 commits from wallet-balance-fix into master 2022-01-31 15:12:43 +01:00
3 changed files with 11 additions and 9 deletions

BIN
admin/images/lbc.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

View file

@ -69,18 +69,19 @@ class LBRY_Daemon
/**
* Returns the available balance of a current LBRY account
* https://lbry.tech/api/sdk#account_balance
* @param string $address Wallet Address
* @return float Wallet Balance
* https://lbry.tech/api/sdk#wallet_balance
* @param string $address Wallet Address
* @return array $wallet_balance Wallet Balance
*
*/
public function wallet_balance()
{
try {
$result = $this->request('account_balance');
return $result->result->available;
try { // Convert JSON string to an object
$result = $this->request('wallet_balance');
return $result;
} catch (LBRYDaemonException $e) {
$this->logger->log('account_balance error', $e->getMessage() . ' | Code: ' . $e->getCode());
LBRY()->notice->set_notice('error', 'Issue getting account balance.');
$this->logger->log('wallet_balance error', $e->getMessage() . ' | Code: ' . $e->getCode());
LBRY()->notice->set_notice('error', 'Issue getting wallet balance.');
return;
}
}

View file

@ -1,13 +1,14 @@
<?php
$LBRY = LBRY();
$wallet_balance = $LBRY->daemon->wallet_balance();
$available_balance = $wallet_balance->result->available;
$channel_list = $LBRY->daemon->channel_list();
// TODO: Make this page look cleaner
?>
<div class="wrap">
<h1><?= esc_html(get_admin_page_title()); ?></h1>
<h2>Your wallet amount:</h2>
<code><?= number_format($wallet_balance, 2, '.', ','); ?></code>
<img src="<?php echo esc_url( plugin_dir_url(LBRY_PLUGIN_FILE) . 'admin/images/lbc.png') ?>" class="icon icon-lbc wallet-icon-lbc" style="height: 1.8em; margin-right: .5em; margin-bottom: -.5em;"><code><?= number_format($available_balance, 2, '.', ','); ?></code>
<form action="options.php" method="post">
<?php
settings_fields(LBRY_SETTINGS_GROUP);