From 3adb309d494d15dc9e8b9670f542985f1f3d07bc Mon Sep 17 00:00:00 2001
From: SomberNight <somber.night@protonmail.com>
Date: Fri, 11 Jun 2021 15:00:06 +0200
Subject: [PATCH] kivy settings: more intuitive "recoverable channels" toggle

Previously if the wallet did not have a deterministic node id,
the wallet info dialog could say "lightning enabled, non-recoverable channels", but
the "recoverable channels" setting could be toggled and might even say "yes".
---
 electrum/gui/kivy/uix/dialogs/settings.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/electrum/gui/kivy/uix/dialogs/settings.py b/electrum/gui/kivy/uix/dialogs/settings.py
index 2ced56e78..7467d7f68 100644
--- a/electrum/gui/kivy/uix/dialogs/settings.py
+++ b/electrum/gui/kivy/uix/dialogs/settings.py
@@ -24,6 +24,7 @@ Builder.load_string('''
     title: _('Electrum Settings')
     has_pin_code: False
     use_encryption: False
+    enable_toggle_use_recoverable_channels: False
     BoxLayout:
         orientation: 'vertical'
         ScrollView:
@@ -83,7 +84,8 @@ Builder.load_string('''
                     action: root.change_password
                 CardSeparator
                 SettingsItem:
-                    status: _('Yes') if app.use_recoverable_channels else _('No')
+                    disabled: not root.enable_toggle_use_recoverable_channels
+                    status: _('Yes') if (app.use_recoverable_channels and not self.disabled) else _('No')
                     title: _('Create recoverable channels') + ': ' + self.status
                     description: _("Add channel recovery data to funding transaction.")
                     message: _(messages.MSG_RECOVERABLE_CHANNELS)
@@ -128,6 +130,7 @@ class SettingsDialog(Factory.Popup):
         self.wallet = self.app.wallet
         self.use_encryption = self.wallet.has_password() if self.wallet else False
         self.has_pin_code = self.app.has_pin_code()
+        self.enable_toggle_use_recoverable_channels = self.wallet.lnworker and self.wallet.lnworker.has_deterministic_node_id()
 
     def get_language_name(self):
         return languages.get(self.config.get('language', 'en_UK'), '')