@@ -337,6 +337,10 @@ type InterceptedHtlc struct {
337337
338338 // OnionBlob is the onion blob for the next hop.
339339 OnionBlob []byte
340+
341+ // InWireCustomRecords are custom records sent by the sender that were
342+ // only present in the wire message and not the onion itself.
343+ InWireCustomRecords map [uint64 ][]byte
340344}
341345
342346// HtlcInterceptHandler is a function signature for handling code for htlc
@@ -360,6 +364,10 @@ const (
360364 // InterceptorActionResume indicates that an intercepted hltc should be
361365 // resumed as normal.
362366 InterceptorActionResume
367+
368+ // InterceptorActionResumeModified indicates that an intercepted hltc
369+ // should be resumed as normal, but with modifications.
370+ InterceptorActionResumeModified
363371)
364372
365373// InterceptedHtlcResponse contains the actions that must be taken for an
@@ -372,6 +380,19 @@ type InterceptedHtlcResponse struct {
372380 // Action is the action that should be taken for the htlc that is
373381 // intercepted.
374382 Action InterceptorAction
383+
384+ // IncomingAmount is the amount that should be used to validate the
385+ // incoming htlc. This might be different from the actual HTLC amount
386+ // for custom channels.
387+ IncomingAmount lnwire.MilliSatoshi
388+
389+ // OutgoingAmount is the amount that should be set on the HTLC that is
390+ // forwarded.
391+ OutgoingAmount lnwire.MilliSatoshi
392+
393+ // CustomRecords are the custom records that should be added to the
394+ // outgoing/forwarded HTLC.
395+ CustomRecords map [uint64 ][]byte
375396}
376397
377398// routerClient is a wrapper around the generated routerrpc proxy.
@@ -790,6 +811,7 @@ func (r *routerClient) InterceptHtlcs(ctx context.Context,
790811 chanOut := lnwire .NewShortChanIDFromInt (
791812 request .OutgoingRequestedChanId ,
792813 )
814+ inWireCustomRecords := request .InWireCustomRecords
793815
794816 req := InterceptedHtlc {
795817 IncomingCircuitKey : invpkg.CircuitKey {
@@ -808,6 +830,7 @@ func (r *routerClient) InterceptHtlcs(ctx context.Context,
808830 OutgoingChannelID : chanOut ,
809831 CustomRecords : request .CustomRecords ,
810832 OnionBlob : request .OnionBlob ,
833+ InWireCustomRecords : inWireCustomRecords ,
811834 }
812835
813836 // Try to send our interception request, failing on
@@ -907,6 +930,14 @@ func rpcInterceptorResponse(request InterceptedHtlc,
907930 case InterceptorActionResume :
908931 rpcResp .Action = routerrpc .ResolveHoldForwardAction_RESUME
909932
933+ case InterceptorActionResumeModified :
934+ //nolint:lll
935+ rpcResp .Action = routerrpc .ResolveHoldForwardAction_RESUME_MODIFIED
936+
937+ rpcResp .InAmountMsat = uint64 (response .IncomingAmount )
938+ rpcResp .OutAmountMsat = uint64 (response .OutgoingAmount )
939+ rpcResp .OutWireCustomRecords = response .CustomRecords
940+
910941 default :
911942 return nil , fmt .Errorf ("unknown action: %v" , response .Action )
912943 }
0 commit comments