mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-05-21 01:00:15 +02:00
cmd/lncli: add confirmation to sendcoins
This commit is contained in:
parent
63b32b9e4a
commit
3a5d67a16b
@ -23,6 +23,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/routing/route"
|
"github.com/lightningnetwork/lnd/routing/route"
|
||||||
"github.com/lightningnetwork/lnd/signal"
|
"github.com/lightningnetwork/lnd/signal"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
|
"golang.org/x/term"
|
||||||
"google.golang.org/grpc/codes"
|
"google.golang.org/grpc/codes"
|
||||||
"google.golang.org/grpc/status"
|
"google.golang.org/grpc/status"
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -302,6 +303,14 @@ var sendCoinsCommand = cli.Command{
|
|||||||
"must satisfy",
|
"must satisfy",
|
||||||
Value: defaultUtxoMinConf,
|
Value: defaultUtxoMinConf,
|
||||||
},
|
},
|
||||||
|
cli.BoolFlag{
|
||||||
|
Name: "force, f",
|
||||||
|
Usage: "if set, the transaction will be broadcast " +
|
||||||
|
"without asking for confirmation; this is " +
|
||||||
|
"set to true by default if stdout is not a " +
|
||||||
|
"terminal avoid breaking existing shell " +
|
||||||
|
"scripts",
|
||||||
|
},
|
||||||
txLabelFlag,
|
txLabelFlag,
|
||||||
},
|
},
|
||||||
Action: actionDecorator(sendCoins),
|
Action: actionDecorator(sendCoins),
|
||||||
@ -364,6 +373,19 @@ func sendCoins(ctx *cli.Context) error {
|
|||||||
"sweep all coins out of the wallet")
|
"sweep all coins out of the wallet")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ask for confirmation if we're on an actual terminal and the output is
|
||||||
|
// not being redirected to another command. This prevents existing shell
|
||||||
|
// scripts from breaking.
|
||||||
|
if !ctx.Bool("force") && term.IsTerminal(int(os.Stdout.Fd())) {
|
||||||
|
fmt.Printf("Amount: %d\n", amt)
|
||||||
|
fmt.Printf("Destination address: %v\n", addr)
|
||||||
|
|
||||||
|
confirm := promptForConfirmation("Confirm payment (yes/no): ")
|
||||||
|
if !confirm {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
client, cleanUp := getClient(ctx)
|
client, cleanUp := getClient(ctx)
|
||||||
defer cleanUp()
|
defer cleanUp()
|
||||||
|
|
||||||
|
@ -115,6 +115,13 @@ unlock or create.
|
|||||||
|
|
||||||
* Added ability to use [ENV variables to override `lncli` global flags](https://github.com/lightningnetwork/lnd/pull/7693). Flags will have preference over ENVs.
|
* Added ability to use [ENV variables to override `lncli` global flags](https://github.com/lightningnetwork/lnd/pull/7693). Flags will have preference over ENVs.
|
||||||
|
|
||||||
|
* The `lncli sendcoins` command now asks for manual confirmation when invoked
|
||||||
|
on the command line. This can be skipped by adding the `--force` (or `-f`)
|
||||||
|
flag, similar to how `lncli payinvoice` works. To not break any existing
|
||||||
|
scripts the confirmation is also skipped if `stdout` is not a terminal/tty
|
||||||
|
(e.g. when capturing the output in a shell script variable or piping the
|
||||||
|
output to another program).
|
||||||
|
|
||||||
## Bug Fix
|
## Bug Fix
|
||||||
|
|
||||||
* Make sure payment stream returns all the events by [subscribing it before
|
* Make sure payment stream returns all the events by [subscribing it before
|
||||||
|
Loading…
x
Reference in New Issue
Block a user