From 12fac3a167d4d14c0791504d65c3220622bca81f Mon Sep 17 00:00:00 2001 From: SomberNight Date: Tue, 13 Apr 2021 19:05:07 +0200 Subject: [PATCH] fix running with --offline --- electrum/gui/kivy/main_window.py | 11 ++++++----- electrum/gui/kivy/uix/dialogs/lightning_channels.py | 8 +++++--- electrum/lnworker.py | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/electrum/gui/kivy/main_window.py b/electrum/gui/kivy/main_window.py index ae4188f34..707d40775 100644 --- a/electrum/gui/kivy/main_window.py +++ b/electrum/gui/kivy/main_window.py @@ -188,11 +188,12 @@ class ElectrumWindow(App, Logger): use_gossip = BooleanProperty(False) def on_use_gossip(self, instance, x): self.electrum_config.set_key('use_gossip', self.use_gossip, True) - if self.use_gossip: - self.network.start_gossip() - else: - self.network.run_from_another_thread( - self.network.stop_gossip()) + if self.network: + if self.use_gossip: + self.network.start_gossip() + else: + self.network.run_from_another_thread( + self.network.stop_gossip()) use_change = BooleanProperty(False) def on_use_change(self, instance, x): diff --git a/electrum/gui/kivy/uix/dialogs/lightning_channels.py b/electrum/gui/kivy/uix/dialogs/lightning_channels.py index 01e0bcb5b..7395c3866 100644 --- a/electrum/gui/kivy/uix/dialogs/lightning_channels.py +++ b/electrum/gui/kivy/uix/dialogs/lightning_channels.py @@ -172,6 +172,7 @@ Builder.load_string(r''' : name: 'lightning_channels' title: _('Lightning Network') + has_network: False has_lightning: False has_gossip: False can_send: '' @@ -205,13 +206,13 @@ Builder.load_string(r''' size_hint: 0.3, None height: '48dp' text: _('Open Channel') - disabled: not root.has_lightning + disabled: not (root.has_network and root.has_lightning) on_release: popup.app.popup_dialog('lightning_open_channel_dialog') Button: size_hint: 0.3, None height: '48dp' text: _('Swap') - disabled: not root.has_lightning + disabled: not (root.has_network and root.has_lightning) on_release: popup.app.popup_dialog('swap_dialog') Button: size_hint: 0.3, None @@ -589,8 +590,9 @@ class LightningChannelsDialog(Factory.Popup): super(LightningChannelsDialog, self).__init__() self.clocks = [] self.app = app + self.has_network = bool(self.app.network) self.has_lightning = app.wallet.has_lightning() - self.has_gossip = self.app.network.channel_db is not None + self.has_gossip = self.has_network and self.app.network.channel_db is not None self.update() def show_item(self, obj): diff --git a/electrum/lnworker.py b/electrum/lnworker.py index cd0f8983a..889434c9c 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -845,6 +845,8 @@ class LNWallet(LNWorker): item = chan.get_funding_height() if item is None: continue + if not self.lnwatcher: + continue # lnwatcher not available with --offline (its data is not persisted) funding_txid, funding_height, funding_timestamp = item tx_height = self.lnwatcher.get_tx_height(funding_txid) item = {