lnrpc: add first hop records field to SendPayment

This commit is contained in:
George Tsagkarelis 2024-04-16 11:03:59 +02:00 committed by Olaoluwa Osuntokun
parent 7a3246855f
commit 3a53b16549
4 changed files with 642 additions and 592 deletions

File diff suppressed because it is too large Load Diff

View File

@ -330,6 +330,15 @@ message SendPaymentRequest {
only, to 1 to optimize for reliability only or a value inbetween for a mix.
*/
double time_pref = 23;
/*
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 = 24;
}
message TrackPaymentRequest {

View File

@ -1802,6 +1802,14 @@
"type": "number",
"format": "double",
"description": "The time preference for this payment. Set to -1 to optimize for fees\nonly, to 1 to optimize for reliability only or a value inbetween for a mix."
},
"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."
}
}
},

View File

@ -858,6 +858,12 @@ func (r *RouterBackend) extractIntentFromSendRequest(
}
payIntent.DestCustomRecords = customRecords
firstHopRecords := record.CustomSet(rpcPayReq.FirstHopCustomRecords)
if err := firstHopRecords.Validate(); err != nil {
return nil, err
}
payIntent.FirstHopCustomRecords = firstHopRecords
payIntent.PayAttemptTimeout = time.Second *
time.Duration(rpcPayReq.TimeoutSeconds)