Skip to content

Commit

Permalink
fix: Confirm password when creating wallet
Browse files Browse the repository at this point in the history
Closes #61
  • Loading branch information
0xjac committed Jul 12, 2023
1 parent ad73ffd commit cc05f2b
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions cmd/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,22 @@ sure the device is connected, unlocked, and the Spacemesh app is open.`,
}

fmt.Print("Enter a secure password used to encrypt the wallet file (optional but strongly recommended): ")
password, err := password.Read(os.Stdin)
pass, err := password.Read(os.Stdin)
fmt.Println()
cobra.CheckErr(err)
wk := wallet.NewKey(wallet.WithRandomSalt(), wallet.WithPbkdf2Password([]byte(password)))

if pass != "" {
fmt.Print("Confirm your password: ")
confirm, err := password.Read(os.Stdin)
fmt.Println()
cobra.CheckErr(err)

if pass != confirm {
log.Fatalln("Error: Passwords do not match.")
}
}

wk := wallet.NewKey(wallet.WithRandomSalt(), wallet.WithPbkdf2Password([]byte(pass)))
err = os.MkdirAll(common.DotDirectory(), 0o700)
cobra.CheckErr(err)

Expand Down

0 comments on commit cc05f2b

Please sign in to comment.