URI: 
       tfix lnwatcher: network triggers were renamed - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit c91fe27e7da79eccaad4db7638ec1e987def3428
   DIR parent d29191b010d3174679ca90ee59c3c850e2bc6096
  HTML Author: SomberNight <somber.night@protonmail.com>
       Date:   Mon, 24 Sep 2018 16:38:59 +0200
       
       fix lnwatcher: network triggers were renamed
       
       Diffstat:
         M electrum/lnwatcher.py               |       6 +++++-
         M electrum/lnworker.py                |       5 +++--
         M electrum/verifier.py                |       4 ++--
       
       3 files changed, 10 insertions(+), 5 deletions(-)
       ---
   DIR diff --git a/electrum/lnwatcher.py b/electrum/lnwatcher.py
       t@@ -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
       t@@ -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
   DIR diff --git a/electrum/lnworker.py b/electrum/lnworker.py
       t@@ -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):
       t@@ -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()
   DIR diff --git a/electrum/verifier.py b/electrum/verifier.py
       t@@ -133,8 +133,8 @@ class SPV(NetworkJobOnDefaultServer):
                                      txpos=pos,
                                      header_hash=header_hash)
                self.wallet.add_verified_tx(tx_hash, tx_info)
       -        #if self.is_up_to_date() and self.wallet.is_up_to_date():
       -        #    self.wallet.save_verified_tx(write=True)
       +        if self.is_up_to_date() and self.wallet.is_up_to_date():
       +            self.wallet.save_verified_tx(write=True)
        
            @classmethod
            def hash_merkle_root(cls, merkle_branch: Sequence[str], tx_hash: str, leaf_pos_in_tree: int):