Add password length validation on create CLI

In this commit we add this validation importing
the walletunlocker.ValidatePassword function on
create wallet command.
This commit is contained in:
Francisco Calderón
2019-02-21 11:25:42 -03:00
parent 4de9ffdf7b
commit 9e920f12c9
2 changed files with 13 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ import (
"github.com/golang/protobuf/jsonpb"
"github.com/golang/protobuf/proto"
"github.com/lightningnetwork/lnd/lnrpc"
"github.com/lightningnetwork/lnd/walletunlocker"
"github.com/urfave/cli"
"golang.org/x/crypto/ssh/terminal"
"golang.org/x/net/context"
@@ -265,7 +266,7 @@ var listUnspentCommand = cli.Command{
confirmations. Use --min_confs=0 to include unconfirmed coins. To list
all coins with at least min_confs confirmations, omit the second
argument or flag '--max_confs'. To list all confirmed and unconfirmed
coins, no arguments are required. To see only unconfirmed coins, use
coins, no arguments are required. To see only unconfirmed coins, use
'--unconfirmed_only' with '--min_confs' and '--max_confs' set to zero or
not present.
`,
@@ -1334,6 +1335,13 @@ func create(ctx *cli.Context) error {
return fmt.Errorf("passwords don't match")
}
// If the password length is less than 8 characters, then we'll
// return an error.
pwErr := walletunlocker.ValidatePassword(pw1)
if pwErr != nil {
return pwErr
}
// Next, we'll see if the user has 24-word mnemonic they want to use to
// derive a seed within the wallet.
var (