forked from cerc-io/plugeth
cmd/ethkey: support --passwordfile in generate command (#21183)
This commit is contained in:
parent
da06519347
commit
45b7535137
@ -51,7 +51,7 @@ Change the password of a keyfile.`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt key with passphrase.
|
// Decrypt key with passphrase.
|
||||||
passphrase := getPassphrase(ctx)
|
passphrase := getPassphrase(ctx, false)
|
||||||
key, err := keystore.DecryptKey(keyjson, passphrase)
|
key, err := keystore.DecryptKey(keyjson, passphrase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Error decrypting key: %v", err)
|
utils.Fatalf("Error decrypting key: %v", err)
|
||||||
|
@ -94,7 +94,7 @@ If you want to encrypt an existing private key, it can be specified by setting
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Encrypt key with passphrase.
|
// Encrypt key with passphrase.
|
||||||
passphrase := promptPassphrase(true)
|
passphrase := getPassphrase(ctx, true)
|
||||||
scryptN, scryptP := keystore.StandardScryptN, keystore.StandardScryptP
|
scryptN, scryptP := keystore.StandardScryptN, keystore.StandardScryptP
|
||||||
if ctx.Bool("lightkdf") {
|
if ctx.Bool("lightkdf") {
|
||||||
scryptN, scryptP = keystore.LightScryptN, keystore.LightScryptP
|
scryptN, scryptP = keystore.LightScryptN, keystore.LightScryptP
|
||||||
|
@ -60,7 +60,7 @@ make sure to use this feature with great caution!`,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt key with passphrase.
|
// Decrypt key with passphrase.
|
||||||
passphrase := getPassphrase(ctx)
|
passphrase := getPassphrase(ctx, false)
|
||||||
key, err := keystore.DecryptKey(keyjson, passphrase)
|
key, err := keystore.DecryptKey(keyjson, passphrase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Error decrypting key: %v", err)
|
utils.Fatalf("Error decrypting key: %v", err)
|
||||||
|
@ -62,7 +62,7 @@ To sign a message contained in a file, use the --msgfile flag.
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Decrypt key with passphrase.
|
// Decrypt key with passphrase.
|
||||||
passphrase := getPassphrase(ctx)
|
passphrase := getPassphrase(ctx, false)
|
||||||
key, err := keystore.DecryptKey(keyjson, passphrase)
|
key, err := keystore.DecryptKey(keyjson, passphrase)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
utils.Fatalf("Error decrypting key: %v", err)
|
utils.Fatalf("Error decrypting key: %v", err)
|
||||||
|
@ -52,7 +52,7 @@ func promptPassphrase(confirmation bool) string {
|
|||||||
// 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
|
// --passfile command line flag and ultimately prompts the user for a
|
||||||
// passphrase.
|
// passphrase.
|
||||||
func getPassphrase(ctx *cli.Context) string {
|
func getPassphrase(ctx *cli.Context, confirmation bool) string {
|
||||||
// Look for the --passwordfile flag.
|
// Look for the --passwordfile flag.
|
||||||
passphraseFile := ctx.String(passphraseFlag.Name)
|
passphraseFile := ctx.String(passphraseFlag.Name)
|
||||||
if passphraseFile != "" {
|
if passphraseFile != "" {
|
||||||
@ -65,7 +65,7 @@ func getPassphrase(ctx *cli.Context) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Otherwise prompt the user for the passphrase.
|
// Otherwise prompt the user for the passphrase.
|
||||||
return promptPassphrase(false)
|
return promptPassphrase(confirmation)
|
||||||
}
|
}
|
||||||
|
|
||||||
// signHash is a helper function that calculates a hash for the given message
|
// signHash is a helper function that calculates a hash for the given message
|
||||||
|
Loading…
Reference in New Issue
Block a user