diff --git a/cmd/ethkey/changepassphrase.go b/cmd/ethkey/changepassphrase.go index 283803ae4805..530554c007c3 100644 --- a/cmd/ethkey/changepassphrase.go +++ b/cmd/ethkey/changepassphrase.go @@ -10,6 +10,11 @@ import ( "gopkg.in/urfave/cli.v1" ) +var newPassphraseFlag = cli.StringFlag{ + Name: "newpassowrdfile", + Usage: "the file that contains the new passphrase for the keyfile", +} + var commandChangePassphrase = cli.Command{ Name: "changepassphrase", Usage: "change the passphrase on a keyfile", @@ -18,10 +23,7 @@ var commandChangePassphrase = cli.Command{ Change the passphrase of a keyfile.`, Flags: []cli.Flag{ passphraseFlag, - cli.StringFlag{ - Name: "newpassfile", - Usage: "the file that contains the new passphrase for the keyfile", - }, + newPassphraseFlag, }, Action: func(ctx *cli.Context) error { keyfilepath := ctx.Args().First() @@ -42,22 +44,18 @@ Change the passphrase of a keyfile.`, // Get a new passphrase. fmt.Println("Please provide a new passphrase") var newPhrase string - // Look for the --newpassfile flag. - if passFile := ctx.String(passphraseFlag.Name); passFile != "" { + if passFile := ctx.String(newPassphraseFlag.Name); passFile != "" { content, err := ioutil.ReadFile(passFile) if err != nil { - utils.Fatalf("Failed to read new passphrase file '%s': %v", - passFile, err) + utils.Fatalf("Failed to read new passphrase file '%s': %v", passFile, err) } newPhrase = strings.TrimRight(string(content), "\r\n") } else { - // If not present, ask for new passphrase. newPhrase = promptPassphrase(true) } // Encrypt the key with the new passphrase. - newJson, err := keystore.EncryptKey(key, newPhrase, - keystore.StandardScryptN, keystore.StandardScryptP) + newJson, err := keystore.EncryptKey(key, newPhrase, keystore.StandardScryptN, keystore.StandardScryptP) if err != nil { utils.Fatalf("Error encrypting with new passphrase: %v", err) } diff --git a/cmd/ethkey/main.go b/cmd/ethkey/main.go index 607939a98494..f8be3714a4d7 100644 --- a/cmd/ethkey/main.go +++ b/cmd/ethkey/main.go @@ -47,7 +47,7 @@ func init() { // Commonly used command line flags. var ( passphraseFlag = cli.StringFlag{ - Name: "passfile", + Name: "passwordfile", Usage: "the file that contains the passphrase for the keyfile", } jsonFlag = cli.BoolFlag{ diff --git a/cmd/ethkey/utils.go b/cmd/ethkey/utils.go index 9dbb3ccec216..6f60ebaf1beb 100644 --- a/cmd/ethkey/utils.go +++ b/cmd/ethkey/utils.go @@ -49,11 +49,11 @@ func promptPassphrase(confirmation bool) string { return passphrase } -// getPassPhrase obtains a passphrase given by the user. It first checks the +// getPassphrase obtains a passphrase given by the user. It first checks the // --passfile command line flag and ultimately prompts the user for a // passphrase. func getPassphrase(ctx *cli.Context) string { - // Look for the --passfile flag. + // Look for the --passwordfile flag. passphraseFile := ctx.String(passphraseFlag.Name) if passphraseFile != "" { content, err := ioutil.ReadFile(passphraseFile)