multi: return txns first and last indices
In this commit we introduce first and last indices for the tranasctions returned which can be used to seek for further transactions in a pagination style. Signed-off-by: Abdullahi Yunus <abdoollahikbk@gmail.com>
This commit is contained in:
1 parent
cd1df4ac34
commit
762d01536b
13 files changed
+3135
-3044
No files matched your search
+3038
-3014
File diff suppressed because it is too large.
Load diff
@@ -774,6 +774,18 @@ message GetTransactionsRequest {
|
||||
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 {
|
||||
|
||||
@@ -7520,6 +7520,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,7 +1376,7 @@ 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, 0, 0,
|
||||
)
|
||||
@@ -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