From 80ef16e8538a80111e62e2d43ba2f089d71ddef6 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Thu, 1 Mar 2018 00:40:32 +0100 Subject: [PATCH] peer: hand lnwire.Error to fndgMngr or link depending on chanID --- peer.go | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/peer.go b/peer.go index a0a5cc8b..cca99733 100644 --- a/peer.go +++ b/peer.go @@ -748,7 +748,27 @@ out: } case *lnwire.Error: - p.server.fundingMgr.processFundingError(msg, p.addr) + switch { + + // In the case of an all-zero channel ID we want to + // forward the error to all channels with this peer. + case msg.ChanID == lnwire.ConnectionWideID: + for _, chanStream := range chanMsgStreams { + chanStream.AddMsg(nextMsg) + } + + // If the channel ID for the error message corresponds + // to a pending channel, then the funding manager will + // handle the error. + case p.server.fundingMgr.IsPendingChannel(msg.ChanID, p.addr): + p.server.fundingMgr.processFundingError(msg, p.addr) + + // If not we hand the error to the channel link for + // this channel. + default: + isChanUpdate = true + targetChan = msg.ChanID + } // TODO(roasbeef): create ChanUpdater interface for the below case *lnwire.UpdateAddHTLC: