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

@@ -95,6 +95,11 @@ var (
Usage: "if set to true, then AMP will be used to complete the " +
"payment",
}
timePrefFlag = cli.Float64Flag{
Name: "time_pref",
Usage: "(optional) expresses time preference (range -1 to 1)",
}
)
// paymentFlags returns common flags for sendpayment and payinvoice.
@@ -140,6 +145,7 @@ func paymentFlags() []cli.Flag {
},
dataFlag, inflightUpdatesFlag, maxPartsFlag, jsonFlag,
maxShardSizeSatFlag, maxShardSizeMsatFlag, ampFlag,
timePrefFlag,
}
}
@@ -523,6 +529,9 @@ func sendPaymentRequest(ctx *cli.Context,
req.FeeLimitSat = feeLimit
// Set time pref.
req.TimePref = ctx.Float64(timePrefFlag.Name)
// Always print in-flight updates for the table output.
printJSON := ctx.Bool(jsonFlag.Name)
req.NoInflightUpdates = !ctx.Bool(inflightUpdatesFlag.Name) && printJSON
@@ -1019,6 +1028,7 @@ var queryRoutesCommand = cli.Command{
Usage: "(optional) the channel id of the channel " +
"that must be taken to the first hop",
},
timePrefFlag,
cltvLimitFlag,
},
Action: actionDecorator(queryRoutes),
@@ -1072,6 +1082,7 @@ func queryRoutes(ctx *cli.Context) error {
UseMissionControl: ctx.Bool("use_mc"),
CltvLimit: uint32(ctx.Uint64(cltvLimitFlag.Name)),
OutgoingChanId: ctx.Uint64("outgoing_chanid"),
TimePref: ctx.Float64(timePrefFlag.Name),
}
route, err := client.QueryRoutes(ctxc, req)