Merge pull request #8998 from Abdulkbk/trx-pagination
pagination: add pagination to wallet transactions
This commit is contained in:
14 files changed
+329
-37
No files matched your search
+59
-10
@@ -2068,6 +2068,12 @@ type GetTransactionsRequest struct {
|
||||
EndHeight int32 `protobuf:"varint,2,opt,name=end_height,json=endHeight,proto3" json:"end_height,omitempty"`
|
||||
// An optional filter to only include transactions relevant to an account.
|
||||
Account string `protobuf:"bytes,3,opt,name=account,proto3" json:"account,omitempty"`
|
||||
// The index of a transaction that will be used in a query to determine which
|
||||
// transaction should be returned in the response.
|
||||
IndexOffset uint32 `protobuf:"varint,4,opt,name=index_offset,json=indexOffset,proto3" json:"index_offset,omitempty"`
|
||||
// The maximal number of transactions returned in the response to this query.
|
||||
// This value should be set to 0 to return all transactions.
|
||||
MaxTransactions uint32 `protobuf:"varint,5,opt,name=max_transactions,json=maxTransactions,proto3" json:"max_transactions,omitempty"`
|
||||
}
|
||||
|
||||
func (x *GetTransactionsRequest) Reset() {
|
||||
@@ -2123,6 +2129,20 @@ func (x *GetTransactionsRequest) GetAccount() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *GetTransactionsRequest) GetIndexOffset() uint32 {
|
||||
if x != nil {
|
||||
return x.IndexOffset
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *GetTransactionsRequest) GetMaxTransactions() uint32 {
|
||||
if x != nil {
|
||||
return x.MaxTransactions
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type TransactionDetails struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -2130,6 +2150,12 @@ type TransactionDetails struct {
|
||||
|
||||
// The list of transactions relevant to the wallet.
|
||||
Transactions []*Transaction `protobuf:"bytes,1,rep,name=transactions,proto3" json:"transactions,omitempty"`
|
||||
// The index of the last item in the set of returned transactions. This can be
|
||||
// used to seek further, pagination style.
|
||||
LastIndex uint64 `protobuf:"varint,2,opt,name=last_index,json=lastIndex,proto3" json:"last_index,omitempty"`
|
||||
// The index of the last item in the set of returned transactions. This can be
|
||||
// used to seek backwards, pagination style.
|
||||
FirstIndex uint64 `protobuf:"varint,3,opt,name=first_index,json=firstIndex,proto3" json:"first_index,omitempty"`
|
||||
}
|
||||
|
||||
func (x *TransactionDetails) Reset() {
|
||||
@@ -2171,6 +2197,20 @@ func (x *TransactionDetails) GetTransactions() []*Transaction {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (x *TransactionDetails) GetLastIndex() uint64 {
|
||||
if x != nil {
|
||||
return x.LastIndex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *TransactionDetails) GetFirstIndex() uint64 {
|
||||
if x != nil {
|
||||
return x.FirstIndex
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type FeeLimit struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@@ -18558,20 +18598,29 @@ var file_lightning_proto_rawDesc = []byte{
|
||||
0x75, 0x73, 0x5f, 0x6f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x18, 0x0c, 0x20, 0x03,
|
||||
0x28, 0x0b, 0x32, 0x17, 0x2e, 0x6c, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x50, 0x72, 0x65, 0x76, 0x69,
|
||||
0x6f, 0x75, 0x73, 0x4f, 0x75, 0x74, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x52, 0x11, 0x70, 0x72, 0x65,
|
||||
0x76, 0x69, 0x6f, 0x75, 0x73, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0x74,
|
||||
0x0a, 0x16, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e,
|
||||
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x61, 0x72,
|
||||
0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b,
|
||||
0x73, 0x74, 0x61, 0x72, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x65,
|
||||
0x6e, 0x64, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x09, 0x65, 0x6e, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x22, 0x4c, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
|
||||
0x76, 0x69, 0x6f, 0x75, 0x73, 0x4f, 0x75, 0x74, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x73, 0x22, 0xc2,
|
||||
0x01, 0x0a, 0x16, 0x47, 0x65, 0x74, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x73, 0x74, 0x61,
|
||||
0x72, 0x74, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
|
||||
0x0b, 0x73, 0x74, 0x61, 0x72, 0x74, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x1d, 0x0a, 0x0a,
|
||||
0x65, 0x6e, 0x64, 0x5f, 0x68, 0x65, 0x69, 0x67, 0x68, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05,
|
||||
0x52, 0x09, 0x65, 0x6e, 0x64, 0x48, 0x65, 0x69, 0x67, 0x68, 0x74, 0x12, 0x18, 0x0a, 0x07, 0x61,
|
||||
0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63,
|
||||
0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x6e, 0x64, 0x65, 0x78, 0x5f, 0x6f,
|
||||
0x66, 0x66, 0x73, 0x65, 0x74, 0x18, 0x04, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x0b, 0x69, 0x6e, 0x64,
|
||||
0x65, 0x78, 0x4f, 0x66, 0x66, 0x73, 0x65, 0x74, 0x12, 0x29, 0x0a, 0x10, 0x6d, 0x61, 0x78, 0x5f,
|
||||
0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x05, 0x20, 0x01,
|
||||
0x28, 0x0d, 0x52, 0x0f, 0x6d, 0x61, 0x78, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69,
|
||||
0x6f, 0x6e, 0x73, 0x22, 0x8c, 0x01, 0x0a, 0x12, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74,
|
||||
0x69, 0x6f, 0x6e, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x73, 0x12, 0x36, 0x0a, 0x0c, 0x74, 0x72,
|
||||
0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x12, 0x2e, 0x6c, 0x6e, 0x72, 0x70, 0x63, 0x2e, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63,
|
||||
0x74, 0x69, 0x6f, 0x6e, 0x52, 0x0c, 0x74, 0x72, 0x61, 0x6e, 0x73, 0x61, 0x63, 0x74, 0x69, 0x6f,
|
||||
0x6e, 0x73, 0x22, 0x68, 0x0a, 0x08, 0x46, 0x65, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16,
|
||||
0x6e, 0x73, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x61, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x04, 0x52, 0x09, 0x6c, 0x61, 0x73, 0x74, 0x49, 0x6e, 0x64, 0x65,
|
||||
0x78, 0x12, 0x1f, 0x0a, 0x0b, 0x66, 0x69, 0x72, 0x73, 0x74, 0x5f, 0x69, 0x6e, 0x64, 0x65, 0x78,
|
||||
0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x66, 0x69, 0x72, 0x73, 0x74, 0x49, 0x6e, 0x64,
|
||||
0x65, 0x78, 0x22, 0x68, 0x0a, 0x08, 0x46, 0x65, 0x65, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x12, 0x16,
|
||||
0x0a, 0x05, 0x66, 0x69, 0x78, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52,
|
||||
0x05, 0x66, 0x69, 0x78, 0x65, 0x64, 0x12, 0x1f, 0x0a, 0x0a, 0x66, 0x69, 0x78, 0x65, 0x64, 0x5f,
|
||||
0x6d, 0x73, 0x61, 0x74, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x48, 0x00, 0x52, 0x09, 0x66, 0x69,
|
||||
|
||||
@@ -757,11 +757,35 @@ message GetTransactionsRequest {
|
||||
|
||||
// An optional filter to only include transactions relevant to an account.
|
||||
string account = 3;
|
||||
|
||||
/*
|
||||
The index of a transaction that will be used in a query to determine which
|
||||
transaction should be returned in the response.
|
||||
*/
|
||||
uint32 index_offset = 4;
|
||||
|
||||
/*
|
||||
The maximal number of transactions returned in the response to this query.
|
||||
This value should be set to 0 to return all transactions.
|
||||
*/
|
||||
uint32 max_transactions = 5;
|
||||
}
|
||||
|
||||
message TransactionDetails {
|
||||
// The list of transactions relevant to the wallet.
|
||||
repeated Transaction transactions = 1;
|
||||
|
||||
/*
|
||||
The index of the last item in the set of returned transactions. This can be
|
||||
used to seek further, pagination style.
|
||||
*/
|
||||
uint64 last_index = 2;
|
||||
|
||||
/*
|
||||
The index of the last item in the set of returned transactions. This can be
|
||||
used to seek backwards, pagination style.
|
||||
*/
|
||||
uint64 first_index = 3;
|
||||
}
|
||||
|
||||
message FeeLimit {
|
||||
|
||||
@@ -2591,6 +2591,22 @@
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "index_offset",
|
||||
"description": "The index of a transaction that will be used in a query to determine which\ntransaction should be returned in the response.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"name": "max_transactions",
|
||||
"description": "The maximal number of transactions returned in the response to this query.\nThis value should be set to 0 to return all transactions.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
@@ -2774,6 +2790,22 @@
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"name": "index_offset",
|
||||
"description": "The index of a transaction that will be used in a query to determine which\ntransaction should be returned in the response.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
{
|
||||
"name": "max_transactions",
|
||||
"description": "The maximal number of transactions returned in the response to this query.\nThis value should be set to 0 to return all transactions.",
|
||||
"in": "query",
|
||||
"required": false,
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
}
|
||||
],
|
||||
"tags": [
|
||||
@@ -7492,6 +7524,16 @@
|
||||
"$ref": "#/definitions/lnrpcTransaction"
|
||||
},
|
||||
"description": "The list of transactions relevant to the wallet."
|
||||
},
|
||||
"last_index": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The index of the last item in the set of returned transactions. This can be\nused to seek further, pagination style."
|
||||
},
|
||||
"first_index": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The index of the last item in the set of returned transactions. This can be\nused to seek backwards, pagination style."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
+5
-1
@@ -117,9 +117,13 @@ func RPCTransaction(tx *lnwallet.TransactionDetail) *Transaction {
|
||||
}
|
||||
|
||||
// RPCTransactionDetails returns a set of rpc transaction details.
|
||||
func RPCTransactionDetails(txns []*lnwallet.TransactionDetail) *TransactionDetails {
|
||||
func RPCTransactionDetails(txns []*lnwallet.TransactionDetail, firstIdx,
|
||||
lastIdx uint64) *TransactionDetails {
|
||||
|
||||
txDetails := &TransactionDetails{
|
||||
Transactions: make([]*Transaction, len(txns)),
|
||||
FirstIndex: firstIdx,
|
||||
LastIndex: lastIdx,
|
||||
}
|
||||
|
||||
for i, tx := range txns {
|
||||
|
||||
@@ -1166,6 +1166,16 @@
|
||||
"$ref": "#/definitions/lnrpcTransaction"
|
||||
},
|
||||
"description": "The list of transactions relevant to the wallet."
|
||||
},
|
||||
"last_index": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The index of the last item in the set of returned transactions. This can be\nused to seek further, pagination style."
|
||||
},
|
||||
"first_index": {
|
||||
"type": "string",
|
||||
"format": "uint64",
|
||||
"description": "The index of the last item in the set of returned transactions. This can be\nused to seek backwards, pagination style."
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1376,9 +1376,9 @@ func (w *WalletKit) ListSweeps(ctx context.Context,
|
||||
// can match our list of sweeps against the list of transactions that
|
||||
// the wallet is still tracking. Sweeps are currently always swept to
|
||||
// the default wallet account.
|
||||
transactions, err := w.cfg.Wallet.ListTransactionDetails(
|
||||
txns, firstIdx, lastIdx, err := w.cfg.Wallet.ListTransactionDetails(
|
||||
in.StartHeight, btcwallet.UnconfirmedHeight,
|
||||
lnwallet.DefaultAccountName,
|
||||
lnwallet.DefaultAccountName, 0, 0,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -1389,7 +1389,7 @@ func (w *WalletKit) ListSweeps(ctx context.Context,
|
||||
txDetails []*lnwallet.TransactionDetail
|
||||
)
|
||||
|
||||
for _, tx := range transactions {
|
||||
for _, tx := range txns {
|
||||
_, ok := sweepTxns[tx.Hash.String()]
|
||||
if !ok {
|
||||
continue
|
||||
@@ -1408,7 +1408,7 @@ func (w *WalletKit) ListSweeps(ctx context.Context,
|
||||
return &ListSweepsResponse{
|
||||
Sweeps: &ListSweepsResponse_TransactionDetails{
|
||||
TransactionDetails: lnrpc.RPCTransactionDetails(
|
||||
txDetails,
|
||||
txDetails, firstIdx, lastIdx,
|
||||
),
|
||||
},
|
||||
}, nil
|
||||
|
||||
Reference in new issue
Block a user