lncli: modify listpayments to use queried payments and update cli docs

This commit is contained in:
bitromortac 2020-01-17 07:50:50 +01:00
parent 97b759796d
commit 4593cfa6c6

@ -2171,10 +2171,42 @@ var listPaymentsCommand = cli.Command{
Name: "listpayments",
Category: "Payments",
Usage: "List all outgoing payments.",
Description: "This command enables the retrieval of payments stored " +
"in the database. Pagination is supported by the usage of " +
"index_offset in combination with the paginate_forwards flag. " +
"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. ",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "include_incomplete",
Usage: "if set to true, payments still in flight (or failed) will be returned as well",
Usage: "if set to true, payments still in flight (or " +
"failed) will be returned as well, keeping" +
"indices for payments the same as without " +
"the flag",
},
cli.UintFlag{
Name: "index_offset",
Usage: "The index of a payment that will be used as " +
"either the start (in forwards mode) or end " +
"(in reverse mode) of a query to determine " +
"which payments should be returned in the " +
"response, where the index_offset is " +
"excluded. If index_offset is set to zero in " +
"reversed mode, the query will end with the " +
"last payment made.",
},
cli.UintFlag{
Name: "max_payments",
Usage: "the max number of payments to return, by " +
"default, all completed payments are returned",
},
cli.BoolFlag{
Name: "paginate_forwards",
Usage: "if set, payments succeeding the " +
"index_offset will be returned, allowing " +
"forwards pagination",
},
},
Action: actionDecorator(listPayments),
@ -2186,6 +2218,9 @@ func listPayments(ctx *cli.Context) error {
req := &lnrpc.ListPaymentsRequest{
IncludeIncomplete: ctx.Bool("include_incomplete"),
IndexOffset: uint64(ctx.Uint("index_offset")),
MaxPayments: uint64(ctx.Uint("max_payments")),
Reversed: !ctx.Bool("paginate_forwards"),
}
payments, err := client.ListPayments(context.Background(), req)