cli: update listinvoices and listpayments to use the date filter

This commit is contained in:
yyforyongyu
2022-11-16 02:28:17 +08:00
parent e9269c2093
commit 57b7eb7814
2 changed files with 32 additions and 4 deletions

View File

@@ -234,6 +234,18 @@ var listInvoicesCommand = cli.Command{
Usage: "if set, invoices succeeding the " +
"index_offset will be returned",
},
cli.Uint64Flag{
Name: "creation_date_start",
Usage: "timestamp in seconds, if set, filter " +
"invoices with creation date greater than or " +
"equal to it",
},
cli.Uint64Flag{
Name: "creation_date_end",
Usage: "timestamp in seconds, if set, filter " +
"invoices with creation date less than or " +
"equal to it",
},
},
Action: actionDecorator(listInvoices),
}
@@ -244,10 +256,12 @@ func listInvoices(ctx *cli.Context) error {
defer cleanUp()
req := &lnrpc.ListInvoiceRequest{
PendingOnly: ctx.Bool("pending_only"),
IndexOffset: ctx.Uint64("index_offset"),
NumMaxInvoices: ctx.Uint64("max_invoices"),
Reversed: !ctx.Bool("paginate-forwards"),
PendingOnly: ctx.Bool("pending_only"),
IndexOffset: ctx.Uint64("index_offset"),
NumMaxInvoices: ctx.Uint64("max_invoices"),
Reversed: !ctx.Bool("paginate-forwards"),
CreationDateStart: ctx.Uint64("creation_date_start"),
CreationDateEnd: ctx.Uint64("creation_date_end"),
}
invoices, err := client.ListInvoices(ctxc, req)

View File

@@ -1229,6 +1229,18 @@ var listPaymentsCommand = cli.Command{
"be counted; can take a long time on systems " +
"with many payments",
},
cli.Uint64Flag{
Name: "creation_date_start",
Usage: "timestamp in seconds, if set, filter " +
"payments with creation date greater than or " +
"equal to it",
},
cli.Uint64Flag{
Name: "creation_date_end",
Usage: "timestamp in seconds, if set, filter " +
"payments with creation date less than or " +
"equal to it",
},
},
Action: actionDecorator(listPayments),
}
@@ -1244,6 +1256,8 @@ func listPayments(ctx *cli.Context) error {
MaxPayments: uint64(ctx.Uint("max_payments")),
Reversed: !ctx.Bool("paginate_forwards"),
CountTotalPayments: ctx.Bool("count_total_payments"),
CreationDateStart: ctx.Uint64("creation_date_start"),
CreationDateEnd: ctx.Uint64("creation_date_end"),
}
payments, err := client.ListPayments(ctxc, req)