-
Notifications
You must be signed in to change notification settings - Fork 20.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accounts, console, internal: support trezor hardware wallet #14885
Conversation
673bc6e
to
e4e7111
Compare
console/bridge.go
Outdated
throwJSException(err.Error()) | ||
} 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"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use
+ fmt.Fprintf(b.printer, "7 | 8 | 9\n")
+ fmt.Fprintf(b.printer, "--+---+--\n")
+ fmt.Fprintf(b.printer, "4 | 5 | 6\n")
+ fmt.Fprintf(b.printer, "--+---+--\n")
+ fmt.Fprintf(b.printer, "1 | 2 | 3\n\n")
above and skip this step?
This is exactly the scheme used in python-trezor
and most of the CLI users are already used to that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That was my original code but @nagydani suggested we use something else to ensure users don't type in their real PINs accidentally. Though after using both schemes, the a-b-c one in indeed annoying, whereas the keypad version can be typed in without looking at the keyboard. So it may indeed be a better approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Gustav-Simonsson Do you have an opinion on this one? (Pinging you since you explicitly reacted to the PIN pad on twitter :D)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because using numerics for both unencrypted and encrypted PIN might confuse users into entering the unencrypted PIN on the console or making some other mistake. It is good to keep the distinction by using a different alphabet, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nagydani @prusnak Given that multiple people already requested the classical keypad pinpad, I've added a new commit to revert to that. My main reasoning was that with the keypad, it's simple to look at the device pinpad and enter your pin, whereas with the alphabetical one it's a PITA to map the numbers to letters.
I've also tried to look into mapping to q-w-e / a-s-d / z-x-c but that requires keyboard layout detection, which I couldn't do meaningfully easily. All in all I think the keypad should be fine too.
Question: What are the events that should trigger adding new addresses to Otherwise, the code is tidy and readable and none of the implemented functionality showed any erroneous behavior with the possible exception of adding accounts from the Trezor. |
I'm unsure what you mean by not correct. Accounts are auto-derived from the base path:
If an account has a non zero balance or non zero nonce, it will be added to the list of tracked accounts, and the next one is derived too. The account list is refreshed whenever balance changes are detected. |
@nagydani You can also see the logic in the log I posted in the PR description:
|
Also note, there's a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR in its present form works with Trezor correctly and I am satisfied with the implementation. Could not verify Ledger support regressions, as I do not have that HW.
Thank you, Péter! |
Just to be clear, any "gap" in activity in your accounts will prevent discovery of later accounts, right? Like:
(where "activity" is a nonzero balance or nonce) This seems reasonable, just wanted to be sure I understood. |
Yes, that is correct according to BIP44.
|
On OSX, how do you find the URL? It's not documented anywhere, but maybe it is a bug. The url shown is not correct and/or truncated.
personal.openWallet("trezor://IOServiceAppleACPIPl") gets you a 'Error: unknown wallet' error. |
You can list all the details with |
I'm on geth 1.8/go 1.9.2, running latest High Sierra. |
Checked in console mode instead of attach and work fine now. |
Also, geth automatically hijacks the process, so you can't use it with MEW or the Chrome plugin with geth running, which is annoying because I want to keep Swarm and geth running 24/7. |
@woodydeck I'm experiencing the same thing. I'm trying to use a locally running MEW with my local node but because Geth instantly tries to connect no other process can connect with the Trezor. Is there any way around this? |
@karalabe I dug around a bit on the geth/trezor integration and I wonder if it's still working (specifically I'm trying to get ethsign to work with trezor which relies on it being accessible in geth). I manage to enter the pin in geth console but I don't understand where and how to enter the passphrase (which is required after entering the pin) |
I have not implemented passwords for the Trezor. Didn't know that that was a generally desired use case. Will do when I get to integrating the Trezor T. |
@karalabe Excellent to know the plan to implement passwords for the Trezor, thanks! |
Any plan to implement local Hardware Wallets (Trezor/Ledger) recognition from an attached ws/rpc geth instance? Is this functionality already implemented? IMHO It seems an interesting use case. You could attach to a remote node via ws/rpc (avoiding the consumption of local resources) without losing the ability to continue using your local USB connected Ledger or Trezor from the awesome geth console. |
Added Hardware Wallets support wiki entry at forked repo. |
This PR adds support for the Trezor hardware wallet. Plain message signing is not yet supported as each wallet has a different spec for the signatures (#14794). I'll add that when an EIP is opened and a consensus is reached on how to sign arbitrary messages.
Opposed to the Ledger, the Trezor is a bit more complicated as it requires a PIN-unlock sent from the communicating machine instead of directly input by the user. As such, when a user plugs in a Trezor, Geth will print the following warning:
WARN [08-10|11:55:19] New wallet appeared, failed to open url=trezor://0003:0007:00 err="trezor: pin needed"
Opening the Trezor from Geth
The Geth console can be used to unlock the Trezor by invoking
personal.openWallet(url)
, which will request the user to enter the shuffled PIN code and send that over to the Trezor for verification:Opening the Trezor from RPC
The Trezor can also be unlocked via remote RPC methods (to support external UI wallets) by calling
personal_openWallet
with the parameters[url, pin]
.If
pin == ""
, the Trezor is attempted to be opened without a PIN, which will either succeed (if it was already opened before), or it will display a PIN pad on the device and return atrezor: pin needed
error. The UI doing the opening should react to this error by displaying a PIN entry UI element, and after reading the code from the user, callpersonal_openWallet
again, withpin
set to the user's input corresponding to a keyboard numpad layout (7-8-9 / 4-5-6 / 1-2-3).Listing the Trezor wallets
The available Trezor (and other) wallets can be listed via
personal_listWallets
, which will also auto-derive Ethereum accounts which have non-zero balances or nonces: