diff --git a/rootfs/standard/var/www/mynode/lightning_info.py b/rootfs/standard/var/www/mynode/lightning_info.py index d44eb842..268c984d 100644 --- a/rootfs/standard/var/www/mynode/lightning_info.py +++ b/rootfs/standard/var/www/mynode/lightning_info.py @@ -29,6 +29,7 @@ lightning_payments = None lightning_invoices = None lightning_watchtower_server_info = None lightning_desync_count = 0 +lightning_update_count = 0 LND_FOLDER = "/mnt/hdd/mynode/lnd/" TLS_CERT_FILE = "/mnt/hdd/mynode/lnd/tls.cert" @@ -46,10 +47,17 @@ def update_lightning_info(): global lightning_invoices global lightning_watchtower_server_info global lightning_desync_count + global lightning_update_count global lnd_ready + # Check logged in + #while not is_lnd_logged_in(): + # lnd_ready = False + # time.sleep(10) + # Get latest LN info lightning_info = lnd_get("/getinfo") + lightning_update_count = lightning_update_count + 1 # Set is LND ready if lightning_info != None and "synced_to_chain" in lightning_info and lightning_info['synced_to_chain']: @@ -76,11 +84,12 @@ def update_lightning_info(): lightning_channels = lnd_get("/channels") lightning_channel_balance = lnd_get("/balance/channels") lightning_wallet_balance = lnd_get("/balance/blockchain") - #lightning_transactions = lnd_get("/transactions") - #lightning_payments = lnd_get("/payments") - #lightning_invoices = lnd_get("/invoices") lightning_watchtower_server_info = lnd_get_v2("/watchtower/server") + # Poll slower + if lightning_update_count % 2 == 0: + update_lightning_tx_info() + return True def update_lightning_tx_info(): @@ -335,9 +344,11 @@ def restart_lnd_actual(): os.system("systemctl restart lnd_admin") def restart_lnd(): - t = Timer(1.0, restart_lnd_actual) + t = Timer(0.1, restart_lnd_actual) t.start() + time.sleep(1) + def is_testnet_enabled(): return os.path.isfile("/mnt/hdd/mynode/settings/.testnet_enabled") diff --git a/rootfs/standard/var/www/mynode/lnd.py b/rootfs/standard/var/www/mynode/lnd.py index bceaba25..a37ab0fb 100644 --- a/rootfs/standard/var/www/mynode/lnd.py +++ b/rootfs/standard/var/www/mynode/lnd.py @@ -49,6 +49,7 @@ def page_lnd(): check_logged_in() height = 0 + refresh_rate = 3600 alias = get_lnd_alias_file_data() num_peers = "0" num_active_channels = "TODO" @@ -93,6 +94,7 @@ def page_lnd(): "version": get_lnd_version(), "loop_version": get_loop_version(), "pool_version": get_pool_version(), + "refresh_rate": 10, "ui_settings": read_ui_settings() } return render_template('lnd.html', **templateData) @@ -152,10 +154,14 @@ def page_lnd(): "header": "Lightning Status", #"message": str(e), "message": traceback.format_exc(), + "refresh_rate": 10, "ui_settings": read_ui_settings() } return render_template('error.html', **templateData) + if not is_lnd_ready(): + refresh_rate = 15 + templateData = { "title": "myNode Lightning Status", "wallet_exists": wallet_exists, @@ -189,6 +195,7 @@ def page_lnd(): "payments": payments, "invoices": invoices, "tx_display_limit": 8, + "refresh_rate": refresh_rate, "ui_settings": read_ui_settings() } return render_template('lnd.html', **templateData) @@ -200,7 +207,7 @@ def lnd_regen_tls_cert(): os.system("rm /mnt/hdd/mynode/lnd/tls.cert") os.system("rm /mnt/hdd/mynode/lnd/tls.key") - t = Timer(1.0, restart_lnd) + t = Timer(3.0, restart_lnd) t.start() flash("TLS Certificate Regenerated!", category="message") diff --git a/rootfs/standard/var/www/mynode/templates/error.html b/rootfs/standard/var/www/mynode/templates/error.html index 0333e470..c1479faf 100644 --- a/rootfs/standard/var/www/mynode/templates/error.html +++ b/rootfs/standard/var/www/mynode/templates/error.html @@ -2,6 +2,10 @@