From e14485d66c396433ee077aa1983b2f6fab8f03c8 Mon Sep 17 00:00:00 2001
From: ThomasV <thomasv@electrum.org>
Date: Sat, 2 Feb 2019 17:00:03 +0100
Subject: [PATCH] set short_channel_id regardless of channel state, because
 peer might be disconnected

---
 electrum/lnworker.py | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/electrum/lnworker.py b/electrum/lnworker.py
index 77640770b..c56662338 100644
--- a/electrum/lnworker.py
+++ b/electrum/lnworker.py
@@ -274,7 +274,6 @@ class LNWorker(PrintError):
         if it's also deep enough, also save to disk.
         Returns tuple (mined_deep_enough, num_confirmations).
         """
-        assert chan.get_state() in ["OPEN", "OPENING"]
         lnwatcher = self.network.lnwatcher
         conf = lnwatcher.get_tx_height(chan.funding_outpoint.txid).conf
         if conf > 0:
@@ -285,8 +284,8 @@ class LNWorker(PrintError):
             chan.short_channel_id = chan.short_channel_id_predicted
             self.save_channel(chan)
             self.on_channels_updated()
-            return True, conf
-        return False, conf
+        else:
+            self.print_error("funding tx is still not at sufficient depth. actual depth: " + str(conf))
 
     def channel_by_txo(self, txo):
         with self.lock:
@@ -373,12 +372,9 @@ class LNWorker(PrintError):
             if args[0] != lnwatcher:
                 return
         for chan in channels:
-            if chan.get_state() == "OPENING":
-                res, depth = self.save_short_chan_id(chan)
-                if not res:
-                    self.print_error("network update but funding tx is still not at sufficient depth. actual depth: " + str(depth))
-                    continue
-                # this results in the channel being marked OPEN
+            if chan.short_channel_id is None:
+                self.save_short_chan_id(chan)
+            if chan.get_state() == "OPENING" and chan.short_channel_id:
                 peer = self.peers[chan.node_id]
                 peer.send_funding_locked(chan)
             elif chan.get_state() == "OPEN":