mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-09 19:43:36 +02:00
routing: add time_pref parameter to queryroutes and sendpayment
This commit is contained in:
@@ -53,7 +53,8 @@ type RouterBackend struct {
|
||||
// FindRoutes is a closure that abstracts away how we locate/query for
|
||||
// routes.
|
||||
FindRoute func(source, target route.Vertex,
|
||||
amt lnwire.MilliSatoshi, restrictions *routing.RestrictParams,
|
||||
amt lnwire.MilliSatoshi, timePref float64,
|
||||
restrictions *routing.RestrictParams,
|
||||
destCustomRecords record.CustomSet,
|
||||
routeHints map[route.Vertex][]*channeldb.CachedEdgePolicy,
|
||||
finalExpiry uint16) (*route.Route, error)
|
||||
@@ -324,7 +325,7 @@ func (r *RouterBackend) QueryRoutes(ctx context.Context,
|
||||
// can carry `in.Amt` satoshis _including_ the total fee required on
|
||||
// the route.
|
||||
route, err := r.FindRoute(
|
||||
sourcePubKey, targetPubKey, amt, restrictions,
|
||||
sourcePubKey, targetPubKey, amt, in.TimePref, restrictions,
|
||||
customRecords, routeHintEdges, finalCLTVDelta,
|
||||
)
|
||||
if err != nil {
|
||||
@@ -559,6 +560,12 @@ func (r *RouterBackend) extractIntentFromSendRequest(
|
||||
|
||||
payIntent := &routing.LightningPayment{}
|
||||
|
||||
// Pass along time preference.
|
||||
if rpcPayReq.TimePref < -1 || rpcPayReq.TimePref > 1 {
|
||||
return nil, errors.New("time preference out of range")
|
||||
}
|
||||
payIntent.TimePref = rpcPayReq.TimePref
|
||||
|
||||
// Pass along restrictions on the outgoing channels that may be used.
|
||||
payIntent.OutgoingChannelIDs = rpcPayReq.OutgoingChanIds
|
||||
|
||||
|
Reference in New Issue
Block a user