Merge pull request #2244 from nspcc-dev/dont-panic-on-stdin-ioctl-issues
Dont panic on stdin ioctl issues
This commit is contained in:
commit
49149afecf
4 changed files with 10 additions and 10 deletions
|
@ -27,7 +27,7 @@ func ReadLine(prompt string) (string, error) {
|
|||
if trm == nil {
|
||||
s, err := term.MakeRaw(syscall.Stdin)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", err
|
||||
}
|
||||
defer func() { _ = term.Restore(syscall.Stdin, s) }()
|
||||
trm = term.NewTerminal(ReadWriter{
|
||||
|
@ -52,7 +52,7 @@ func ReadPassword(prompt string) (string, error) {
|
|||
if trm == nil {
|
||||
s, err := term.MakeRaw(syscall.Stdin)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
return "", err
|
||||
}
|
||||
defer func() { _ = term.Restore(syscall.Stdin, s) }()
|
||||
trm = term.NewTerminal(ReadWriter{os.Stdin, os.Stdout}, prompt)
|
||||
|
|
|
@ -813,7 +813,7 @@ func getUnlockedAccount(wall *wallet.Wallet, addr util.Uint160) (*wallet.Account
|
|||
rawPass, err := input.ReadPassword(
|
||||
fmt.Sprintf("Enter account %s password > ", address.Uint160ToString(addr)))
|
||||
if err != nil {
|
||||
return nil, cli.NewExitError(err, 1)
|
||||
return nil, cli.NewExitError(fmt.Errorf("Error reading password: %w", err), 1)
|
||||
}
|
||||
pass := strings.TrimRight(string(rawPass), "\n")
|
||||
err = acc.Decrypt(pass, wall.Scrypt)
|
||||
|
|
|
@ -205,7 +205,7 @@ func getDecryptedAccount(ctx *cli.Context, wall *wallet.Wallet, addr util.Uint16
|
|||
}
|
||||
|
||||
if pass, err := input.ReadPassword("Password > "); err != nil {
|
||||
fmt.Println("ERROR", pass, err)
|
||||
fmt.Println("Error reading password", err)
|
||||
return nil, err
|
||||
} else if err := acc.Decrypt(pass, wall.Scrypt); err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -302,7 +302,7 @@ func convertWallet(ctx *cli.Context) error {
|
|||
for _, acc := range wall.Accounts {
|
||||
pass, err := input.ReadPassword(fmt.Sprintf("Enter passphrase for account %s (label '%s') > ", acc.Address, acc.Label))
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
return cli.NewExitError(fmt.Errorf("Error reading password: %w", err), 1)
|
||||
}
|
||||
newAcc, err := acc.convert(pass, wall.Scrypt)
|
||||
if err != nil {
|
||||
|
@ -372,7 +372,7 @@ loop:
|
|||
if decrypt {
|
||||
pass, err := input.ReadPassword("Enter password > ")
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
return cli.NewExitError(fmt.Errorf("Error reading password: %w", err), 1)
|
||||
}
|
||||
|
||||
pk, err := keys.NEP2Decrypt(wif, pass, wall.Scrypt)
|
||||
|
@ -567,7 +567,7 @@ func dumpWallet(ctx *cli.Context) error {
|
|||
if ctx.Bool("decrypt") {
|
||||
pass, err := input.ReadPassword("Enter wallet password > ")
|
||||
if err != nil {
|
||||
return cli.NewExitError(err, 1)
|
||||
return cli.NewExitError(fmt.Errorf("Error reading password: %w", err), 1)
|
||||
}
|
||||
for i := range wall.Accounts {
|
||||
// Just testing the decryption here.
|
||||
|
@ -656,11 +656,11 @@ func readAccountInfo() (string, string, error) {
|
|||
rawName, _ := input.ReadLine("Enter the name of the account > ")
|
||||
phrase, err := input.ReadPassword("Enter passphrase > ")
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
return "", "", fmt.Errorf("Error reading password: %w", err)
|
||||
}
|
||||
phraseCheck, err := input.ReadPassword("Confirm passphrase > ")
|
||||
if err != nil {
|
||||
return "", "", err
|
||||
return "", "", fmt.Errorf("Error reading password: %w", err)
|
||||
}
|
||||
|
||||
if phrase != phraseCheck {
|
||||
|
@ -692,7 +692,7 @@ func newAccountFromWIF(w io.Writer, wif string, scrypt keys.ScryptParams) (*wall
|
|||
if len(wif) == 58 {
|
||||
pass, err := input.ReadPassword("Enter password > ")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("Error reading password: %w", err)
|
||||
}
|
||||
|
||||
return wallet.NewAccountFromEncryptedWIF(wif, pass, scrypt)
|
||||
|
|
Loading…
Reference in a new issue