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.
This commit is contained in:
carla 2020-02-19 17:34:47 +02:00
parent 937062b6d3
commit 79a890fa48
No known key found for this signature in database
GPG Key ID: 4CA7FE54A6213C91

@ -770,6 +770,20 @@ func (s *Switch) handleLocalDispatch(pkt *htlcPacket) error {
if htlc, ok := pkt.htlc.(*lnwire.UpdateAddHTLC); ok { if htlc, ok := pkt.htlc.(*lnwire.UpdateAddHTLC); ok {
link, err := s.handleLocalAddHTLC(pkt, htlc) link, err := s.handleLocalAddHTLC(pkt, htlc)
if err != nil { 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 return err
} }