From a9d5235c628fc6e5594b8c34fe2a375db103b7a2 Mon Sep 17 00:00:00 2001 From: Keagan McClelland Date: Sun, 26 Nov 2023 13:45:55 -0800 Subject: [PATCH] htlcswitch: bounce downstream adds when flushing --- htlcswitch/link.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 8ef618b02..76293fd7a 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -1457,6 +1457,17 @@ func (l *channelLink) handleDownstreamUpdateAdd(pkt *htlcPacket) error { return errors.New("not an UpdateAddHTLC packet") } + // If we are flushing the link in the outgoing direction we can't add + // new htlcs to the link and we need to bounce it + if l.IsFlushing(Outgoing) { + l.mailBox.FailAdd(pkt) + + return NewDetailedLinkError( + &lnwire.FailPermanentChannelFailure{}, + OutgoingFailureLinkNotEligible, + ) + } + // If hodl.AddOutgoing mode is active, we exit early to simulate // arbitrary delays between the switch adding an ADD to the // mailbox, and the HTLC being added to the commitment state.