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

Fix input sanitation for listchaintxns lncli cmd #9558

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
22 changes: 18 additions & 4 deletions cmd/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -2248,7 +2248,7 @@ 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 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 @@ -2267,10 +2267,24 @@ func listChainTxns(ctx *cli.Context) error {
MaxTransactions: uint32(ctx.Uint64("max_transactions")),
}

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 > endHeight {
return errors.New("start_height should " +
"be less 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"))
}

Expand Down
4 changes: 4 additions & 0 deletions docs/release-notes/release-notes-0.19.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@

## lncli Updates

* [Added](https://github.com/lightningnetwork/lnd/pull/9558) additional
guardrails to the listchaintxns command to make behavior match docs.

## Code Health

* [Add retry logic](https://github.com/lightningnetwork/lnd/pull/8381) for
Expand Down Expand Up @@ -390,6 +393,7 @@ The underlying functionality between those two options remain the same.
* Nishant Bansal
* Oliver Gugger
* Pins
* kornpow
* Viktor Tigerström
* Yong Yu
* Ziggie
Loading