From 57b7eb7814f28c67f502d42b52a46f660fdc065e Mon Sep 17 00:00:00 2001 From: yyforyongyu Date: Wed, 16 Nov 2022 02:28:17 +0800 Subject: [PATCH] cli: update `listinvoices` and `listpayments` to use the date filter --- cmd/lncli/cmd_invoice.go | 22 ++++++++++++++++++---- cmd/lncli/cmd_payments.go | 14 ++++++++++++++ 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/cmd/lncli/cmd_invoice.go b/cmd/lncli/cmd_invoice.go index 65e76883e..87686d013 100644 --- a/cmd/lncli/cmd_invoice.go +++ b/cmd/lncli/cmd_invoice.go @@ -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) diff --git a/cmd/lncli/cmd_payments.go b/cmd/lncli/cmd_payments.go index 725870c9f..cb6b88b55 100644 --- a/cmd/lncli/cmd_payments.go +++ b/cmd/lncli/cmd_payments.go @@ -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)