1
0

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

closes https://github.com/spesmilo/electrum/issues/8321
This commit is contained in:
SomberNight
2023-04-20 15:06:37 +00:00
parent fa04ff005b
commit 22205dccb1
2 changed files with 9 additions and 0 deletions

View File

@@ -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)

View File

@@ -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: