Skip to content

Commit cf6ece4

Browse files
committed
fix: Confirm password when creating wallet
Closes #61
1 parent ad73ffd commit cf6ece4

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cmd/wallet.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,10 +108,23 @@ sure the device is connected, unlocked, and the Spacemesh app is open.`,
108108
}
109109

110110
fmt.Print("Enter a secure password used to encrypt the wallet file (optional but strongly recommended): ")
111-
password, err := password.Read(os.Stdin)
111+
pass, err := password.Read(os.Stdin)
112112
fmt.Println()
113113
cobra.CheckErr(err)
114-
wk := wallet.NewKey(wallet.WithRandomSalt(), wallet.WithPbkdf2Password([]byte(password)))
114+
115+
if pass != "" {
116+
fmt.Print("Confirm your password: ")
117+
confirm, err := password.Read(os.Stdin)
118+
fmt.Println()
119+
cobra.CheckErr(err)
120+
121+
if pass != confirm {
122+
_, _ = fmt.Fprintln(os.Stderr, "Error: Passwords do not match.")
123+
os.Exit(1)
124+
}
125+
}
126+
127+
wk := wallet.NewKey(wallet.WithRandomSalt(), wallet.WithPbkdf2Password([]byte(pass)))
115128
err = os.MkdirAll(common.DotDirectory(), 0o700)
116129
cobra.CheckErr(err)
117130

0 commit comments

Comments
 (0)