Browse Source

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).
patch-4
SomberNight 3 years ago
parent
commit
0df05dd914
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 2
      electrum/gui/kivy/uix/dialogs/settings.py
  2. 20
      electrum/gui/qt/settings_dialog.py
  3. 17
      electrum/lnworker.py

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

@ -136,7 +136,7 @@ class SettingsDialog(Factory.Popup):
self.wallet = self.app.wallet self.wallet = self.app.wallet
self.use_encryption = self.wallet.has_password() if self.wallet else False self.use_encryption = self.wallet.has_password() if self.wallet else False
self.has_pin_code = self.app.has_pin_code() self.has_pin_code = self.app.has_pin_code()
self.enable_toggle_use_recoverable_channels = bool(self.wallet.lnworker and self.wallet.lnworker.has_deterministic_node_id()) self.enable_toggle_use_recoverable_channels = bool(self.wallet.lnworker and self.wallet.lnworker.can_have_recoverable_channels())
def get_language_name(self) -> str: def get_language_name(self) -> str:
lang = self.config.get('language') or '' lang = self.config.get('language') or ''

20
electrum/gui/qt/settings_dialog.py

@ -129,16 +129,16 @@ class SettingsDialog(WindowModalDialog):
# lightning # lightning
lightning_widgets = [] lightning_widgets = []
if self.wallet.lnworker and self.wallet.lnworker.has_deterministic_node_id(): help_recov = _(messages.MSG_RECOVERABLE_CHANNELS)
help_recov = _(messages.MSG_RECOVERABLE_CHANNELS) recov_cb = QCheckBox(_("Create recoverable channels"))
recov_cb = QCheckBox(_("Create recoverable channels")) enable_toggle_use_recoverable_channels = bool(self.wallet.lnworker and self.wallet.lnworker.can_have_recoverable_channels())
recov_cb.setToolTip(messages.to_rtf(help_recov)) recov_cb.setEnabled(enable_toggle_use_recoverable_channels)
recov_cb.setChecked(bool(self.config.get('use_recoverable_channels', True))) recov_cb.setToolTip(messages.to_rtf(help_recov))
def on_recov_checked(x): recov_cb.setChecked(bool(self.config.get('use_recoverable_channels', True)) and enable_toggle_use_recoverable_channels)
self.config.set_key('use_recoverable_channels', bool(x)) def on_recov_checked(x):
recov_cb.stateChanged.connect(on_recov_checked) self.config.set_key('use_recoverable_channels', bool(x))
recov_cb.setEnabled(not bool(self.config.get('lightning_listen'))) recov_cb.stateChanged.connect(on_recov_checked)
lightning_widgets.append((recov_cb, None)) lightning_widgets.append((recov_cb, None))
help_trampoline = _(messages.MSG_HELP_TRAMPOLINE) help_trampoline = _(messages.MSG_HELP_TRAMPOLINE)
trampoline_cb = QCheckBox(_("Use trampoline routing (disable gossip)")) trampoline_cb = QCheckBox(_("Use trampoline routing (disable gossip)"))

17
electrum/lnworker.py

@ -650,14 +650,19 @@ class LNWallet(LNWorker):
# map forwarded htlcs (fw_info=(scid_hex, htlc_id)) to originating peer pubkeys # map forwarded htlcs (fw_info=(scid_hex, htlc_id)) to originating peer pubkeys
self.downstream_htlc_to_upstream_peer_map = {} # type: Dict[Tuple[str, int], bytes] self.downstream_htlc_to_upstream_peer_map = {} # type: Dict[Tuple[str, int], bytes]
def has_deterministic_node_id(self): def has_deterministic_node_id(self) -> bool:
return bool(self.db.get('lightning_xprv')) return bool(self.db.get('lightning_xprv'))
def has_recoverable_channels(self): def can_have_recoverable_channels(self) -> bool:
# TODO: expose use_recoverable_channels in preferences return (self.has_deterministic_node_id()
return self.has_deterministic_node_id() \ and not (self.config.get('lightning_listen')))
and self.config.get('use_recoverable_channels', True) \
and not (self.config.get('lightning_listen')) def has_recoverable_channels(self) -> bool:
"""Whether *future* channels opened by this wallet would be recoverable
from seed (via putting OP_RETURN outputs into funding txs).
"""
return (self.can_have_recoverable_channels()
and self.config.get('use_recoverable_channels', True))
@property @property
def channels(self) -> Mapping[bytes, Channel]: def channels(self) -> Mapping[bytes, Channel]:

Loading…
Cancel
Save