lnrpc: add wire records fields to payment+interceptor RPCs
This commit is contained in:
1 parent
878f964a33
commit
42e358e3d3
9 files changed
+902
-681
No files matched your search
@@ -92,6 +92,7 @@ func (r *forwardInterceptor) onIntercept(
|
||||
CustomRecords: htlc.InOnionCustomRecords,
|
||||
OnionBlob: htlc.OnionBlob[:],
|
||||
AutoFailHeight: htlc.AutoFailHeight,
|
||||
InWireCustomRecords: htlc.InWireCustomRecords,
|
||||
}
|
||||
|
||||
return r.stream.Send(interceptionRequest)
|
||||
|
||||
+755
-652
File diff suppressed because it is too large.
Load diff
@@ -358,6 +358,15 @@ message SendPaymentRequest {
|
||||
being sent.
|
||||
*/
|
||||
bool cancelable = 24;
|
||||
|
||||
/*
|
||||
An optional field that can be used to pass an arbitrary set of TLV records
|
||||
to the first hop peer of this payment. This can be used to pass application
|
||||
specific data during the payment attempt. Record types are required to be in
|
||||
the custom range >= 65536. When using REST, the values must be encoded as
|
||||
base64.
|
||||
*/
|
||||
map<uint64, bytes> first_hop_custom_records = 25;
|
||||
}
|
||||
|
||||
message TrackPaymentRequest {
|
||||
@@ -451,6 +460,15 @@ message SendToRouteRequest {
|
||||
routes, incorrect payment details, or insufficient funds.
|
||||
*/
|
||||
bool skip_temp_err = 3;
|
||||
|
||||
/*
|
||||
An optional field that can be used to pass an arbitrary set of TLV records
|
||||
to the first hop peer of this payment. This can be used to pass application
|
||||
specific data during the payment attempt. Record types are required to be in
|
||||
the custom range >= 65536. When using REST, the values must be encoded as
|
||||
base64.
|
||||
*/
|
||||
map<uint64, bytes> first_hop_custom_records = 4;
|
||||
}
|
||||
|
||||
message SendToRouteResponse {
|
||||
@@ -726,6 +744,15 @@ message BuildRouteRequest {
|
||||
This is also called payment secret in specifications (e.g. BOLT 11).
|
||||
*/
|
||||
bytes payment_addr = 5;
|
||||
|
||||
/*
|
||||
An optional field that can be used to pass an arbitrary set of TLV records
|
||||
to the first hop peer of this payment. This can be used to pass application
|
||||
specific data during the payment attempt. Record types are required to be in
|
||||
the custom range >= 65536. When using REST, the values must be encoded as
|
||||
base64.
|
||||
*/
|
||||
map<uint64, bytes> first_hop_custom_records = 6;
|
||||
}
|
||||
|
||||
message BuildRouteResponse {
|
||||
@@ -982,6 +1009,9 @@ message ForwardHtlcInterceptRequest {
|
||||
// The block height at which this htlc will be auto-failed to prevent the
|
||||
// channel from force-closing.
|
||||
int32 auto_fail_height = 10;
|
||||
|
||||
// The custom records of the peer's incoming p2p wire message.
|
||||
map<uint64, bytes> in_wire_custom_records = 11;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1283,6 +1283,14 @@
|
||||
"type": "string",
|
||||
"format": "byte",
|
||||
"description": "An optional payment addr to be included within the last hop of the route.\nThis is also called payment secret in specifications (e.g. BOLT 11)."
|
||||
},
|
||||
"first_hop_custom_records": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
},
|
||||
"description": "An optional field that can be used to pass an arbitrary set of TLV records\nto the first hop peer of this payment. This can be used to pass application\nspecific data during the payment attempt. Record types are required to be in\nthe custom range \u003e= 65536. When using REST, the values must be encoded as\nbase64."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1447,6 +1455,14 @@
|
||||
"type": "integer",
|
||||
"format": "int32",
|
||||
"description": "The block height at which this htlc will be auto-failed to prevent the\nchannel from force-closing."
|
||||
},
|
||||
"in_wire_custom_records": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
},
|
||||
"description": "The custom records of the peer's incoming p2p wire message."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1957,6 +1973,14 @@
|
||||
"cancelable": {
|
||||
"type": "boolean",
|
||||
"description": "If set, the payment loop can be interrupted by manually canceling the\npayment context, even before the payment timeout is reached. Note that the\npayment may still succeed after cancellation, as in-flight attempts can\nstill settle afterwards. Canceling will only prevent further attempts from\nbeing sent."
|
||||
},
|
||||
"first_hop_custom_records": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
},
|
||||
"description": "An optional field that can be used to pass an arbitrary set of TLV records\nto the first hop peer of this payment. This can be used to pass application\nspecific data during the payment attempt. Record types are required to be in\nthe custom range \u003e= 65536. When using REST, the values must be encoded as\nbase64."
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1975,6 +1999,14 @@
|
||||
"skip_temp_err": {
|
||||
"type": "boolean",
|
||||
"description": "Whether the payment should be marked as failed when a temporary error is\nreturned from the given route. Set it to true so the payment won't be\nfailed unless a terminal error is occurred, such as payment timeout, no\nroutes, incorrect payment details, or insufficient funds."
|
||||
},
|
||||
"first_hop_custom_records": {
|
||||
"type": "object",
|
||||
"additionalProperties": {
|
||||
"type": "string",
|
||||
"format": "byte"
|
||||
},
|
||||
"description": "An optional field that can be used to pass an arbitrary set of TLV records\nto the first hop peer of this payment. This can be used to pass application\nspecific data during the payment attempt. Record types are required to be in\nthe custom range \u003e= 65536. When using REST, the values must be encoded as\nbase64."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -858,6 +858,12 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
}
|
||||
payIntent.DestCustomRecords = customRecords
|
||||
|
||||
firstHopRecords := lnwire.CustomRecords(rpcPayReq.FirstHopCustomRecords)
|
||||
if err := firstHopRecords.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
payIntent.FirstHopCustomRecords = firstHopRecords
|
||||
|
||||
payIntent.PayAttemptTimeout = time.Second *
|
||||
time.Duration(rpcPayReq.TimeoutSeconds)
|
||||
|
||||
|
||||
@@ -864,6 +864,11 @@ func (s *Server) SendToRouteV2(ctx context.Context,
|
||||
return nil, err
|
||||
}
|
||||
|
||||
firstHopRecords := lnwire.CustomRecords(req.FirstHopCustomRecords)
|
||||
if err := firstHopRecords.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var attempt *channeldb.HTLCAttempt
|
||||
|
||||
// Pass route to the router. This call returns the full htlc attempt
|
||||
@@ -873,9 +878,13 @@ func (s *Server) SendToRouteV2(ctx context.Context,
|
||||
// case, we give precedence to the attempt information as stored in the
|
||||
// db.
|
||||
if req.SkipTempErr {
|
||||
attempt, err = s.cfg.Router.SendToRouteSkipTempErr(hash, route)
|
||||
attempt, err = s.cfg.Router.SendToRouteSkipTempErr(
|
||||
hash, route, firstHopRecords,
|
||||
)
|
||||
} else {
|
||||
attempt, err = s.cfg.Router.SendToRoute(hash, route)
|
||||
attempt, err = s.cfg.Router.SendToRoute(
|
||||
hash, route, firstHopRecords,
|
||||
)
|
||||
}
|
||||
if attempt != nil {
|
||||
rpcAttempt, err := s.cfg.RouterBackend.MarshalHTLCAttempt(
|
||||
@@ -1458,9 +1467,26 @@ func (s *Server) BuildRoute(_ context.Context,
|
||||
)
|
||||
}
|
||||
|
||||
var firstHopBlob fn.Option[[]byte]
|
||||
if len(req.FirstHopCustomRecords) > 0 {
|
||||
firstHopRecords := lnwire.CustomRecords(
|
||||
req.FirstHopCustomRecords,
|
||||
)
|
||||
if err := firstHopRecords.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
firstHopData, err := firstHopRecords.Serialize()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
firstHopBlob = fn.Some(firstHopData)
|
||||
}
|
||||
|
||||
// Build the route and return it to the caller.
|
||||
route, err := s.cfg.Router.BuildRoute(
|
||||
amt, hops, outgoingChan, req.FinalCltvDelta, payAddr,
|
||||
firstHopBlob,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in new issue
Block a user