cmd/lncli: add --count_total_payments flag

This commit is contained in:
Oliver Gugger 2022-04-26 21:35:46 +02:00
parent a44e56b51a
commit ab6e1012e4
No known key found for this signature in database
GPG Key ID: 8E4256593F177720

View File

@ -1130,13 +1130,22 @@ var listPaymentsCommand = cli.Command{
Name: "listpayments", Name: "listpayments",
Category: "Payments", Category: "Payments",
Usage: "List all outgoing payments.", Usage: "List all outgoing payments.",
Description: "This command enables the retrieval of payments stored " + Description: `
"in the database. Pagination is supported by the usage of " + This command enables the retrieval of payments stored
"index_offset in combination with the paginate_forwards flag. " + in the database.
"Reversed pagination is enabled by default to receive " +
"current payments first. Pagination can be resumed by using " + Pagination is supported by the usage of index_offset in combination with
"the returned last_index_offset (for forwards order), or " + the paginate_forwards flag.
"first_index_offset (for reversed order) as the offset_index. ", Reversed pagination is enabled by default to receive current payments
first. Pagination can be resumed by using the returned last_index_offset
(for forwards order), or first_index_offset (for reversed order) as the
offset_index.
Because counting all payments in the payment database can take a long
time on systems with many payments, the count is not returned by
default. That feature can be turned on with the --count_total_payments
flag.
`,
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "include_incomplete", Name: "include_incomplete",
@ -1167,6 +1176,13 @@ var listPaymentsCommand = cli.Command{
"index_offset will be returned, allowing " + "index_offset will be returned, allowing " +
"forwards pagination", "forwards pagination",
}, },
cli.BoolFlag{
Name: "count_total_payments",
Usage: "if set, all payments (complete or incomplete, " +
"independent of max_payments parameter) will " +
"be counted; can take a long time on systems " +
"with many payments",
},
}, },
Action: actionDecorator(listPayments), Action: actionDecorator(listPayments),
} }
@ -1181,6 +1197,7 @@ func listPayments(ctx *cli.Context) error {
IndexOffset: uint64(ctx.Uint("index_offset")), IndexOffset: uint64(ctx.Uint("index_offset")),
MaxPayments: uint64(ctx.Uint("max_payments")), MaxPayments: uint64(ctx.Uint("max_payments")),
Reversed: !ctx.Bool("paginate_forwards"), Reversed: !ctx.Bool("paginate_forwards"),
CountTotalPayments: ctx.Bool("count_total_payments"),
} }
payments, err := client.ListPayments(ctxc, req) payments, err := client.ListPayments(ctxc, req)