From 22d370aa5155b5dba43eeaf1a9818c40724147dd Mon Sep 17 00:00:00 2001 From: carla Date: Wed, 19 Feb 2020 17:34:47 +0200 Subject: [PATCH] htlcswitch: notify send forward failures and settles Add notifications for local initiated sends settles and forwarding failures. As with link failures, local send settles and forwarding failures are reported directly to the router so must have their own notification handling. --- htlcswitch/switch.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/htlcswitch/switch.go b/htlcswitch/switch.go index a30eb5846..602dc55b0 100644 --- a/htlcswitch/switch.go +++ b/htlcswitch/switch.go @@ -898,6 +898,18 @@ func (s *Switch) handleLocalResponse(pkt *htlcPacket) { pkt.inKey(), err) return } + + // Finally, notify on the htlc failure or success that has been handled. + key := newHtlcKey(pkt) + eventType := getEventType(pkt) + + switch pkt.htlc.(type) { + case *lnwire.UpdateFulfillHTLC: + s.cfg.HtlcNotifier.NotifySettleEvent(key, eventType) + + case *lnwire.UpdateFailHTLC: + s.cfg.HtlcNotifier.NotifyForwardingFailEvent(key, eventType) + } } // extractResult uses the given deobfuscator to extract the payment result from