console: use keypad based pinpad (Trezor request)

This commit is contained in:
Péter Szilágyi
2017-08-14 12:21:40 +03:00
parent 5d9ac49c7e
commit 02656f9f61

View File

@ -110,20 +110,15 @@ func (b *bridge) OpenWallet(call otto.FunctionCall) (response otto.Value) {
} }
// Trezor PIN matrix input requested, display the matrix to the user and fetch the data // Trezor PIN matrix input requested, display the matrix to the user and fetch the data
fmt.Fprintf(b.printer, "Look at the device for number positions\n\n") fmt.Fprintf(b.printer, "Look at the device for number positions\n\n")
fmt.Fprintf(b.printer, "a | b | c\n") fmt.Fprintf(b.printer, "7 | 8 | 9\n")
fmt.Fprintf(b.printer, "--+---+--\n") fmt.Fprintf(b.printer, "--+---+--\n")
fmt.Fprintf(b.printer, "d | e | f\n") fmt.Fprintf(b.printer, "4 | 5 | 6\n")
fmt.Fprintf(b.printer, "--+---+--\n") fmt.Fprintf(b.printer, "--+---+--\n")
fmt.Fprintf(b.printer, "g | h | i\n\n") fmt.Fprintf(b.printer, "1 | 2 | 3\n\n")
if input, err := b.prompter.PromptPassword("Please enter current PIN: "); err != nil { if input, err := b.prompter.PromptPassword("Please enter current PIN: "); err != nil {
throwJSException(err.Error()) throwJSException(err.Error())
} else { } else {
// Transform the alphabetical input to numbers
mapping := map[string]string{"a": "7", "b": "8", "c": "9", "d": "4", "e": "5", "f": "6", "g": "1", "h": "2", "i": "3"}
for from, to := range mapping {
input = strings.Replace(input, from, to, -1)
}
passwd, _ = otto.ToValue(input) passwd, _ = otto.ToValue(input)
} }
if val, err = call.Otto.Call("jeth.openWallet", nil, wallet, passwd); err != nil { if val, err = call.Otto.Call("jeth.openWallet", nil, wallet, passwd); err != nil {