Add lightning balance info to home page

This commit is contained in:
Taylor Helsper 2021-03-14 23:58:40 -05:00
parent bfbcd93160
commit 0098a8c15b
6 changed files with 33 additions and 32 deletions

View File

@ -711,13 +711,6 @@ def get_flask_secret_key():
return key
#==================================
# UI Format Functions
#==================================
def format_sat_amount(amount):
return "{:,}".format(int(amount))
#==================================
# Uploader Functions
#==================================

View File

@ -146,15 +146,15 @@ def get_lightning_balance_info():
channel_balance_data = get_lightning_channel_balance()
if channel_balance_data != None and "balance" in channel_balance_data:
balance_data["channel_balance"] = channel_balance_data["balance"]
balance_data["channel_balance"] = format_sat_amount( channel_balance_data["balance"] )
if channel_balance_data != None and "pending_open_balance" in channel_balance_data:
balance_data["channel_pending"] = channel_balance_data["pending_open_balance"]
balance_data["channel_pending"] = format_sat_amount( channel_balance_data["pending_open_balance"] )
wallet_balance_data = get_lightning_wallet_balance()
if wallet_balance_data != None and "confirmed_balance" in wallet_balance_data:
balance_data["wallet_balance"] = wallet_balance_data["confirmed_balance"]
balance_data["wallet_balance"] = format_sat_amount( wallet_balance_data["confirmed_balance"] )
if wallet_balance_data != None and "unconfirmed_balance" in wallet_balance_data:
balance_data["wallet_pending"] = wallet_balance_data["unconfirmed_balance"]
balance_data["wallet_pending"] = format_sat_amount( wallet_balance_data["unconfirmed_balance"] )
return balance_data

View File

@ -5,6 +5,7 @@ from bitcoin_info import *
from lightning_info import *
from settings import reboot_device, read_ui_settings
from device_info import *
from utilities import *
from user_management import check_logged_in
from werkzeug.utils import secure_filename
import base64

View File

@ -49,8 +49,8 @@ td, th {
border-collapse: collapse;
border-top: #e7e7e7 1px solid;
}
.td_left_header {
padding-right: 40px;
.service_table_td_left_header {
padding-right: 10px;
min-width: 120px;
}

View File

@ -16,23 +16,23 @@
<div style="width: 230px; padding-left: 10px; float: right;">
<table style="font-size: 10px; width: 100%;" cellpadding="0" cellspacing="0">
<tr>
<td class="td_left_header">Height</td>
<td class="service_table_td_left_header">Height</td>
<td id="current_block">{{ current_block }}</td>
</tr>
<tr>
<td class="td_left_header">Peers</td>
<td class="service_table_td_left_header">Peers</td>
<td id="bitcoin_peer_count">{{ bitcoin_peer_count }}</td>
</tr>
<tr>
<td class="td_left_header">Difficulty</td>
<td class="service_table_td_left_header">Difficulty</td>
<td id="bitcoin_difficulty">{{ bitcoin_difficulty }}</td>
</tr>
<tr>
<td class="td_left_header">Mempool Size</td>
<td class="service_table_td_left_header">Mempool Size</td>
<td id="bitcoin_mempool_size">{{ bitcoin_mempool_size }}</td>
</tr>
<tr>
<td class="td_left_header">Version</td>
<td class="service_table_td_left_header">Version</td>
<td id="bitcoin_version">{{ bitcoin_version }}</td>
</tr>
</table>
@ -62,26 +62,26 @@
</div>
<div style="width: 230px; padding-left: 10px; float: right;">
<table style="font-size: 10px; width: 100%;" cellpadding="0" cellspacing="0">
{% if lnd_ready %}
<tr>
<td class="td_left_header">Peers</td>
<td class="service_table_td_left_header">On-chain Balance</td>
<td>{{ lnd_balance_info['wallet_balance'] }} sats</td>
</tr>
<tr>
<td class="service_table_td_left_header">Lightning Balance</td>
<td>{{ lnd_balance_info['channel_balance'] }} sats</td>
</tr>
{% endif %}
<tr>
<td class="service_table_td_left_header">Peers</td>
<td id="lnd_peer_count">{{ lnd_peer_count }}</td>
</tr>
<tr>
<td class="td_left_header">Channels</td>
<td class="service_table_td_left_header">Channels</td>
<td id="lnd_channel_count">{{ lnd_channel_count }}</td>
</tr>
<!--
<tr>
<td class="td_left_header">On-chain Balance</td>
<td>{{ lnd_balance_info['wallet_balance'] }}</td>
</tr>
<tr>
<td class="td_left_header">Lightning Balance</td>
<td>{{ lnd_balance_info['channel_balance'] }}</td>
</tr>
-->
<tr>
<td class="td_left_header">Version</td>
<td class="service_table_td_left_header">Version</td>
<td>{{ lnd_version }}</td>
</tr>
</table>

View File

@ -53,4 +53,11 @@ def set_data(key, value):
def get_data(key):
r = redis.Redis(host='localhost', port=6379, db=0)
mynode_key = "mynode_" + key
return r.get(mynode_key)
return r.get(mynode_key)
#==================================
# UI Format Functions
#==================================
def format_sat_amount(amount):
return "{:,}".format(int(amount))