From 79a890fa487a891577fd4154073c464b88634036 Mon Sep 17 00:00:00 2001 From: carla Date: Wed, 19 Feb 2020 17:34:47 +0200 Subject: [PATCH] htlcswitch: notify outgoing link failures for local sends Notify link failures for our own payments. Separate handling code is required for local payment link failures because we do not pass these failures back through the switch (like we do for link failures for forwards), but rather send them straight back to the router. Our own sends have the payment ID saved in the incoming htlc ID of the packet's incoming circuit. This change replaces that value with for the sake of consistent notifying of sends and receives from our node. --- htlcswitch/switch.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index 84e5aa15..a30eb584 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -770,6 +770,20 @@ func (s *Switch) handleLocalDispatch(pkt *htlcPacket) error { if htlc, ok := pkt.htlc.(*lnwire.UpdateAddHTLC); ok { link, err := s.handleLocalAddHTLC(pkt, htlc) if err != nil { + // Notify the htlc notifier of a link failure on our + // outgoing link. Incoming timelock/amount values are + // not set because they are not present for local sends. + s.cfg.HtlcNotifier.NotifyLinkFailEvent( + newHtlcKey(pkt), + HtlcInfo{ + OutgoingTimeLock: htlc.Expiry, + OutgoingAmt: htlc.Amount, + }, + HtlcEventTypeSend, + err, + false, + ) + return err }