mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-11-30 16:10:01 +01:00
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:
@@ -2295,11 +2295,37 @@ func debugLevel(ctx *cli.Context) error {
|
||||
}
|
||||
|
||||
var listChainTxnsCommand = cli.Command{
|
||||
Name: "listchaintxns",
|
||||
Category: "On-chain",
|
||||
Usage: "List transactions from the wallet.",
|
||||
Description: "List all transactions an address of the wallet was involved in.",
|
||||
Action: actionDecorator(listChainTxns),
|
||||
Name: "listchaintxns",
|
||||
Category: "On-chain",
|
||||
Usage: "List transactions from the wallet.",
|
||||
Flags: []cli.Flag{
|
||||
cli.Int64Flag{
|
||||
Name: "start_height",
|
||||
Usage: "the block height from which to list " +
|
||||
"transactions, inclusive",
|
||||
},
|
||||
cli.Int64Flag{
|
||||
Name: "end_height",
|
||||
Usage: "the block height until which to list " +
|
||||
"transactions, inclusive, to get transactions " +
|
||||
"until the chain tip, including unconfirmed, " +
|
||||
"set this value to -1",
|
||||
},
|
||||
},
|
||||
Description: `
|
||||
List all transactions an address of the wallet was involved in.
|
||||
|
||||
This call will return a list of wallet related transactions that paid
|
||||
to an address our wallet controls, or spent utxos that we held. The
|
||||
start_height and end_height flags can be used to specify an inclusive
|
||||
block range over which to query for transactions. If the end_height is
|
||||
less than the start_height, transactions will be queried in reverse.
|
||||
To get all transactions until the chain tip, including unconfirmed
|
||||
transactions (identifiable with BlockHeight=0), set end_height to -1.
|
||||
By default, this call will get all transactions our wallet was involved
|
||||
in, including unconfirmed transactions.
|
||||
`,
|
||||
Action: actionDecorator(listChainTxns),
|
||||
}
|
||||
|
||||
func listChainTxns(ctx *cli.Context) error {
|
||||
@@ -2307,8 +2333,16 @@ func listChainTxns(ctx *cli.Context) error {
|
||||
client, cleanUp := getClient(ctx)
|
||||
defer cleanUp()
|
||||
|
||||
resp, err := client.GetTransactions(ctxb, &lnrpc.GetTransactionsRequest{})
|
||||
req := &lnrpc.GetTransactionsRequest{}
|
||||
|
||||
if ctx.IsSet("start_height") {
|
||||
req.StartHeight = int32(ctx.Int64("start_height"))
|
||||
}
|
||||
if ctx.IsSet("end_height") {
|
||||
req.EndHeight = int32(ctx.Int64("end_height"))
|
||||
}
|
||||
|
||||
resp, err := client.GetTransactions(ctxb, req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user