htlcswitch: bounce downstream adds when flushing

This commit is contained in:
Keagan McClelland 2023-11-26 13:45:55 -08:00
parent 5ab69aedc7
commit a9d5235c62

View file

@ -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.