Browse Source

Qt: test if lightinng is running

hard-fail-on-bad-server-string
ThomasV 5 years ago
parent
commit
0d160cceea
  1. 2
      electrum/gui/qt/__init__.py
  2. 3
      electrum/gui/qt/channels_list.py
  3. 2
      electrum/gui/qt/main_window.py
  4. 3
      electrum/network.py

2
electrum/gui/qt/__init__.py

@ -206,6 +206,8 @@ class ElectrumGui(Logger):
self.app.new_window_signal.emit(path, uri) self.app.new_window_signal.emit(path, uri)
def show_lightning_dialog(self): def show_lightning_dialog(self):
if not self.daemon.network.is_lightning_running():
return
if not self.lightning_dialog: if not self.lightning_dialog:
self.lightning_dialog = LightningDialog(self) self.lightning_dialog = LightningDialog(self)
self.lightning_dialog.bring_to_top() self.lightning_dialog.bring_to_top()

3
electrum/gui/qt/channels_list.py

@ -66,8 +66,11 @@ class ChannelsList(MyTreeView):
labels[subject] = label labels[subject] = label
status = self.lnworker.get_channel_status(chan) status = self.lnworker.get_channel_status(chan)
closed = chan.is_closed() closed = chan.is_closed()
if self.parent.network.is_lightning_running():
node_info = self.lnworker.channel_db.get_node_info_for_node_id(chan.node_id) node_info = self.lnworker.channel_db.get_node_info_for_node_id(chan.node_id)
node_alias = (node_info.alias if node_info else '') or '' node_alias = (node_info.alias if node_info else '') or ''
else:
node_alias = ''
return [ return [
format_short_channel_id(chan.short_channel_id), format_short_channel_id(chan.short_channel_id),
bh2u(chan.node_id), bh2u(chan.node_id),

2
electrum/gui/qt/main_window.py

@ -2076,6 +2076,8 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, Logger):
def update_lightning_icon(self): def update_lightning_icon(self):
if self.lightning_button is None: if self.lightning_button is None:
return return
if not self.network.is_lightning_running():
return
cur, total = self.network.lngossip.get_sync_progress_estimate() cur, total = self.network.lngossip.get_sync_progress_estimate()
# self.logger.debug(f"updating lngossip sync progress estimate: cur={cur}, total={total}") # self.logger.debug(f"updating lngossip sync progress estimate: cur={cur}, total={total}")
progress_percent = 0 progress_percent = 0

3
electrum/network.py

@ -322,6 +322,9 @@ class Network(Logger):
self.local_watchtower.start_network(self) self.local_watchtower.start_network(self)
asyncio.ensure_future(self.local_watchtower.start_watching()) asyncio.ensure_future(self.local_watchtower.start_watching())
def is_lightning_running(self):
return self.channel_db is not None
def maybe_init_lightning(self): def maybe_init_lightning(self):
if self.channel_db is None: if self.channel_db is None:
from . import lnworker from . import lnworker

Loading…
Cancel
Save