Browse Source

qt ChannelsList: disable toolbar menu if `not wallet.has_lightning()`

closes https://github.com/spesmilo/electrum/issues/8321
master
SomberNight 3 years ago
parent
commit
22205dccb1
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/gui/qt/channels_list.py
  2. 6
      electrum/gui/qt/main_window.py

3
electrum/gui/qt/channels_list.py

@ -363,6 +363,9 @@ class ChannelsList(MyTreeView):
menu.addAction(read_QIcon('update.png'), _('Submarine swap'), lambda: self.main_window.run_swap_dialog())
menu.addSeparator()
menu.addAction(_("Import channel backup"), lambda: self.main_window.do_process_from_text_channel_backup())
# only enable menu if has LN. Or we could selectively enable menu items?
# and maybe add item "main_window.init_lightning_dialog()" when applicable
menu.setEnabled(self.wallet.has_lightning())
self.new_channel_button = EnterButton(_('New Channel'), self.main_window.new_channel_dialog)
self.new_channel_button.setEnabled(self.wallet.has_lightning())
toolbar.insertWidget(2, self.new_channel_button)

6
electrum/gui/qt/main_window.py

@ -1112,6 +1112,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
if not self.network:
self.show_error(_("You are offline."))
return
if not self.wallet.lnworker:
self.show_error(_('Lightning is disabled'))
return
if not self.wallet.lnworker.num_sats_can_send() and not self.wallet.lnworker.num_sats_can_receive():
self.show_error(_("You do not have liquidity in your active channels."))
return
@ -2130,6 +2133,9 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger, QtEventListener):
def import_channel_backup(self, encrypted: str):
if not self.question('Import channel backup?'):
return
if not self.wallet.lnworker:
self.show_error(_('Lightning is disabled'))
return
try:
self.wallet.lnworker.import_channel_backup(encrypted)
except Exception as e:

Loading…
Cancel
Save