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:
Abdullahi Yunus committed 2024-11-22 08:22:55 +01:00
1 parent cd1df4ac34
commit 762d01536b
13 files changed
+3135 -3044

No files matched your search

+10
View File
@@ -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."
}
}
},
+3 -3
View File
@@ -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