Browse Source

fix lnwatcher: network triggers were renamed

regtest_lnd
SomberNight 6 years ago
parent
commit
b0a1cade2d
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 6
      electrum/lnwatcher.py
  2. 5
      electrum/lnworker.py
  3. 4
      electrum/verifier.py

6
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

5
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()

4
electrum/verifier.py

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

Loading…
Cancel
Save