Skip to content

Commit 2381151

Browse files
committed
router: add resume modified response and fields
1 parent 86db058 commit 2381151

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

router_client.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,10 @@ type InterceptedHtlc struct {
344344

345345
// OnionBlob is the onion blob for the next hop.
346346
OnionBlob []byte
347+
348+
// InWireCustomRecords are custom records sent by the sender that were
349+
// only present in the wire message and not the onion itself.
350+
InWireCustomRecords map[uint64][]byte
347351
}
348352

349353
// HtlcInterceptHandler is a function signature for handling code for htlc
@@ -367,6 +371,10 @@ const (
367371
// InterceptorActionResume indicates that an intercepted hltc should be
368372
// resumed as normal.
369373
InterceptorActionResume
374+
375+
// InterceptorActionResumeModified indicates that an intercepted hltc
376+
// should be resumed as normal, but with modifications.
377+
InterceptorActionResumeModified
370378
)
371379

372380
// InterceptedHtlcResponse contains the actions that must be taken for an
@@ -379,6 +387,19 @@ type InterceptedHtlcResponse struct {
379387
// Action is the action that should be taken for the htlc that is
380388
// intercepted.
381389
Action InterceptorAction
390+
391+
// IncomingAmount is the amount that should be used to validate the
392+
// incoming htlc. This might be different from the actual HTLC amount
393+
// for custom channels.
394+
IncomingAmount lnwire.MilliSatoshi
395+
396+
// OutgoingAmount is the amount that should be set on the HTLC that is
397+
// forwarded.
398+
OutgoingAmount lnwire.MilliSatoshi
399+
400+
// CustomRecords are the custom records that should be added to the
401+
// outgoing/forwarded HTLC.
402+
CustomRecords map[uint64][]byte
382403
}
383404

384405
// routerClient is a wrapper around the generated routerrpc proxy.
@@ -798,6 +819,7 @@ func (r *routerClient) InterceptHtlcs(ctx context.Context,
798819
chanOut := lnwire.NewShortChanIDFromInt(
799820
request.OutgoingRequestedChanId,
800821
)
822+
inWireCustomRecords := request.InWireCustomRecords
801823

802824
req := InterceptedHtlc{
803825
IncomingCircuitKey: invpkg.CircuitKey{
@@ -816,6 +838,7 @@ func (r *routerClient) InterceptHtlcs(ctx context.Context,
816838
OutgoingChannelID: chanOut,
817839
CustomRecords: request.CustomRecords,
818840
OnionBlob: request.OnionBlob,
841+
InWireCustomRecords: inWireCustomRecords,
819842
}
820843

821844
// Try to send our interception request, failing on
@@ -915,6 +938,14 @@ func rpcInterceptorResponse(request InterceptedHtlc,
915938
case InterceptorActionResume:
916939
rpcResp.Action = routerrpc.ResolveHoldForwardAction_RESUME
917940

941+
case InterceptorActionResumeModified:
942+
//nolint:lll
943+
rpcResp.Action = routerrpc.ResolveHoldForwardAction_RESUME_MODIFIED
944+
945+
rpcResp.InAmountMsat = uint64(response.IncomingAmount)
946+
rpcResp.OutAmountMsat = uint64(response.OutgoingAmount)
947+
rpcResp.OutWireCustomRecords = response.CustomRecords
948+
918949
default:
919950
return nil, fmt.Errorf("unknown action: %v", response.Action)
920951
}

0 commit comments

Comments
 (0)