Skip to content

Commit 0df05dd

Browse files
committed
qt preferences: always show cb for LN/"Create recoverable channels"
This makes it explicit that the option cannot be enabled if so (instead of hiding the checkbox).
1 parent 62e1d8e commit 0df05dd

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

electrum/gui/kivy/uix/dialogs/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def update(self):
136136
self.wallet = self.app.wallet
137137
self.use_encryption = self.wallet.has_password() if self.wallet else False
138138
self.has_pin_code = self.app.has_pin_code()
139-
self.enable_toggle_use_recoverable_channels = bool(self.wallet.lnworker and self.wallet.lnworker.has_deterministic_node_id())
139+
self.enable_toggle_use_recoverable_channels = bool(self.wallet.lnworker and self.wallet.lnworker.can_have_recoverable_channels())
140140

141141
def get_language_name(self) -> str:
142142
lang = self.config.get('language') or ''

electrum/gui/qt/settings_dialog.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,16 +129,16 @@ def on_batch_rbf(x):
129129
# lightning
130130
lightning_widgets = []
131131

132-
if self.wallet.lnworker and self.wallet.lnworker.has_deterministic_node_id():
133-
help_recov = _(messages.MSG_RECOVERABLE_CHANNELS)
134-
recov_cb = QCheckBox(_("Create recoverable channels"))
135-
recov_cb.setToolTip(messages.to_rtf(help_recov))
136-
recov_cb.setChecked(bool(self.config.get('use_recoverable_channels', True)))
137-
def on_recov_checked(x):
138-
self.config.set_key('use_recoverable_channels', bool(x))
139-
recov_cb.stateChanged.connect(on_recov_checked)
140-
recov_cb.setEnabled(not bool(self.config.get('lightning_listen')))
141-
lightning_widgets.append((recov_cb, None))
132+
help_recov = _(messages.MSG_RECOVERABLE_CHANNELS)
133+
recov_cb = QCheckBox(_("Create recoverable channels"))
134+
enable_toggle_use_recoverable_channels = bool(self.wallet.lnworker and self.wallet.lnworker.can_have_recoverable_channels())
135+
recov_cb.setEnabled(enable_toggle_use_recoverable_channels)
136+
recov_cb.setToolTip(messages.to_rtf(help_recov))
137+
recov_cb.setChecked(bool(self.config.get('use_recoverable_channels', True)) and enable_toggle_use_recoverable_channels)
138+
def on_recov_checked(x):
139+
self.config.set_key('use_recoverable_channels', bool(x))
140+
recov_cb.stateChanged.connect(on_recov_checked)
141+
lightning_widgets.append((recov_cb, None))
142142

143143
help_trampoline = _(messages.MSG_HELP_TRAMPOLINE)
144144
trampoline_cb = QCheckBox(_("Use trampoline routing (disable gossip)"))

electrum/lnworker.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -650,14 +650,19 @@ def __init__(self, wallet: 'Abstract_Wallet', xprv):
650650
# map forwarded htlcs (fw_info=(scid_hex, htlc_id)) to originating peer pubkeys
651651
self.downstream_htlc_to_upstream_peer_map = {} # type: Dict[Tuple[str, int], bytes]
652652

653-
def has_deterministic_node_id(self):
653+
def has_deterministic_node_id(self) -> bool:
654654
return bool(self.db.get('lightning_xprv'))
655655

656-
def has_recoverable_channels(self):
657-
# TODO: expose use_recoverable_channels in preferences
658-
return self.has_deterministic_node_id() \
659-
and self.config.get('use_recoverable_channels', True) \
660-
and not (self.config.get('lightning_listen'))
656+
def can_have_recoverable_channels(self) -> bool:
657+
return (self.has_deterministic_node_id()
658+
and not (self.config.get('lightning_listen')))
659+
660+
def has_recoverable_channels(self) -> bool:
661+
"""Whether *future* channels opened by this wallet would be recoverable
662+
from seed (via putting OP_RETURN outputs into funding txs).
663+
"""
664+
return (self.can_have_recoverable_channels()
665+
and self.config.get('use_recoverable_channels', True))
661666

662667
@property
663668
def channels(self) -> Mapping[bytes, Channel]:

0 commit comments

Comments
 (0)