Skip to content

Commit

Permalink
Closes #5 by showing native currency in address detai page
Browse files Browse the repository at this point in the history
This patch was written by @reiven here: https://github.com/reiven
/multichain-explorer/commit/1d3b88c7bf1d7a38d06c41a08d8c1ac5c1b2c6e8
  • Loading branch information
bitcartel committed Oct 31, 2016
1 parent 13e8a0a commit 168c826
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Mce/abe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1719,6 +1719,28 @@ def handle_address(abe, page):
body += ['<div class="alert alert-danger" role="alert">', msg, '</div>']
return

# Display native currency if the blockchain has one
if abe.get_blockchainparams(chain).get('initial-block-reward', 0) > 0:
body += ['<h3>Native Balance</h3>']
try:
resp = util.jsonrpc(multichain_name, url, "getaddressbalances", address)
if len(resp) is 0:
body += ['None']
else:
body += ['<ul>']
for balance in resp:
if str(balance['assetref']) is '':
body += ['<li>', str(balance['qty']), '</li>']
body += ['</ul>']
except util.JsonrpcException as e:
msg= "Failed to get balance for address: JSON-RPC error({0}): {1}".format(e.code, e.message)
body += ['<div class="alert alert-danger" role="warning">', msg, '</div>']
return
except IOError as e:
msg= "Failed to get balance for address: I/O error({0}): {1}".format(e.errno, e.strerror)
body += ['<div class="alert alert-danger" role="alert">', msg, '</div>']
return

body += ['<h3>Asset Balances</h3>']
try:
row = abe.store.selectrow("""select pubkey_id from pubkey where pubkey_hash = ?""",
Expand Down

0 comments on commit 168c826

Please sign in to comment.