From b1ba83bf2bc37949698b955111abf0fcd3815b82 Mon Sep 17 00:00:00 2001 From: Wilmer Paulino Date: Wed, 23 May 2018 03:09:19 -0400 Subject: [PATCH] peer: prevent processing close msg if channel is not found --- fundingmanager.go | 9 +++++---- peer.go | 11 ++++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/fundingmanager.go b/fundingmanager.go index f9269f29..b06464fb 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -442,10 +442,11 @@ var ( // of being opened. channelOpeningStateBucket = []byte("channelOpeningState") - // ErrChannelNotFound is returned when we are looking for a specific - // channel opening state in the FundingManager's internal database, but - // the channel in question is not considered being in an opening state. - ErrChannelNotFound = fmt.Errorf("channel not found in db") + // ErrChannelNotFound is an error returned when a channel is not known + // to us. In this case of the fundingManager, this error is returned + // when the channel in question is not considered being in an opening + // state. + ErrChannelNotFound = fmt.Errorf("channel not found") ) // newFundingManager creates and initializes a new instance of the diff --git a/peer.go b/peer.go index b13235f6..82b077f6 100644 --- a/peer.go +++ b/peer.go @@ -1539,7 +1539,13 @@ out: // closure process. chanCloser, err := p.fetchActiveChanCloser(closeMsg.cid) if err != nil { - peerLog.Errorf("unable to respond to remote "+ + // If the channel is not known to us, we'll + // simply ignore this message. + if err == ErrChannelNotFound { + continue + } + + peerLog.Errorf("Unable to respond to remote "+ "close msg: %v", err) errMsg := &lnwire.Error{ @@ -1617,8 +1623,7 @@ func (p *peer) fetchActiveChanCloser(chanID lnwire.ChannelID) (*channelCloser, e channel, ok := p.activeChannels[chanID] p.activeChanMtx.RUnlock() if !ok { - return nil, fmt.Errorf("unable to close channel, "+ - "ChannelID(%v) is unknown", chanID) + return nil, ErrChannelNotFound } // We'll attempt to look up the matching state machine, if we can't