Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds the missing prompt_pin and send_pin commands mentioned here (backup appears to have already been implemented FYI).
Adding these commands required some refactoring-
They need to be called on an
HWIDevice
struct, initialized viaget_client
, however as things areHWIDevice
requires aFingerprint
to initialise it, which is not available when the device is in a locked state. Therefore I have updated its type toOption<Fingerprint>,
withNone
being the value when in a locked state.This also required some refactoring of the conversion of
HWIDeviceInternal
toHWIDevice
via theTryFrom
trait.when using the python HWI implementation accessing these commands is done by calling:
./hwi.py enumerate
from the command line, which returns:
[{"type": "trezor", "path": "webusb:001:1:3", "label": "My Trezor", "model": "trezor_1", "needs_pin_sent": true, "needs_passphrase_sent": false, "error": "Could not open client or get fingerprint information: Trezor is locked. Unlock by using 'promptpin' and then 'sendpin'.", "code": -12}]
you would then reference the path referenced in this error and enter
./hwi.py -t trezor -d webusb:001:1:2 promptpin
to correctly call the
promptpin
command.However in Rust HWI paths are not directly specified, and as things currently are the occurance of all Errors will prevent conversion from
HWIDeviceInternal
toHWIDevice
, and instead return an error which contains only the error message and code ([Err(Hwi("Could not open client or get fingerprint information: Trezor is locked. Unlock by using 'promptpin' and then 'sendpin'.", Some(-12)))]
in the example above).After playing around with a few approaches the cleanest and simplest to my eyes is what I have implemented here- an if statement to let this specific error pass, and then a match statement to either return the error in all other instances, or initialise the struct with the correct
Fingerprint
value.