mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-06-02 19:19:18 +02:00
multi: modify listtxn definition
This commit modifies listtransactiondetails method definition to take in additional params: index_offset and maxTxn
This commit is contained in:
parent
037db4278a
commit
cd1df4ac34
@ -1378,7 +1378,7 @@ func (w *WalletKit) ListSweeps(ctx context.Context,
|
||||
// the default wallet account.
|
||||
transactions, err := w.cfg.Wallet.ListTransactionDetails(
|
||||
in.StartHeight, btcwallet.UnconfirmedHeight,
|
||||
lnwallet.DefaultAccountName,
|
||||
lnwallet.DefaultAccountName, 0, 0,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -187,7 +187,7 @@ func (w *WalletController) ListUnspentWitness(int32, int32,
|
||||
|
||||
// ListTransactionDetails currently returns dummy values.
|
||||
func (w *WalletController) ListTransactionDetails(int32, int32,
|
||||
string) ([]*lnwallet.TransactionDetail, error) {
|
||||
string, uint32, uint32) ([]*lnwallet.TransactionDetail, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -1554,7 +1554,8 @@ func unminedTransactionsToDetail(
|
||||
//
|
||||
// This is a part of the WalletController interface.
|
||||
func (b *BtcWallet) ListTransactionDetails(startHeight, endHeight int32,
|
||||
accountFilter string) ([]*lnwallet.TransactionDetail, error) {
|
||||
accountFilter string, indexOffset uint32,
|
||||
maxTransactons uint32) ([]*lnwallet.TransactionDetail, error) {
|
||||
|
||||
// Grab the best block the wallet knows of, we'll use this to calculate
|
||||
// # of confirmations shortly below.
|
||||
@ -1594,7 +1595,22 @@ func (b *BtcWallet) ListTransactionDetails(startHeight, endHeight int32,
|
||||
txDetails = append(txDetails, detail)
|
||||
}
|
||||
|
||||
return txDetails, nil
|
||||
// Return empty transaction list, if offset is more than all
|
||||
// transactions.
|
||||
if int(indexOffset) >= len(txDetails) {
|
||||
return []*lnwallet.TransactionDetail{}, nil
|
||||
}
|
||||
|
||||
if maxTransactons == 0 {
|
||||
return txDetails[indexOffset:], nil
|
||||
}
|
||||
|
||||
end := indexOffset + maxTransactons
|
||||
if int(end) > len(txDetails) {
|
||||
end = uint32(len(txDetails))
|
||||
}
|
||||
|
||||
return txDetails[indexOffset:end], nil
|
||||
}
|
||||
|
||||
// txSubscriptionClient encapsulates the transaction notification client from
|
||||
|
@ -402,7 +402,8 @@ type WalletController interface {
|
||||
// retrieve the transactions relevant to a specific account. When
|
||||
// empty, transactions of all wallet accounts are returned.
|
||||
ListTransactionDetails(startHeight, endHeight int32,
|
||||
accountFilter string) ([]*TransactionDetail, error)
|
||||
accountFilter string, indexOffset uint32,
|
||||
maxTransactions uint32) ([]*TransactionDetail, error)
|
||||
|
||||
// LeaseOutput locks an output to the given ID, preventing it from being
|
||||
// available for any future coin selection attempts. The absolute time
|
||||
|
@ -198,7 +198,7 @@ func (w *mockWalletController) ListUnspentWitness(int32, int32,
|
||||
|
||||
// ListTransactionDetails currently returns dummy values.
|
||||
func (w *mockWalletController) ListTransactionDetails(int32, int32,
|
||||
string) ([]*TransactionDetail, error) {
|
||||
string, uint32, uint32) ([]*TransactionDetail, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -199,7 +199,9 @@ func assertTxInWallet(t *testing.T, w *lnwallet.LightningWallet,
|
||||
// We'll fetch all of our transaction and go through each one until
|
||||
// finding the expected transaction with its expected confirmation
|
||||
// status.
|
||||
txs, err := w.ListTransactionDetails(0, btcwallet.UnconfirmedHeight, "")
|
||||
txs, err := w.ListTransactionDetails(
|
||||
0, btcwallet.UnconfirmedHeight, "", 0, 1000,
|
||||
)
|
||||
require.NoError(t, err, "unable to retrieve transactions")
|
||||
for _, tx := range txs {
|
||||
if tx.Hash != txHash {
|
||||
@ -1102,7 +1104,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||
err = waitForWalletSync(miner, alice)
|
||||
require.NoError(t, err, "Couldn't sync Alice's wallet")
|
||||
txDetails, err := alice.ListTransactionDetails(
|
||||
startHeight, chainTip, "",
|
||||
startHeight, chainTip, "", 0, 1000,
|
||||
)
|
||||
require.NoError(t, err, "unable to fetch tx details")
|
||||
|
||||
@ -1214,7 +1216,7 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||
// with a confirmation height of 0, indicating that it has not been
|
||||
// mined yet.
|
||||
txDetails, err = alice.ListTransactionDetails(
|
||||
chainTip, btcwallet.UnconfirmedHeight, "",
|
||||
chainTip, btcwallet.UnconfirmedHeight, "", 0, 1000,
|
||||
)
|
||||
require.NoError(t, err, "unable to fetch tx details")
|
||||
var mempoolTxFound bool
|
||||
@ -1266,7 +1268,9 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||
// transactions from the last block.
|
||||
err = waitForWalletSync(miner, alice)
|
||||
require.NoError(t, err, "Couldn't sync Alice's wallet")
|
||||
txDetails, err = alice.ListTransactionDetails(chainTip, chainTip, "")
|
||||
txDetails, err = alice.ListTransactionDetails(
|
||||
chainTip, chainTip, "", 0, 1000,
|
||||
)
|
||||
require.NoError(t, err, "unable to fetch tx details")
|
||||
var burnTxFound bool
|
||||
for _, txDetail := range txDetails {
|
||||
@ -1307,7 +1311,9 @@ func testListTransactionDetails(miner *rpctest.Harness,
|
||||
|
||||
// Query for transactions only in the latest block. We do not expect
|
||||
// any transactions to be returned.
|
||||
txDetails, err = alice.ListTransactionDetails(chainTip, chainTip, "")
|
||||
txDetails, err = alice.ListTransactionDetails(
|
||||
chainTip, chainTip, "", 0, 1000,
|
||||
)
|
||||
require.NoError(t, err, "unexpected error")
|
||||
if len(txDetails) != 0 {
|
||||
t.Fatalf("expected 0 transactions, got: %v", len(txDetails))
|
||||
|
@ -6477,7 +6477,8 @@ func (r *rpcServer) GetTransactions(ctx context.Context,
|
||||
}
|
||||
|
||||
transactions, err := r.server.cc.Wallet.ListTransactionDetails(
|
||||
req.StartHeight, endHeight, req.Account,
|
||||
req.StartHeight, endHeight, req.Account, req.IndexOffset,
|
||||
req.MaxTransactions,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
Loading…
x
Reference in New Issue
Block a user