mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01:00
cmd: Modified listchaintxns command.
- Added reverse flag to listchaintxns command. - Listchaintxns command returns error when start_height is less than end_height if end_height is not -1.
This commit is contained in:
parent
e3d9fcb5ac
commit
255ff1beb3
1 changed files with 18 additions and 4 deletions
|
@ -2248,7 +2248,7 @@ var listChainTxnsCommand = cli.Command{
|
||||||
to an address our wallet controls, or spent utxos that we held. The
|
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
|
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
|
block range over which to query for transactions. If the end_height is
|
||||||
less than the start_height, transactions will be queried in reverse.
|
less than the start_height, an error will be returned.
|
||||||
To get all transactions until the chain tip, including unconfirmed
|
To get all transactions until the chain tip, including unconfirmed
|
||||||
transactions (identifiable with BlockHeight=0), set end_height to -1.
|
transactions (identifiable with BlockHeight=0), set end_height to -1.
|
||||||
By default, this call will get all transactions our wallet was involved
|
By default, this call will get all transactions our wallet was involved
|
||||||
|
@ -2267,10 +2267,24 @@ func listChainTxns(ctx *cli.Context) error {
|
||||||
MaxTransactions: uint32(ctx.Uint64("max_transactions")),
|
MaxTransactions: uint32(ctx.Uint64("max_transactions")),
|
||||||
}
|
}
|
||||||
|
|
||||||
if ctx.IsSet("start_height") {
|
switch {
|
||||||
req.StartHeight = int32(ctx.Int64("start_height"))
|
case ctx.IsSet("start_height") && ctx.IsSet("end_height"):
|
||||||
|
startHeight := ctx.Int64("start_height")
|
||||||
|
endHeight := ctx.Int64("end_height")
|
||||||
|
|
||||||
|
if endHeight != -1 && startHeight > endHeight {
|
||||||
|
return errors.New("start_height should " +
|
||||||
|
"be less than end_height if end_height " +
|
||||||
|
"is not equal to -1")
|
||||||
}
|
}
|
||||||
if ctx.IsSet("end_height") {
|
|
||||||
|
req.StartHeight = int32(startHeight)
|
||||||
|
req.EndHeight = int32(endHeight)
|
||||||
|
|
||||||
|
case ctx.IsSet("start_height"):
|
||||||
|
req.StartHeight = int32(ctx.Int64("start_height"))
|
||||||
|
|
||||||
|
case ctx.IsSet("end_height"):
|
||||||
req.EndHeight = int32(ctx.Int64("end_height"))
|
req.EndHeight = int32(ctx.Int64("end_height"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue