diff --git a/cmd/goal/messages.go b/cmd/goal/messages.go index 1bc78ce30a..21d4e4f503 100644 --- a/cmd/goal/messages.go +++ b/cmd/goal/messages.go @@ -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" diff --git a/cmd/goal/wallet.go b/cmd/goal/wallet.go index e95aea62a6..1033a8a00f 100644 --- a/cmd/goal/wallet.go +++ b/cmd/goal/wallet.go @@ -32,8 +32,10 @@ import ( ) var ( - recoverWallet bool - defaultWalletName string + recoverWallet bool + createUnencryptedWallet bool + noDisplaySeed bool + defaultWalletName string ) func init() { @@ -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{ @@ -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 @@ -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 {