Merge pull request #43 from lemsmyth/wallet-balance-fix

This commit is contained in:
Alex Grin 2022-01-31 09:12:42 -05:00 committed by GitHub
commit 4b0e17bcf4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
* https://lbry.tech/api/sdk#wallet_balance
* @param string $address Wallet Address
* @return float Wallet Balance
* @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);