routing: add time_pref parameter to queryroutes and sendpayment

This commit is contained in:
Joost Jager
2021-11-23 12:06:33 +01:00
parent 269a8e74d3
commit ba5abdc090
17 changed files with 2034 additions and 1918 deletions

View File

@@ -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