From 171c997fe0e3fc53d165cfa40c9312a967b3e07f Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Mon, 2 Oct 2017 16:30:17 -0700 Subject: [PATCH] peer: within loadActiveChannels, skip channel if FundingLocked not processed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit fixes a bug to wrap up the recently merged PR to properly handle duplicate FundingLocked retransmissions and also ensure that we reliably re-send the FundingLocked message if we’re unable to the first time around. In this commit, we skip processing a channel that does not yet have a set remote revocation as otherwise, if we attempt to trigger a state update, then we’ll be attempting to manipulate a nil commitment point. Therefore, we’ll rely on the fundingManager to properly send the channel all relevant subsystems. --- peer.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/peer.go b/peer.go index c6dbc0c6f..bb3a4ad5c 100644 --- a/peer.go +++ b/peer.go @@ -292,6 +292,18 @@ func (p *peer) loadActiveChannels(chans []*channeldb.OpenChannel) error { } chanPoint := &dbChan.FundingOutpoint + + // If the channel we read form disk has a nil next revocation + // key, then we'll skip loading this channel. We must do this + // as it doesn't yet have the needed items required to initiate + // a local state transition, or one triggered by forwarding an + // HTLC. + if lnChan.RemoteNextRevocation() == nil { + peerLog.Debugf("Skipping ChannelPoint(%v), lacking "+ + "next commit point", chanPoint) + continue + } + chanID := lnwire.NewChanIDFromOutPoint(chanPoint) p.activeChanMtx.Lock()