Fix mnemonic input to not echo to screen
Changed mnemonic input to use secure non-echoing input like passphrases: - Use secret.ReadPassphrase() instead of readLineFromStdin() - Add newline after hidden input for better UX - Remove unused stdin reading functions from cli.go This prevents sensitive mnemonic phrases from being displayed on screen during input, matching the security behavior of passphrase input.
This commit is contained in:
@@ -60,14 +60,17 @@ func (cli *Instance) Init(cmd *cobra.Command) error {
|
||||
mnemonicStr = envMnemonic
|
||||
} else {
|
||||
secret.Debug("Prompting user for mnemonic phrase")
|
||||
// Read mnemonic from stdin using shared line reader
|
||||
var err error
|
||||
mnemonicStr, err = readLineFromStdin("Enter your BIP39 mnemonic phrase: ")
|
||||
// Read mnemonic securely without echo
|
||||
mnemonicBuffer, err := secret.ReadPassphrase("Enter your BIP39 mnemonic phrase: ")
|
||||
if err != nil {
|
||||
secret.Debug("Failed to read mnemonic from stdin", "error", err)
|
||||
|
||||
return fmt.Errorf("failed to read mnemonic: %w", err)
|
||||
}
|
||||
defer mnemonicBuffer.Destroy()
|
||||
|
||||
mnemonicStr = mnemonicBuffer.String()
|
||||
fmt.Fprintln(os.Stderr) // Add newline after hidden input
|
||||
}
|
||||
|
||||
if mnemonicStr == "" {
|
||||
|
||||
Reference in New Issue
Block a user