From 22dc136ffe9545b462aa4df7aae151c82c921d16 Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Sun, 21 Sep 2025 19:31:00 +0800 Subject: [PATCH] cmd: replace passPHRASE with passWORD in any user interactions #19932 (#1535) --- cmd/XDC/accountcmd.go | 30 +++++++++++++-------------- cmd/XDC/accountcmd_test.go | 42 +++++++++++++++++++------------------- cmd/ethkey/README.md | 19 +++++++---------- cmd/ethkey/message_test.go | 6 +++--- cmd/ethkey/utils.go | 16 +++++++-------- 5 files changed, 54 insertions(+), 59 deletions(-) diff --git a/cmd/XDC/accountcmd.go b/cmd/XDC/accountcmd.go index c19a824122..074da4e92c 100644 --- a/cmd/XDC/accountcmd.go +++ b/cmd/XDC/accountcmd.go @@ -117,11 +117,11 @@ Print a short summary of all accounts`, Creates a new account and prints the address. -The account is saved in encrypted format, you are prompted for a passphrase. +The account is saved in encrypted format, you are prompted for a password. -You must remember this passphrase to unlock your account in the future. +You must remember this password to unlock your account in the future. -For non-interactive use the passphrase can be specified with the --password flag: +For non-interactive use the password can be specified with the --password flag: Note, this is meant to be used for testing only, it is a bad idea to save your password to file or expose in any other way. @@ -144,12 +144,12 @@ password to file or expose in any other way. Update an existing account. The account is saved in the newest version in encrypted format, you are prompted -for a passphrase to unlock the account and another to save the updated file. +for a password to unlock the account and another to save the updated file. This same command can therefore be used to migrate an account of a deprecated format to the newest format or change the password for an account. -For non-interactive use the passphrase can be specified with the --password flag: +For non-interactive use the password can be specified with the --password flag: XDC account update [options]
@@ -177,11 +177,11 @@ Prints the address. The keyfile is assumed to contain an unencrypted private key in hexadecimal format. -The account is saved in encrypted format, you are prompted for a passphrase. +The account is saved in encrypted format, you are prompted for a password. -You must remember this passphrase to unlock your account in the future. +You must remember this password to unlock your account in the future. -For non-interactive use the passphrase can be specified with the -password flag: +For non-interactive use the password can be specified with the -password flag: XDC account import [options] @@ -268,17 +268,17 @@ func getPassPhrase(prompt string, confirmation bool, i int, passwords []string) if prompt != "" { fmt.Println(prompt) } - password, err := prompt2.Stdin.PromptPassword("Passphrase: ") + password, err := prompt2.Stdin.PromptPassword("Password: ") if err != nil { - utils.Fatalf("Failed to read passphrase: %v", err) + utils.Fatalf("Failed to read password: %v", err) } if confirmation { - confirm, err := prompt2.Stdin.PromptPassword("Repeat passphrase: ") + confirm, err := prompt2.Stdin.PromptPassword("Repeat password: ") if err != nil { - utils.Fatalf("Failed to read passphrase confirmation: %v", err) + utils.Fatalf("Failed to read password confirmation: %v", err) } if password != confirm { - utils.Fatalf("Passphrases do not match") + utils.Fatalf("Passwords do not match") } } return password @@ -289,7 +289,7 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr for _, a := range err.Matches { fmt.Println(" ", a.URL) } - fmt.Println("Testing your passphrase against all of them...") + fmt.Println("Testing your password against all of them...") var match *accounts.Account for _, a := range err.Matches { if err := ks.Unlock(a, auth); err == nil { @@ -300,7 +300,7 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr if match == nil { utils.Fatalf("None of the listed files could be unlocked.") } - fmt.Printf("Your passphrase unlocked %s\n", match.URL) + fmt.Printf("Your password unlocked %s\n", match.URL) fmt.Println("In order to avoid this warning, you need to remove the following duplicate key files:") for _, a := range err.Matches { if a != *match { diff --git a/cmd/XDC/accountcmd_test.go b/cmd/XDC/accountcmd_test.go index 30a97a9a8b..0fda6d8502 100644 --- a/cmd/XDC/accountcmd_test.go +++ b/cmd/XDC/accountcmd_test.go @@ -76,8 +76,8 @@ func TestAccountNew(t *testing.T) { XDC.Expect(` Your new account is locked with a password. Please give a password. Do not forget this password. !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foobar"}} -Repeat passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} +Repeat password: {{.InputLine "foobar"}} Your new key was generated @@ -121,9 +121,9 @@ func TestAccountNewBadRepeat(t *testing.T) { XDC.Expect(` Your new account is locked with a password. Please give a password. Do not forget this password. !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "something"}} -Repeat passphrase: {{.InputLine "something else"}} -Fatal: Passphrases do not match +Password: {{.InputLine "something"}} +Repeat password: {{.InputLine "something else"}} +Fatal: Passwords do not match `) } @@ -135,10 +135,10 @@ func TestAccountUpdate(t *testing.T) { XDC.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} Please give a new password. Do not forget this password. -Passphrase: {{.InputLine "foobar2"}} -Repeat passphrase: {{.InputLine "foobar2"}} +Password: {{.InputLine "foobar2"}} +Repeat password: {{.InputLine "foobar2"}} `) } @@ -148,7 +148,7 @@ func TestWalletImport(t *testing.T) { defer XDC.ExpectExit() XDC.Expect(` !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foo"}} +Password: {{.InputLine "foo"}} Address: {xdcd4584b5f6229b7be90727b0fc8c6b91bb427821f} `) @@ -193,7 +193,7 @@ func TestWalletImportBadPassword(t *testing.T) { defer XDC.ExpectExit() XDC.Expect(` !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "wrong"}} +Password: {{.InputLine "wrong"}} Fatal: could not decrypt key with given password `) } @@ -208,7 +208,7 @@ func TestUnlockFlag(t *testing.T) { XDC.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} `) XDC.ExpectExit() @@ -233,11 +233,11 @@ func TestUnlockFlagWrongPassword(t *testing.T) { XDC.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "wrong1"}} +Password: {{.InputLine "wrong1"}} Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 2/3 -Passphrase: {{.InputLine "wrong2"}} +Password: {{.InputLine "wrong2"}} Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 3/3 -Passphrase: {{.InputLine "wrong3"}} +Password: {{.InputLine "wrong3"}} Fatal: Failed to unlock account f466859ead1932d743d622cb74fc058882e8648a (could not decrypt key with given password) `) } @@ -252,9 +252,9 @@ func TestUnlockFlagMultiIndex(t *testing.T) { XDC.Expect(` Unlocking account 0 | Attempt 1/3 !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} Unlocking account 2 | Attempt 1/3 -Passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} `) XDC.ExpectExit() @@ -319,12 +319,12 @@ func TestUnlockFlagAmbiguous(t *testing.T) { XDC.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} Multiple key files exist for address f466859ead1932d743d622cb74fc058882e8648a: keystore://{{keypath "1"}} keystore://{{keypath "2"}} -Testing your passphrase against all of them... -Your passphrase unlocked keystore://{{keypath "1"}} +Testing your password against all of them... +Your password unlocked keystore://{{keypath "1"}} In order to avoid this warning, you need to remove the following duplicate key files: keystore://{{keypath "2"}} `) @@ -356,11 +356,11 @@ func TestUnlockFlagAmbiguousWrongPassword(t *testing.T) { XDC.Expect(` Unlocking account f466859ead1932d743d622cb74fc058882e8648a | Attempt 1/3 !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "wrong"}} +Password: {{.InputLine "wrong"}} Multiple key files exist for address f466859ead1932d743d622cb74fc058882e8648a: keystore://{{keypath "1"}} keystore://{{keypath "2"}} -Testing your passphrase against all of them... +Testing your password against all of them... Fatal: None of the listed files could be unlocked. `) XDC.ExpectExit() diff --git a/cmd/ethkey/README.md b/cmd/ethkey/README.md index cf72ba43d7..08c263c114 100644 --- a/cmd/ethkey/README.md +++ b/cmd/ethkey/README.md @@ -3,39 +3,34 @@ ethkey ethkey is a simple command-line tool for working with Ethereum keyfiles. - # Usage ### `ethkey generate` Generate a new keyfile. -If you want to use an existing private key to use in the keyfile, it can be -specified by setting `--privatekey` with the location of the file containing the +If you want to use an existing private key to use in the keyfile, it can be +specified by setting `--privatekey` with the location of the file containing the private key. - ### `ethkey inspect ` Print various information about the keyfile. Private key information can be printed by using the `--private` flag; make sure to use this feature with great caution! - ### `ethkey sign ` Sign the message with a keyfile. It is possible to refer to a file containing the message. - ### `ethkey verify
` Verify the signature of the message. It is possible to refer to a file containing the message. +## Passwords -## Passphrases - -For every command that uses a keyfile, you will be prompted to provide the -passphrase for decrypting the keyfile. To avoid this message, it is possible -to pass the passphrase by using the `--passphrase` flag pointing to a file that -contains the passphrase. +For every command that uses a keyfile, you will be prompted to provide the +password for decrypting the keyfile. To avoid this message, it is possible +to pass the password by using the `--passwordfile` flag pointing to a file that +contains the password. diff --git a/cmd/ethkey/message_test.go b/cmd/ethkey/message_test.go index c06cf1ffad..ed3a779b5b 100644 --- a/cmd/ethkey/message_test.go +++ b/cmd/ethkey/message_test.go @@ -31,8 +31,8 @@ func TestMessageSignVerify(t *testing.T) { generate := runEthkey(t, "generate", keyfile) generate.Expect(` !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foobar"}} -Repeat passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} +Repeat password: {{.InputLine "foobar"}} `) _, matches := generate.ExpectRegexp(`Address: (xdc[0-9a-fA-F]{40})\n`) address := matches[1] @@ -42,7 +42,7 @@ Repeat passphrase: {{.InputLine "foobar"}} sign := runEthkey(t, "signmessage", keyfile, message) sign.Expect(` !! Unsupported terminal, password will be echoed. -Passphrase: {{.InputLine "foobar"}} +Password: {{.InputLine "foobar"}} `) _, matches = sign.ExpectRegexp(`Signature: ([0-9a-f]+)\n`) signature := matches[1] diff --git a/cmd/ethkey/utils.go b/cmd/ethkey/utils.go index 123a0e6f1c..8cf6879ab7 100644 --- a/cmd/ethkey/utils.go +++ b/cmd/ethkey/utils.go @@ -29,32 +29,32 @@ import ( ) // getPassPhrase obtains a passphrase given by the user. It first checks the -// --passphrase command line flag and ultimately prompts the user for a +// --passfile command line flag and ultimately prompts the user for a // passphrase. func getPassPhrase(ctx *cli.Context, confirmation bool) string { - // Look for the --passphrase flag. + // Look for the --passwordfile flag. passphraseFile := ctx.String(passphraseFlag.Name) if passphraseFile != "" { content, err := os.ReadFile(passphraseFile) if err != nil { - utils.Fatalf("Failed to read passphrase file '%s': %v", + utils.Fatalf("Failed to read password file '%s': %v", passphraseFile, err) } return strings.TrimRight(string(content), "\r\n") } // Otherwise prompt the user for the passphrase. - passphrase, err := prompt.Stdin.PromptPassword("Passphrase: ") + passphrase, err := prompt.Stdin.PromptPassword("Password: ") if err != nil { - utils.Fatalf("Failed to read passphrase: %v", err) + utils.Fatalf("Failed to read password: %v", err) } if confirmation { - confirm, err := prompt.Stdin.PromptPassword("Repeat passphrase: ") + confirm, err := prompt.Stdin.PromptPassword("Repeat password: ") if err != nil { - utils.Fatalf("Failed to read passphrase confirmation: %v", err) + utils.Fatalf("Failed to read password confirmation: %v", err) } if passphrase != confirm { - utils.Fatalf("Passphrases do not match") + utils.Fatalf("Passwords do not match") } } return passphrase