Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modified the listchanneltxn subcommand #7496

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 32 additions & 4 deletions cmd/lncli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,12 @@ var listChainTxnsCommand = cli.Command{
"until the chain tip, including unconfirmed, " +
"set this value to -1",
},
cli.BoolFlag{
Name: "reverse",
Usage: "It modifies the way the transactions are " +
"listed, if true, transactions are listed in " +
"reverse order",
},
},
Description: `
List all transactions an address of the wallet was involved in.
Expand All @@ -1848,7 +1854,8 @@ var listChainTxnsCommand = cli.Command{
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.
less than the start_height, an error will be returned. To return
transactions in reverse use the reverse flag.
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
Expand All @@ -1864,13 +1871,34 @@ func listChainTxns(ctx *cli.Context) error {

req := &lnrpc.GetTransactionsRequest{}

if ctx.IsSet("start_height") {
switch {
case ctx.IsSet("start_height") && ctx.IsSet("end_height"):
startHeight := ctx.Int64("start_height")
endHeight := ctx.Int64("end_height")

if endHeight == -1 && startHeight != 0 {
return errors.New("start height should be zero " +
"if end height is -1")
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatt: extra line

if endHeight != -1 && startHeight > endHeight {
return errors.New("start Height should " +
"be greater than end height if end height" +
" is not equal to -1")
}

req.StartHeight = int32(startHeight)
req.EndHeight = int32(endHeight)

case ctx.IsSet("start_height"):
req.StartHeight = int32(ctx.Int64("start_height"))
}
if ctx.IsSet("end_height") {

case ctx.IsSet("end_height"):
req.EndHeight = int32(ctx.Int64("end_height"))
}

req.Reverse = ctx.Bool("reverse")

resp, err := client.GetTransactions(ctxc, req)
if err != nil {
return err
Expand Down
9 changes: 9 additions & 0 deletions docs/release-notes/release-notes-0.17.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,9 @@ None

* The [WalletBalance](https://github.com/lightningnetwork/lnd/pull/7857) RPC
(lncli walletbalance) now supports showing the balance for a specific account.

* Added [reverse bool](https://github.com/lightningnetwork/lnd/pull/7496) to
`GettransactionRequest` message.

## lncli Updates
* Added ability to use [environment variables to override `lncli` global
Expand All @@ -244,6 +247,11 @@ None
* Add [`--unused`](https://github.com/lightningnetwork/lnd/pull/6387) to
`lncli newaddr` command.

* Added [`--reverse`](https://github.com/lightningnetwork/lnd/pull/7496) to
`lncli listchaintxns` command. `lncli listchaintxns` now returns an error when
`start_height` is less than `end_height` if end_height is not -1 and when
`start_height` is not zero but end_height is -1.

## Code Health
* Updated [our fork for serializing protobuf as JSON to be based on the
latest version of `google.golang.org/protobuf` instead of the deprecated
Expand Down Expand Up @@ -342,6 +350,7 @@ None
* MG-ng
* Olaoluwa Osuntokun
* Oliver Gugger
* Ononiwu Maureen
* Pierre Beugnet
* Satarupa Deb
* Shaurya Arora
Expand Down
Loading
Loading