lnrpc: update ListInvoices RPC with new pagination support

This commit is contained in:
Wilmer Paulino 2018-09-13 14:50:58 -07:00 committed by Olaoluwa Osuntokun
parent fe17adc519
commit 9c92d60149
3 changed files with 33 additions and 14 deletions

@ -4101,15 +4101,14 @@ type ListInvoiceRequest struct {
// / If set, only unsettled invoices will be returned in the response.
PendingOnly bool `protobuf:"varint,1,opt,name=pending_only" json:"pending_only,omitempty"`
// *
// The offset in the time series to start at. As each response can only contain
// 50k invoices, callers can use this to skip around within a packed time
// series.
// The index of an invoice that will be used as either the start or end of a
// query to determine which invoices should be returned in the response.
IndexOffset uint64 `protobuf:"varint,4,opt,name=index_offset" json:"index_offset,omitempty"`
// / The max number of invoices to return in the response to this query.
NumMaxInvoices uint64 `protobuf:"varint,5,opt,name=num_max_invoices" json:"num_max_invoices,omitempty"`
// *
// If set, the invoices returned will result from seeking backwards from the
// specified index offset.
// specified index offset. This can be used to paginate backwards.
Reversed bool `protobuf:"varint,6,opt,name=reversed" json:"reversed,omitempty"`
}
@ -5327,7 +5326,14 @@ type LightningClient interface {
AddInvoice(ctx context.Context, in *Invoice, opts ...grpc.CallOption) (*AddInvoiceResponse, error)
// * lncli: `listinvoices`
// ListInvoices returns a list of all the invoices currently stored within the
// database. Any active debug invoices are ignored.
// database. Any active debug invoices are ignored. It has full support for
// paginated responses, 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.
ListInvoices(ctx context.Context, in *ListInvoiceRequest, opts ...grpc.CallOption) (*ListInvoiceResponse, error)
// * lncli: `lookupinvoice`
// LookupInvoice attempts to look up an invoice according to its payment hash.
@ -6104,7 +6110,14 @@ type LightningServer interface {
AddInvoice(context.Context, *Invoice) (*AddInvoiceResponse, error)
// * lncli: `listinvoices`
// ListInvoices returns a list of all the invoices currently stored within the
// database. Any active debug invoices are ignored.
// database. Any active debug invoices are ignored. It has full support for
// paginated responses, 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.
ListInvoices(context.Context, *ListInvoiceRequest) (*ListInvoiceResponse, error)
// * lncli: `lookupinvoice`
// LookupInvoice attempts to look up an invoice according to its payment hash.

@ -443,7 +443,14 @@ service Lightning {
/** lncli: `listinvoices`
ListInvoices returns a list of all the invoices currently stored within the
database. Any active debug invoices are ignored.
database. Any active debug invoices are ignored. It has full support for
paginated responses, 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.
*/
rpc ListInvoices (ListInvoiceRequest) returns (ListInvoiceResponse) {
option (google.api.http) = {
@ -1726,9 +1733,8 @@ message ListInvoiceRequest {
bool pending_only = 1 [json_name = "pending_only"];
/**
The offset in the time series to start at. As each response can only contain
50k invoices, callers can use this to skip around within a packed time
series.
The index of an invoice that will be used as either the start or end of a
query to determine which invoices should be returned in the response.
*/
uint64 index_offset = 4 [json_name = "index_offset"];
@ -1737,7 +1743,7 @@ message ListInvoiceRequest {
/**
If set, the invoices returned will result from seeking backwards from the
specified index offset.
specified index offset. This can be used to paginate backwards.
*/
bool reversed = 6 [json_name = "reversed"];
}

@ -614,7 +614,7 @@
},
"/v1/invoices": {
"get": {
"summary": "* lncli: `listinvoices`\nListInvoices returns a list of all the invoices currently stored within the\ndatabase. Any active debug invoices are ignored.",
"summary": "* lncli: `listinvoices`\nListInvoices returns a list of all the invoices currently stored within the\ndatabase. Any active debug invoices are ignored. It has full support for\npaginated responses, allowing users to query for specific invoices through\ntheir add_index. This can be done by using either the first_index_offset or\nlast_index_offset fields included in the response as the index_offset of the\nnext request. The reversed flag is set by default in order to paginate\nbackwards. If you wish to paginate forwards, you must explicitly set the\nflag to false. If none of the parameters are specified, then the last 100\ninvoices will be returned.",
"operationId": "ListInvoices",
"responses": {
"200": {
@ -635,7 +635,7 @@
},
{
"name": "index_offset",
"description": "*\nThe offset in the time series to start at. As each response can only contain\n50k invoices, callers can use this to skip around within a packed time\nseries.",
"description": "*\nThe index of an invoice that will be used as either the start or end of a\nquery to determine which invoices should be returned in the response.",
"in": "query",
"required": false,
"type": "string",
@ -651,7 +651,7 @@
},
{
"name": "reversed",
"description": "*\nIf set, the invoices returned will result from seeking backwards from the\nspecified index offset.",
"description": "*\nIf set, the invoices returned will result from seeking backwards from the\nspecified index offset. This can be used to paginate backwards.",
"in": "query",
"required": false,
"type": "boolean",