From 2d24ac150a9b5bed5941e151833e9f9a2ee1b7b7 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 24 Sep 2018 16:38:59 +0200 Subject: [PATCH] fix lnwatcher: network triggers were renamed --- electrum/interface.py | 2 +- electrum/lnwatcher.py | 6 +++++- electrum/lnworker.py | 5 +++-- electrum/verifier.py | 1 - 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/electrum/interface.py b/electrum/interface.py index 1b8511dc9..e0685adb3 100644 --- a/electrum/interface.py +++ b/electrum/interface.py @@ -161,7 +161,7 @@ class Interface(PrintError): self.group = SilentTaskGroup() def diagnostic_name(self): - return self.host + return 'iface:{}'.format(self.host) def _set_proxy(self, proxy: dict): if proxy: diff --git a/electrum/lnwatcher.py b/electrum/lnwatcher.py index 631f7e562..18dfb5761 100644 --- a/electrum/lnwatcher.py +++ b/electrum/lnwatcher.py @@ -93,7 +93,7 @@ class LNWatcher(PrintError): e_tx2 = EncumberedTransaction.from_json(e_tx) self.sweepstore[funding_outpoint][ctx_txid].add(e_tx2) - self.network.register_callback(self.on_network_update, ['updated']) + self.network.register_callback(self.on_network_update, ['network_updated', 'blockchain_updated', 'verified']) def write_to_disk(self): # FIXME: json => every update takes linear instead of constant disk write @@ -128,6 +128,10 @@ class LNWatcher(PrintError): @aiosafe async def on_network_update(self, event, *args): + if event == 'verified': + wallet = args[0] + if wallet != self.addr_sync: + return if not self.addr_sync.synchronizer: self.print_error("synchronizer not set yet") return diff --git a/electrum/lnworker.py b/electrum/lnworker.py index 839d8b4ae..90a0cbb36 100644 --- a/electrum/lnworker.py +++ b/electrum/lnworker.py @@ -57,7 +57,7 @@ class LNWorker(PrintError): self._last_tried_peer = {} # LNPeerAddr -> unix timestamp self._add_peers_from_config() # wait until we see confirmations - self.network.register_callback(self.on_network_update, ['updated', 'verified', 'fee']) # thread safe + self.network.register_callback(self.on_network_update, ['network_updated', 'verified', 'fee']) # thread safe asyncio.run_coroutine_threadsafe(self.network.main_taskgroup.spawn(self.main_loop()), self.network.asyncio_loop) def _add_peers_from_config(self): @@ -346,7 +346,8 @@ class LNWorker(PrintError): asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop) async def main_loop(self): - await self.on_network_update('updated') # shortcut (don't block) if funding tx locked and verified + await self.on_network_update('network_updated') # shortcut (don't block) if funding tx locked and verified + await self.network.lnwatcher.on_network_update('network_updated') # ping watcher to check our channels while True: await asyncio.sleep(1) now = time.time() diff --git a/electrum/verifier.py b/electrum/verifier.py index e1229137d..27913ce13 100644 --- a/electrum/verifier.py +++ b/electrum/verifier.py @@ -127,7 +127,6 @@ class SPV(NetworkJobOnDefaultServer): vtx_info = VerifiedTxInfo(tx_height, header.get('timestamp'), pos, header_hash) self.wallet.add_verified_tx(tx_hash, vtx_info) if self.is_up_to_date() and self.wallet.is_up_to_date(): - self.network.trigger_callback('updated') self.wallet.save_verified_tx(write=True) @classmethod