The HTLC Interceptor is a service in LND that allows you to inspect, approve, deny or settle all HTLCs passing through your node. HTLCs terminating at this node, meaning payments made to the node, are not affected. Once the HTLC interceptor is registered, LND will forward information about every passing HTLC to the interceptor, which can reply with either Settle, Fail or Resume.
The HTLC Interceptor can be used in many ways. For instance, it is useful in a high-performance cluster of multiple LND nodes, where multiple LND instances are used to generate invoices, but only one node is used to receive the payments.
In such an arrangement the invoicing virtual nodes, each with their own public key but without public channels, would include a hop hint from the settlement node into their invoices. The interceptor would resume all HTLCs not passing through to the invoicing nodes, and settle HTLCs by providing the preimage obtained from the invoicing nodes.
When failing HTLCs, the interceptor may respond with the appropriate error message, as if it were the recipient of the HTLC.
// InterceptedHtlc contains information about a htlc that was intercepted in// lnd's switch.typeInterceptedHtlcstruct {// IncomingCircuitKey is lnd's unique identfier for the incoming htlc. IncomingCircuitKey invpkg.CircuitKey// Hash is the payment hash for the htlc. This may not be unique for// MPP htlcs. Hash lntypes.Hash// AmountInMsat is the incoming htlc amount. AmountInMsat lnwire.MilliSatoshi// AmountOutMsat is the outgoing htlc amount. AmountOutMsat lnwire.MilliSatoshi// IncomingExpiryHeight is the expiry height of the incoming htlc. IncomingExpiryHeight uint32// OutgoingExpiryHeight is the expiry height of the outgoing htlcs. OutgoingExpiryHeight uint32// OutgoingChannelID is the outgoing channel id proposed by the sender.// Since lnd has non-strict forwarding, this may not be the channel that// the htlc ends up being forwarded on. OutgoingChannelID lnwire.ShortChannelID// CustomRecords holds the custom TLV records that were added to the// payment. CustomRecords map[uint64][]byte// OnionBlob is the onion blob for the next hop. OnionBlob []byte}// HtlcInterceptHandler is a function signature for handling code for htlc// interception.typeHtlcInterceptHandlerfunc(context.Context, InterceptedHtlc) (*InterceptedHtlcResponse, error)// InterceptorAction represents the different actions we can take for an// intercepted htlc.typeInterceptorActionuint8const (// InterceptorActionSettle indicates that an intercepted htlc should// be settled. InterceptorActionSettle InterceptorAction=iota// InterceptorActionFail indicates that an intercepted htlc should be// failed. InterceptorActionFail// InterceptorActionResume indicates that an intercepted hltc should be// resumed as normal. InterceptorActionResume)// InterceptedHtlcResponse contains the actions that must be taken for an// intercepted htlc.typeInterceptedHtlcResponsestruct {// Preimage is the preimage to settle a htlc with, this value must be// set if the interceptor action is to settle. Preimage *lntypes.Preimage// Action is the action that should be taken for the htlc that is// intercepted. Action InterceptorAction}