diff --git a/rootfs/standard/usr/bin/mynode_gen_lnd_config.sh b/rootfs/standard/usr/bin/mynode_gen_lnd_config.sh index 8252a883..f0d91802 100755 --- a/rootfs/standard/usr/bin/mynode_gen_lnd_config.sh +++ b/rootfs/standard/usr/bin/mynode_gen_lnd_config.sh @@ -13,11 +13,16 @@ else # Generate a default config cp -f /usr/share/mynode/lnd.conf /mnt/hdd/mynode/lnd/lnd.conf - # Append Watchtower Section + # Append Watchtower Server Section if [ -f /mnt/hdd/mynode/settings/watchtower_enabled ]; then cat /usr/share/mynode/lnd_watchtower.conf >> /mnt/hdd/mynode/lnd/lnd.conf fi + # Append Watchtower Client Section + if [ -f /mnt/hdd/mynode/settings/watchtower_client_enabled ]; then + cat /usr/share/mynode/lnd_watchtower_client.conf >> /mnt/hdd/mynode/lnd/lnd.conf + fi + # Append Tor/IP section (check new file or old file, should be migrated to new) if [ -f /mnt/hdd/mynode/settings/btc_lnd_tor_enabled ] || [ -f /mnt/hdd/mynode/settings/.btc_lnd_tor_enabled ]; then cat /usr/share/mynode/lnd_tor.conf >> /mnt/hdd/mynode/lnd/lnd.conf diff --git a/rootfs/standard/usr/share/mynode/lnd.conf b/rootfs/standard/usr/share/mynode/lnd.conf index 9e51ebb5..1ae8f23e 100644 --- a/rootfs/standard/usr/share/mynode/lnd.conf +++ b/rootfs/standard/usr/share/mynode/lnd.conf @@ -52,5 +52,3 @@ db.bolt.auto-compact=true [routing] routing.strictgraphpruning=true -[Wtclient] -wtclient.active=1 \ No newline at end of file diff --git a/rootfs/standard/usr/share/mynode/lnd_watchtower_client.conf b/rootfs/standard/usr/share/mynode/lnd_watchtower_client.conf new file mode 100644 index 00000000..dbb25807 --- /dev/null +++ b/rootfs/standard/usr/share/mynode/lnd_watchtower_client.conf @@ -0,0 +1,4 @@ + +[Wtclient] +wtclient.active=1 + diff --git a/rootfs/standard/var/pynode/lightning_info.py b/rootfs/standard/var/pynode/lightning_info.py index 98f78e0a..88b27ea6 100644 --- a/rootfs/standard/var/pynode/lightning_info.py +++ b/rootfs/standard/var/pynode/lightning_info.py @@ -109,7 +109,7 @@ def update_lightning_info(): lightning_channel_balance = lnd_get("/balance/channels") lightning_wallet_balance = lnd_get("/balance/blockchain") log_message("update_lightning_info - GET WATCHTOWER") - if is_watchtower_enabled(): + if is_watchtower_server_enabled(): lightning_watchtower_server_info = lnd_get_v2("/watchtower/server") towers = lnd_get_v2("/watchtower/client?include_sessions=1") log_message("update_lightning_info - TOWER DETAILS") @@ -682,15 +682,25 @@ def get_lnd_alias_file_data(): return "ERROR" return "ERROR" -def is_watchtower_enabled(): +def is_watchtower_server_enabled(): return settings_file_exists("watchtower_enabled") -def enable_watchtower(): +def enable_watchtower_server(): create_settings_file("watchtower_enabled") -def disable_watchtower(): +def disable_watchtower_server(): delete_settings_file("watchtower_enabled") + +def is_watchtower_client_enabled(): + return settings_file_exists("watchtower_client_enabled") + +def enable_watchtower_client(): + create_settings_file("watchtower_client_enabled") + +def disable_watchtower_client(): + delete_settings_file("watchtower_client_enabled") + # Only call from www process which has data def update_lightning_json_cache(): global LIGHTNING_CACHE_FILE diff --git a/rootfs/standard/var/www/mynode/lnd.py b/rootfs/standard/var/www/mynode/lnd.py index 2fab8151..39f45550 100644 --- a/rootfs/standard/var/www/mynode/lnd.py +++ b/rootfs/standard/var/www/mynode/lnd.py @@ -78,7 +78,6 @@ def page_lnd(): "wallet_logged_in": wallet_logged_in, "lnd_has_error": lnd_has_error, "using_lnd_custom_config": using_lnd_custom_config(), - "watchtower_enabled": is_watchtower_enabled(), "version": get_lnd_version(), "loop_version": get_loop_version(), "pool_version": get_pool_version(), @@ -93,7 +92,6 @@ def page_lnd(): "wallet_exists": wallet_exists, "wallet_logged_in": wallet_logged_in, "lnd_has_error": lnd_has_error, - "watchtower_enabled": is_watchtower_enabled(), "alias": alias, "status": get_lnd_status(), "version": get_lnd_version(), @@ -114,7 +112,6 @@ def page_lnd(): "wallet_exists": wallet_exists, "wallet_logged_in": False, "lnd_has_error": lnd_has_error, - "watchtower_enabled": is_watchtower_enabled(), "alias": alias, "status": "Waiting on LND data...", "version": get_lnd_version(), @@ -201,7 +198,6 @@ def page_lnd(): "uri": uri, "ip": ip, "channel_db_size": lnd_get_channel_db_size(), - "watchtower_enabled": is_watchtower_enabled(), "lit_password": get_lnd_lit_password(), "lnd_deposit_address": lnd_deposit_address, "channel_balance": format_sat_amount(balance_info["channel_balance"]), @@ -519,14 +515,28 @@ def lnd_config_page(): } return render_template('lnd_config.html', **templateData) -@mynode_lnd.route("/lnd/watchtower/set_watchtower_enabled") -def lnd_set_watchtower_enabled_page(): +@mynode_lnd.route("/lnd/watchtower/set_watchtower_server_enabled") +def lnd_set_watchtower_server_enabled_page(): check_logged_in() if request.args.get("enabled") and request.args.get("enabled") == "1": - enable_watchtower() + enable_watchtower_server() else: - disable_watchtower() + disable_watchtower_server() + + restart_lnd() + + flash("Watchtower settings updated!", category="message") + return redirect(url_for(".page_lnd_watchtower")) + +@mynode_lnd.route("/lnd/watchtower/set_watchtower_client_enabled") +def lnd_set_watchtower_client_enabled_page(): + check_logged_in() + + if request.args.get("enabled") and request.args.get("enabled") == "1": + enable_watchtower_client() + else: + disable_watchtower_client() restart_lnd() @@ -544,8 +554,9 @@ def page_lnd_watchtower(): templateData = { "title": "myNode Lightning Watchtower", - "watchtower_server_enabled": is_watchtower_enabled(), + "watchtower_server_enabled": is_watchtower_server_enabled(), "watchtower_server_uri": Markup(watchtower_server_info["watchtower_server_uri"]), + "watchtower_client_enabled": is_watchtower_client_enabled(), "watchtower_client_towers": watchtower_client_towers, "watchtower_client_stats": watchtower_client_stats, "watchtower_client_policy": watchtower_client_policy, diff --git a/rootfs/standard/var/www/mynode/templates/lnd_watchtower.html b/rootfs/standard/var/www/mynode/templates/lnd_watchtower.html index ae1a22f4..ab68cf63 100644 --- a/rootfs/standard/var/www/mynode/templates/lnd_watchtower.html +++ b/rootfs/standard/var/www/mynode/templates/lnd_watchtower.html @@ -23,11 +23,26 @@ enabled=$('#watchtower_server_enabled_checkbox').is(":checked") if (enabled) { - window.location.href='/lnd/watchtower/set_watchtower_enabled?enabled=1' + window.location.href='/lnd/watchtower/set_watchtower_server_enabled?enabled=1' } else { - window.location.href='/lnd/watchtower/set_watchtower_enabled?enabled=0' + window.location.href='/lnd/watchtower/set_watchtower_server_enabled?enabled=0' + } + }); + + $('#watchtower_client_enabled_checkbox').change(function () { + $("#watchtower_client_enabled_save").show(); + }); + $("#watchtower_client_enabled_save").on("click", function() { + enabled=$('#watchtower_client_enabled_checkbox').is(":checked") + if (enabled) + { + window.location.href='/lnd/watchtower/set_watchtower_client_enabled?enabled=1' + } + else + { + window.location.href='/lnd/watchtower/set_watchtower_client_enabled?enabled=0' } }); @@ -88,11 +103,24 @@
Enabled | +
+
+ + + |
+
---|