multi: specify start and end height for ListTransactionDetails
Add start and end height parameters to the rpc and cli GetTransactions endpoints. Default to returning all transactions from genesis to tip, including unconfirmed transactions to maintain backwards compatibility.
This commit is contained in:
10 files changed
+913
-736
No files matched your search
+15
-3
@@ -50,6 +50,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/lnrpc/routerrpc"
|
||||
"github.com/lightningnetwork/lnd/lntypes"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/btcwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chanfunding"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@@ -4548,10 +4549,21 @@ func (r *rpcServer) SubscribeTransactions(req *lnrpc.GetTransactionsRequest,
|
||||
// GetTransactions returns a list of describing all the known transactions
|
||||
// relevant to the wallet.
|
||||
func (r *rpcServer) GetTransactions(ctx context.Context,
|
||||
_ *lnrpc.GetTransactionsRequest) (*lnrpc.TransactionDetails, error) {
|
||||
req *lnrpc.GetTransactionsRequest) (*lnrpc.TransactionDetails, error) {
|
||||
|
||||
// TODO(roasbeef): add pagination support
|
||||
transactions, err := r.server.cc.wallet.ListTransactionDetails()
|
||||
// To remain backwards compatible with the old api, default to the
|
||||
// special case end height which will return transactions from the start
|
||||
// height until the chain tip, including unconfirmed transactions.
|
||||
var endHeight int32 = btcwallet.UnconfirmedHeight
|
||||
|
||||
// If the user has provided an end height, we overwrite our default.
|
||||
if req.EndHeight != 0 {
|
||||
endHeight = req.EndHeight
|
||||
}
|
||||
|
||||
transactions, err := r.server.cc.wallet.ListTransactionDetails(
|
||||
req.StartHeight, endHeight,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user