Skip to content

Commit 45b7535

Browse files
authored
cmd/ethkey: support --passwordfile in generate command (#21183)
1 parent da06519 commit 45b7535

5 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎cmd/ethkey/changepassword.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Change the password of a keyfile.`,
5151
}
5252

5353
// Decrypt key with passphrase.
54-
passphrase := getPassphrase(ctx)
54+
passphrase := getPassphrase(ctx, false)
5555
key, err := keystore.DecryptKey(keyjson, passphrase)
5656
if err != nil {
5757
utils.Fatalf("Error decrypting key: %v", err)

‎cmd/ethkey/generate.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ If you want to encrypt an existing private key, it can be specified by setting
9494
}
9595

9696
// Encrypt key with passphrase.
97-
passphrase := promptPassphrase(true)
97+
passphrase := getPassphrase(ctx, true)
9898
scryptN, scryptP := keystore.StandardScryptN, keystore.StandardScryptP
9999
if ctx.Bool("lightkdf") {
100100
scryptN, scryptP = keystore.LightScryptN, keystore.LightScryptP

‎cmd/ethkey/inspect.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ make sure to use this feature with great caution!`,
6060
}
6161

6262
// Decrypt key with passphrase.
63-
passphrase := getPassphrase(ctx)
63+
passphrase := getPassphrase(ctx, false)
6464
key, err := keystore.DecryptKey(keyjson, passphrase)
6565
if err != nil {
6666
utils.Fatalf("Error decrypting key: %v", err)

‎cmd/ethkey/message.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ To sign a message contained in a file, use the --msgfile flag.
6262
}
6363

6464
// Decrypt key with passphrase.
65-
passphrase := getPassphrase(ctx)
65+
passphrase := getPassphrase(ctx, false)
6666
key, err := keystore.DecryptKey(keyjson, passphrase)
6767
if err != nil {
6868
utils.Fatalf("Error decrypting key: %v", err)

‎cmd/ethkey/utils.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func promptPassphrase(confirmation bool) string {
5252
// getPassphrase obtains a passphrase given by the user. It first checks the
5353
// --passfile command line flag and ultimately prompts the user for a
5454
// passphrase.
55-
func getPassphrase(ctx *cli.Context) string {
55+
func getPassphrase(ctx *cli.Context, confirmation bool) string {
5656
// Look for the --passwordfile flag.
5757
passphraseFile := ctx.String(passphraseFlag.Name)
5858
if passphraseFile != "" {
@@ -65,7 +65,7 @@ func getPassphrase(ctx *cli.Context) string {
6565
}
6666

6767
// Otherwise prompt the user for the passphrase.
68-
return promptPassphrase(false)
68+
return promptPassphrase(confirmation)
6969
}
7070

7171
// signHash is a helper function that calculates a hash for the given message

0 commit comments

Comments
 (0)