From eba6ba0760384722895a169a4e995c401d93a9ff Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Tue, 16 Jan 2018 18:54:41 -0800 Subject: [PATCH] routing: properly prune edges that return a FailPermanentChannelFailure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In this commit, we now account for a case where a node sends us a FailPermanentChannelFailure during a payment attempt. Before this commit, we wouldn’t properly prune the edge to avoid re-using it. We remedy this by properly attempting to prune the edge if possible. Future changes well send a FailPermanentChannelFailure in the case that we ned to go on-chain for an outgoing HTLC, and cancel back the incoming HTLC. --- routing/router.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/routing/router.go b/routing/router.go index 8ffebc84..baa653cf 100644 --- a/routing/router.go +++ b/routing/router.go @@ -1735,8 +1735,31 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route // we'll note this (exclude the vertex/edge), and // continue with the rest of the routes. case *lnwire.FailPermanentChannelFailure: - // TODO(roasbeef): remove channel from path + // As this error indicates that the target + // channel was unable to carry this HTLC (for + // w/e reason), we'll query the index to find + // the _outgoign_ channel the source of the + // error was meant to pass the HTLC along to. + badChan, ok := route.nextHopChannel(errSource) + if !ok { + // If we weren't able to find the hop + // *after* this node, then we'll + // attempt to disable the previous + // channel. + badChan, ok = route.prevHopChannel( + errSource, + ) + if !ok { + continue + } + } + + // If the channel was found, then we'll inform + // mission control of this failure so future + // attempts avoid this link temporarily. + paySession.ReportChannelFailure(badChan.ChannelID) continue + case *lnwire.FailPermanentNodeFailure: // TODO(rosabeef): remove node from path continue