fix running with --offline

This commit is contained in:
SomberNight
2021-04-13 19:05:07 +02:00
parent 4e91555d56
commit 12fac3a167
3 changed files with 13 additions and 8 deletions

View File

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

View File

@@ -172,6 +172,7 @@ Builder.load_string(r'''
<LightningChannelsDialog@Popup>:
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):

View File

@@ -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 = {