7c0fd1e Update dependencies in the readme (Andrew Chow)
681a52d Replace btchip-python with our own stripped down version of it (Andrew Chow)
f7d04ff Replace ckcc dependency with our own version of the library itself (Andrew Chow)
f0c5aa7 Add Keepkey to Trezorlib and have KeepkeyClient use TrezorClient (Andrew Chow)
2693ae3 Change TrezorClient to do what TrezorNoInit did (Andrew Chow)
aa3665c Replace trezorlib with our own stripped down version (Andrew Chow)
Pull request description:
This PR replaces all of the device libraries (`trezor`, `keepkey`, `ckcc-protocol,` and `btchip-python`) with stripped down versions of them directly in the source tree. These stripped down versions have several unused functions removed, including support for outdated hardware (e.g. Ledger HW.1) and altcoins. Some additional modifications have been made to them in order to make our implementations cleaner and easier to understand.
One major part of this change is replacing the Keepkey implementation with the Trezor implementation entirely. I found during testing that the Keepkey and Trezor use largely the same protocol. Some parts were different but those did not affect our usage of the Keepkey and the Trezor, so those differences were removed and reconciled. This allows us to have only one library which serves both the Trezor and Keepkey and have just one implementation that works for both Trezor and Keepkey.
Overall, by replacing the vendor provided libraries with our own versions of them, we are able to reduce the total number of dependencies required, and reduce some possible implementation errors (e.g. it would be a simple mistake to let Trezor or Keepkey do their default behavior of phoning home to fetch previous transactions). We can also make changes to the lower level implementations as needed instead of waiting on changes and fixes to be merged into upstream libraries.
This PR is based on #118 so that everything that was changed could be tested.
Tree-SHA512: 2e8e581ebf533a9306d76edfff607d6c5fe85f3764e80015b03638abb15edc76f174b013a64604d3b3e70dacf8b70d00c5a1484702d4fbb7c26625dd18da54dc
3e52a4f Do basic keypath check for display/signmessage for ledger (Gregory Sanders)
Pull request description:
This causes me to pass tests locally.
Tree-SHA512: 604bac8362b565f7ab07bf10e65fb704add9aa6ebf70b09e496bdfd823b3399c417557d1c74a0fe280fe2276b33b3c8c620aba6540a356f6e3df00cccdc29989
a38e993 Tests and fixes for remaining Ledger commands (Andrew Chow)
d627634 Tests and fixes for remainig Keepkey commands. (Andrew Chow)
cf152b7 Tests and fixes for remaining Trezor commands (Andrew Chow)
40abbc2 Tests and fixes for remaining Digital Bitbox commands (Andrew Chow)
0085b8f Tests and fixes remaining commands for Coldcard (Andrew Chow)
5c54c0f Add tests and fixes for invalid paths (Andrew Chow)
a7d0121 Tests for nonexistent fingerprints and device types (Andrew Chow)
cd0c994 Test signtx with all three output types as tx outputs (Andrew Chow)
a1b36e2 Remove several unused functions (Andrew Chow)
Pull request description:
Adds tests for nearly all commands for all devices and related fixes. Only `restore` for `trezor` and `keepkey` are untested as I could not get them to work. All other commands for all devices have tests and related bug fixes.
Tree-SHA512: 2c49e0fce037955f1a10ed24664f7eabae8a7db6803ac3afc296c9a2763ba8f91c5e2bc598847719a1cad82f8afaad352eaf98aa4a3e1aa0475d5f6efab5b9c3
b203585 Handle Ledger error codes (Andrew Chow)
7a8e38c Handle Digital Bitbox errors (Andrew Chow)
d279a7e Handle KeepKey bad arguments (Andrew Chow)
7de7e54 Handle Coldcard canceled actions and bad arguments (Andrew Chow)
4e49da2 Handle Trezor canceled actions and bad arguments to trezorlib (Andrew Chow)
9d52695 Add ActionCanceledError, DeviceConnectionError, DeviceBusyError (Andrew Chow)
0a809b2 Handle errors to have cli output always be JSON (Andrew Chow)
4c3a6df Use HWWErrors instead of built-ins (Andrew Chow)
b4a95a6 subclass specific errors so codes and error messages are easy to get (Andrew Chow)
32e56c7 consolidate errors to errors.py (Andrew Chow)
Pull request description:
This PR adds `except` statements around the main command function to catch any and all exceptions and output the correct error code and message. Additional exceptions and error codes are added for new types of errors. Any exception thrown by a library will be caught and converted into the correct type of exception so that the correct message and code can be returned. This change makes it so that users using the command line tool should never see a backtrace.
This removes from the main `commands.py` file handling of exceptions. Instead those functions (which are intended for use as a library in other software) will throw the exceptions and the caller can handle them.
Tree-SHA512: 88dc0bc576c98e5df09635bf624efcac88a214a09493cd4012333d12c04529999c9ed0c46aac42693b05a2f43ddd7e7b5a157734328ed10ea6bd591a2f28ea6e
Handle HWWErrors generically when the command is invoked in
process_commands. The library functions that used to handle the
errors will instead raise the exceptions.
All exceptions possible are handled, with unknown ones resulting
in an UNKNOWN_ERROR code.
Moves the specific error exceptions to a subclass of a new HWWError.
HWWError has methods that make it easy to get the error message and
code generically for all exceptions
00e30c8 Always close clients if they exist (Andrew Chow)
Pull request description:
Tree-SHA512: ee84310f5d926322fb6a4fbba7bcaf57cb32265aff4ff12f9a9a9fe098ec52be58f45f0e1c80b28a5faad1bc2085d95edfbdf03484999cefa354279f22361efa
bd8840d Change links to bitcoin-core (Andrew Chow)
Pull request description:
The repo migrated to bitcoin-core, so changing things that referred to the old location to point to the new one.
Tree-SHA512: a80c1c57e67e9bc15fd9adc650bfe0d0db00d9df1132bedf75151d5bed910675c7110c25ca7ea6452d661dec7801ce056870182f5662d5093218e3dc1e70ece8
97b1d35 Add promptpin and sendpin commands (Andrew Chow)
bb88cc5 Introduce and implement prompt_pin and send_pin methods (Andrew Chow)
Pull request description:
This PR introduces two new commands, `promptpin` and `sendpin`, which only work on Trezors and KeepKeys. `promptpin` triggers the device to display the prompt for entering the PIN. `sendpin` takes the scrambled PIN as an argument and sends it to the device. The device will then cache the pin if it is correct.
The way that the libraries setup the client classes prevents us from doing this. To work around that, I made subclasses of those client classes which do not do the initialization call that breaks this process. Instead, the initialization call will be done by each function individually if it needs it.
Closes#83
Tree-SHA512: 0aa9d135eeceef63b41c1e20efbf7439d5bf9a26f84b66da3c0602952894aa9a659bb5a9b2780b0506578a2b61049233db588cabfc0da8ed10dacd91d97c7f99
Only the Trezor and KeepKey need to have a PIN entered. However this
PIN entering is canceled if the device is re-initialized which happens
every time the client is created. To work around this, a client
subclass for each is introduced which does not initialize the device
on creation. Instead device initialization is done at the beginning
of each call which requires it. At that time, a check is also done
to ensure that the device has the PIN cached. This allows for
send_pin to actually be able to send the PIN after promptpin.
5ea8831 Document Keepkey emulator build instructions (Andrew Chow)
af52908 Use Digital Bitbox's repo for simulator (Andrew Chow)
64ebad3 Use keepkey from PyPi (Andrew Chow)
Pull request description:
Keepkey has updated their PyPi to have their latest library version, so switch things to using that instead of using a specific commit from their repo.
The Digital Bitbox simulator was merged into the upstream repo so use that instead of my own branch for it.
Also added documentation for building the Keepkey emulator.
Tree-SHA512: 6dce47dacd510f0ab6cafeed712c10ac939c2e9c6554c73c9a7696459f3bf8732f173d6758035841201169a8a4c99a35493df3e470f1c973af93e699260d7187
8e4b3fc Add executable script to setup.py and bump version number (Andrew Chow)
2ddd4ed Refactor to make hwilib more like a library (Andrew Chow)
Pull request description:
Refactors `command.py` so that it just has the functions for each command and the arguments are the actual arguments for the command instead of `args` and `client`. `process_commands` has been moved to `cli.py` along with the handlers that take `args` and `client` which then call the functions in `commands.py` to do the command.
`setup.py` has been updated to also install a `hwi` executable script and the version number is bumped to 0.0.5.
This makes HWI actually usable as a library while also having the command line functionality.
Completes part 1 of #91
Tree-SHA512: 73c36f79b3f28140f1600cd263325d2fffc422b759884bccb613f0ca922d76801973a41fbd52cba0b4142f19f97ac465cfe7277748e4511cadc461f16ba3026c
Moves the command argument parsing to hwi.py. Instead of each function
taking args and client, they now take client and whatever else they
need. hwi.py handles the conversion from args and client to the actual
arguments.
653592c Move prompts to stderr (Andrew Chow)
Pull request description:
Instead of printing prompts to stdout, print them to stderr. When used on the command line, the prompts will be seen by the user. But using stderr means that external callers of the command can ignore that output and only use the actual output from stdout.
The Trezor and Keepkey prompts already go to stderr.
Tree-SHA512: 2e988df1cb4299a08374844095be7acb040349eb05a2e06e20c0edff2694d00abfb6ed12a294720755f9d6e45340bbe6841e077d6564efac36255e034b3f351b
8b9d068 Ledger firmware doesn't support mixed input types during signing pass (Gregory Sanders)
Pull request description:
You can theoretically sign but requires that all inputs are given as non-segwit UTXO, so not compliant with BIP174.
Tree-SHA512: d774ca552391508dad9b7fdf4f2e55548eb1c6e6abe05656e96a83f57effaffde3b1feb59bd9d8616b10f4e9c005094af9bad693851284951fce78758792c4e1
Instead of printing prompts to stdout, print them to stderr. When
used on the command line, the prompts will be seen by the user.
But using stderr means that external callers of the command can
ignore that output and only use the actual output from stdout.
0b870d8 Document how to build the simulator (Andrew Chow)
8f1dff2 Change Digital Bitbox test to use simulator (Andrew Chow)
07c9771 Build digital bitbox simulator in setup_environment.sh (Andrew Chow)
814d02d Implement support for communicating with a dbb simulator (Andrew Chow)
Pull request description:
This PR changes the current manual Digital Bitbox tests into an automated test. This uses the [simulator that I wrote](https://github.com/achow101/mcu/blob/simulator/src/simulator.c) (which is also [PR'd](https://github.com/digitalbitbox/mcu/pull/253) to Digital Bitbox).
Built on #104
Tree-SHA512: 582afa5e045c1e222064958b1b9dda17db7025dd5ff3f8a64a826abe92631b0dd808fcded501bedec7fc1d8ef4c386c99212ff1b182d149e182ea472f65d92ea