From 7bea7515f142d17d3da4357ff491182ec9541006 Mon Sep 17 00:00:00 2001 From: ThomasV Date: Fri, 22 Jun 2018 12:52:32 +0200 Subject: [PATCH] follow-up previous commit --- lib/lnbase.py | 3 ++- lib/lnworker.py | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/lnbase.py b/lib/lnbase.py index fd1b8b1c..2d73c8c0 100644 --- a/lib/lnbase.py +++ b/lib/lnbase.py @@ -928,7 +928,8 @@ class Peer(PrintError): assert success, success return chan._replace(remote_state=chan.remote_state._replace(ctn=0),local_state=chan.local_state._replace(ctn=0, current_commitment_signature=remote_sig)) - def reestablish_channel(self, chan): + async def reestablish_channel(self, chan): + await self.initialized self.channel_state[chan.channel_id] = 'REESTABLISHING' self.network.trigger_callback('channel', chan) self.send_message(gen_msg("channel_reestablish", diff --git a/lib/lnworker.py b/lib/lnworker.py index acf8d5db..8b3e4bbd 100644 --- a/lib/lnworker.py +++ b/lib/lnworker.py @@ -157,9 +157,10 @@ class LNWorker(PrintError): outpoints = [Outpoint(x["tx_hash"], x["tx_pos"]) for x in utxos] if chan.funding_outpoint not in outpoints: self.channel_state[chan.channel_id] = "CLOSED" - elif chan.channel_id not in self.channel_state: + elif self.channel_state[chan.channel_id] == 'DISCONNECTED': peer = self.peers[chan.node_id] - peer.reestablish_channel(c) + coro = peer.reestablish_channel(chan) + asyncio.run_coroutine_threadsafe(coro, self.network.asyncio_loop) def on_network_update(self, event, *args): for chan in self.channels.values():