Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lncli: change listinvoices reversed flag to paginate-forwards #4003

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2819,10 +2819,10 @@ var listInvoicesCommand = cli.Command{
allowing users to query for specific invoices through their add_index.
This can be done by using either the first_index_offset or
last_index_offset fields included in the response as the index_offset of
the next request. The reversed flag is set by default in order to
paginate backwards. If you wish to paginate forwards, you must
explicitly set the flag to false. If none of the parameters are
specified, then the last 100 invoices will be returned.
the next request. Backward pagination is enabled by default to receive
current invoices first. If you wish to paginate forwards, set the
paginate-forwards flag. If none of the parameters are specified, then
the last 100 invoices will be returned.

For example: if you have 200 invoices, "lncli listinvoices" will return
the last 100 created. If you wish to retrieve the previous 100, the
Expand All @@ -2845,11 +2845,10 @@ var listInvoicesCommand = cli.Command{
Name: "max_invoices",
Usage: "the max number of invoices to return",
},
cli.BoolTFlag{
Name: "reversed",
Usage: "if set, the invoices returned precede the " +
"given index_offset, allowing backwards " +
"pagination",
cli.BoolFlag{
Name: "paginate-forwards",
Usage: "if set, invoices succeeding the " +
"index_offset will be returned",
},
},
Action: actionDecorator(listInvoices),
Expand All @@ -2863,7 +2862,7 @@ func listInvoices(ctx *cli.Context) error {
PendingOnly: ctx.Bool("pending_only"),
IndexOffset: ctx.Uint64("index_offset"),
NumMaxInvoices: ctx.Uint64("max_invoices"),
Reversed: ctx.Bool("reversed"),
Reversed: !ctx.Bool("paginate-forwards"),
}

invoices, err := client.ListInvoices(context.Background(), req)
Expand Down