diff --git a/cmd/lncli/commands.go b/cmd/lncli/commands.go index e1e511b9..228ca6b4 100644 --- a/cmd/lncli/commands.go +++ b/cmd/lncli/commands.go @@ -161,7 +161,13 @@ var sendCoinsCommand = cli.Command{ Name: "addr", Usage: "the BASE58 encoded bitcoin address to send coins to on-chain", }, - // TODO(roasbeef): switch to BTC on command line? int may not be sufficient + cli.BoolFlag{ + Name: "sweepall", + Usage: "if set, then the amount field will be ignored, " + + "and all the wallet will attempt to sweep all " + + "outputs within the wallet to the target " + + "address", + }, cli.Int64Flag{ Name: "amt", Usage: "the number of bitcoin denominated in satoshis to send", @@ -215,14 +221,18 @@ func sendCoins(ctx *cli.Context) error { amt = ctx.Int64("amt") case args.Present(): amt, err = strconv.ParseInt(args.First(), 10, 64) - default: + case !ctx.Bool("sweepall"): return fmt.Errorf("Amount argument missing") } - if err != nil { return fmt.Errorf("unable to decode amount: %v", err) } + if amt != 0 && ctx.Bool("sweepall") { + return fmt.Errorf("amount cannot be set if attempting to " + + "sweep all coins out of the wallet") + } + ctxb := context.Background() client, cleanUp := getClient(ctx) defer cleanUp() @@ -232,6 +242,7 @@ func sendCoins(ctx *cli.Context) error { Amount: amt, TargetConf: int32(ctx.Int64("conf_target")), SatPerByte: ctx.Int64("sat_per_byte"), + SendAll: ctx.Bool("sweepall"), } txid, err := client.SendCoins(ctxb, req) if err != nil {