Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/goal/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ const (
infoPasswordConfirmation = "Please confirm the password: "
infoCreatingWallet = "Creating wallet..."
infoCreatedWallet = "Created wallet '%s'"
infoUnencrypted = "Creating unencrypted wallet"
infoBackupExplanation = "Your new wallet has a backup phrase that can be used for recovery.\nKeeping this backup phrase safe is extremely important.\nWould you like to see it now? (Y/n): "
infoPrintedBackupPhrase = "Your backup phrase is printed below.\nKeep this information safe -- never share it with anyone!"
infoBackupPhrase = "\n%s"
Expand Down
36 changes: 23 additions & 13 deletions cmd/goal/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ import (
)

var (
recoverWallet bool
defaultWalletName string
recoverWallet bool
createUnencryptedWallet bool
noDisplaySeed bool
defaultWalletName string
)

func init() {
Expand All @@ -45,6 +47,8 @@ func init() {

// Should we recover the wallet?
newWalletCmd.Flags().BoolVarP(&recoverWallet, "recover", "r", false, "Recover the wallet from the backup mnemonic provided at wallet creation (NOT the mnemonic provided by goal account export or by algokey). Regenerate accounts in the wallet with `goal account new`")
newWalletCmd.Flags().BoolVar(&createUnencryptedWallet, "unencrypted", false, "Create a new wallet without a password.")
newWalletCmd.Flags().BoolVar(&noDisplaySeed, "no-display-seed", false, "Create a new wallet without displaying the seed phrase.")
}

var walletCmd = &cobra.Command{
Expand Down Expand Up @@ -113,17 +117,23 @@ var newWalletCmd = &cobra.Command{
}
}

// Fetch a password for the wallet
fmt.Printf(infoChoosePasswordPrompt, walletName)
walletPassword := ensurePassword()
walletPassword := []byte{}

// Confirm the password
fmt.Printf(infoPasswordConfirmation)
passwordConfirmation := ensurePassword()
if createUnencryptedWallet {
reportInfoln(infoUnencrypted)
} else {
// Fetch a password for the wallet
fmt.Printf(infoChoosePasswordPrompt, walletName)
walletPassword = ensurePassword()

// Check the password confirmation
if !bytes.Equal(walletPassword, passwordConfirmation) {
reportErrorln(errorPasswordConfirmation)
// Confirm the password
fmt.Print(infoPasswordConfirmation)
passwordConfirmation := ensurePassword()

// Check the password confirmation
if !bytes.Equal(walletPassword, passwordConfirmation) {
reportErrorln(errorPasswordConfirmation)
}
}

// Create the wallet
Expand All @@ -134,9 +144,9 @@ var newWalletCmd = &cobra.Command{
}
reportInfof(infoCreatedWallet, walletName)

if !recoverWallet {
if !recoverWallet && !noDisplaySeed {
// Offer to print backup seed
fmt.Printf(infoBackupExplanation)
fmt.Println(infoBackupExplanation)
resp, err := reader.ReadString('\n')
resp = strings.TrimSpace(resp)
if err != nil {
Expand Down