From c1541f49ec0837a05dcfa5f54d17057738be09ce Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Sat, 10 Jun 2023 22:43:55 -0500 Subject: [PATCH] Add option to reset macaroons --- rootfs/standard/var/pynode/device_info.py | 4 ++++ rootfs/standard/var/www/mynode/settings.py | 12 ++++++++++++ .../var/www/mynode/templates/settings.html | 18 ++++++++++++++++++ 3 files changed, 34 insertions(+) diff --git a/rootfs/standard/var/pynode/device_info.py b/rootfs/standard/var/pynode/device_info.py index 4f757220..5f4ae633 100644 --- a/rootfs/standard/var/pynode/device_info.py +++ b/rootfs/standard/var/pynode/device_info.py @@ -1115,6 +1115,10 @@ def delete_lnd_watchtower_server_data(): os.system("rm -rf /mnt/hdd/mynode/lnd/data/watchtower") return True +def delete_lnd_macaroons(): + os.system("find /mnt/hdd/mynode/lnd/data/chain/bitcoin/mainnet/ -name '*.macaroon' -delete") + os.system("find /mnt/hdd/mynode/lnd/data/chain/bitcoin/testnet/ -name '*.macaroon' -delete") + return True #================================== # Mainnet / Testnet Functions diff --git a/rootfs/standard/var/www/mynode/settings.py b/rootfs/standard/var/www/mynode/settings.py index 36943f30..af9ce298 100644 --- a/rootfs/standard/var/www/mynode/settings.py +++ b/rootfs/standard/var/www/mynode/settings.py @@ -730,6 +730,18 @@ def page_lnd_delete_wallet(): return redirect("/rebooting") +@mynode_settings.route("/settings/reset-macaroons") +def page_lnd_reset_macaroons(): + check_logged_in() + + delete_lnd_macaroons() + + # Trigger reboot + t = Timer(1.0, reboot_device) + t.start() + + return redirect("/rebooting") + @mynode_settings.route("/settings/reset-lnd-watchtower") def page_lnd_reset_lnd_watchtower(): check_logged_in() diff --git a/rootfs/standard/var/www/mynode/templates/settings.html b/rootfs/standard/var/www/mynode/templates/settings.html index 6d08d8da..7d10cf5c 100644 --- a/rootfs/standard/var/www/mynode/templates/settings.html +++ b/rootfs/standard/var/www/mynode/templates/settings.html @@ -58,6 +58,17 @@ delete_lnd_wallet_dialog.dialog( "open" ); }); + $("#reset_macaroons").on("click", function() { + var okFunction = function() { + window.location.href="/settings/reset-macaroons" + } + openConfirmDialog("confirm-dialog", + "Reset Lightning Macaroons", + "Resetting your LND Macaroons will delete them and reboot your device. You will need to re-pair any connected wallets. "+ + "Would you still like to reset your macaroons?", + okFunction) + }); + $("#reset_lnd_watchtower_client").on("click", function() { var okFunction = function() { window.location.href="/settings/reset-lnd-watchtower?type=client" @@ -1060,6 +1071,13 @@
+
Reset Macaroons
+ Advanced: This will delete your LND macaroons and any paired wallets will no longer work. It will delete both mainnet and testnet macaroons if you have them. +
+ + +
+
Delete Lightning Wallet
{{lnd_delete_message}} Advanced: This will delete your Lightning Wallet. It will delete both mainnet and testnet wallets if you have them.