Commit Graph

369 Commits

Author SHA1 Message Date
Andrew Chow
2dc818c026 Use new importmulti array range format 2019-03-01 17:19:31 -05:00
Andrew Chow
8d738ee31c
Merge #125: Test how the CLI deals with really big transactions
1a2b67d Test how a very large transaction is handled (Andrew Chow)
c69c0ee Add travis job for cli interface test (Andrew Chow)
e594a0b Allow specifiying a different interface for using HWI in tests (Andrew Chow)

Pull request description:

  It was mentioned in the #bitcoin-core-dev IRC channel a few days ago that really big transactions can cause problems if it was entered as an argument in the shell. This PR adds to the test suite the option to run the tests with different interfaces to allow us to test this. It can use the "library" interface which is what we currently do. This interface calls `process_commands` directly. The `cli` interface uses `subprocess` to run the `hwi` command in the shell to test the command line interface. This will emulate entering a command in the shell. This allows us to test the big transaction case which has been added. This case only tests the interface and not whether the transaction is signed. This test should pass when using the `library` interface but not when using the `cli`. Both interfaces will also be tested on travis as separate jobs.

Tree-SHA512: 47c85c3b4df66aaa552dc55028267024ea53a56f8028bc0e161fd390ea3e96166f3d9157f320bbf922c63fd5726f13c3918c75cbd3a1311c1536477c0605dcee
2019-02-28 21:47:56 -05:00
Andrew Chow
9bc8bdc106
Merge #133: Fix Digital Bitbox tests for API changes
6c9964e Fix Digital Bitbox tests for API changes (Andrew Chow)

Pull request description:

  The Digital Bitbox API changed slightly which broke our tests due to the ordering of some operations. Normal usage is still fine. This fixes the test.

Tree-SHA512: bed658d935f6833c7f6e656f35edf5d123edf54a0dfd42383a65a9f178a556d07c84f930bc93e42b3df0b5b79b05e43e12a18042a2401c7040183472bfd6ddb6
2019-02-28 13:12:37 -05:00
Andrew Chow
6c9964ef84 Fix Digital Bitbox tests for API changes
The Digital Bitbox API changed slightly which broke our tests due to
the ordering of some operations. Normal usage is still fine.
2019-02-25 16:03:50 -05:00
Andrew Chow
ca9f0106cd
Merge #132: ledger: check keypath format for getxpub
6e1e9aa ledger: check keypath format for getxpub (Gregory Sanders)

Pull request description:

  Currently does none.

Tree-SHA512: 0219a415db038be0e40b5fda2798a000dce71a33d89265adfdf47f4e3a2c66b8d80238bb74688a68da146461e08f95bd08be6390ffecf13b3e704d1365787326
2019-02-19 12:26:18 -05:00
Andrew Chow
1a2b67d1f3 Test how a very large transaction is handled 2019-02-19 10:21:58 -05:00
Andrew Chow
c69c0ee920 Add travis job for cli interface test 2019-02-19 10:21:58 -05:00
Andrew Chow
e594a0b4b3 Allow specifiying a different interface for using HWI in tests 2019-02-19 10:21:58 -05:00
Andrew Chow
75a915edba
Merge #130: Implement descriptor checksums
2d62204 Use descriptors with checksums in TestSignTx (Andrew Chow)
c2ff20b Use descriptor class in getkeypool (Andrew Chow)
f2aff4d Add descriptor checksums and tests (Andrew Chow)

Pull request description:

  Adds checksums to the Descriptor class. Checksums are optional, but if provided, must be valid. `getkeypool` is also changed to use the descriptor class to return checksums. Tests are updated so that all descriptors used have checksums.

  Closes #129

Tree-SHA512: f77b44a1edbc02d4dc6130fb4f6a97aadf2f12fef90f4b93e734df7374decb060e5486f0a5a03074aa696f6af3c772a52380bbce3ef045042e00597791aacbd1
2019-02-19 10:19:51 -05:00
Gregory Sanders
6e1e9aaacf ledger: check keypath format for getxpub 2019-02-19 10:17:22 -05:00
Andrew Chow
c5524d60cc
Merge #131: travis: fix bitcoind update
ff8e257 travis: fix bitcoind update (Andrew Chow)

Pull request description:

  Currently travis is not working correctly because it isn't updating bitcoind when upstream changes. This fixes that.

Tree-SHA512: 9354324402d8dcfefbd65ceb79ed9811bc773ddbf266a9072528095c07e8f2b09136b7e607dac779d84996a0a3168907aa31fc45efaf7c2a580987d333f23766
2019-02-18 17:18:14 -05:00
Andrew Chow
ff8e257839 travis: fix bitcoind update 2019-02-18 17:17:01 -05:00
Andrew Chow
2d622046ce Use descriptors with checksums in TestSignTx 2019-02-17 18:11:18 -05:00
Andrew Chow
c2ff20bf61 Use descriptor class in getkeypool 2019-02-17 17:46:45 -05:00
Andrew Chow
f2aff4d642 Add descriptor checksums and tests 2019-02-17 17:41:45 -05:00
Andrew Chow
dba7acd5ed
Merge #127: Update things now that Bitcoin Core master is usable
aac8243 Update Bitcoin Core usage docs (Andrew Chow)
daa99c7 Change to building from bitcoin master (Andrew Chow)

Pull request description:

  Updates `setup_environment.sh` to build Bitcoin Core master branch instead of my hww branch.

  Updates the Bitcoin Core usage documentation.

Tree-SHA512: f7a9f2c6cb10f67cfc8b4a8a757d37e2ef8c37e26d5297215e6c8612780496b476d41c614106286813141b1278173094149df2b34a02fc64a71aec844fb081dc
2019-02-15 15:06:01 -05:00
Andrew Chow
03b31bec00
Merge #117: Descriptor support for displayaddress
a71658c displayaddress: descriptor support, make --path a named argument (Sjors Provoost)
163f926 Add descriptor class (Sjors Provoost)
6fc1524 HardwareWalletClient: store fingerprint (Sjors Provoost)

Pull request description:

  Adds a `Descriptor` class, which currently handles some of the descriptor functionality.

  Changes `displayaddress` to allow a descriptor argument. This means `--path` and `--desc` are now named arguments.

  When using a descriptor  `displayaddress` performs additional checks to make sure the fingerprint and xpub match. To enable the fingerprint check, I'm storing the fingerprint on `HardwareWalletClient` instances.

Tree-SHA512: f149481203c340b8e5347f42fd2924f1b2095197d6c25f39f94acfb11f430881412cce48c510260db4e773b662e8b2a0a747c413ba7fadfc6eb78a85f1ec4838
2019-02-15 15:03:48 -05:00
Andrew Chow
aac8243579 Update Bitcoin Core usage docs
Master has everything, all PRs have been merged into master
2019-02-15 14:54:52 -05:00
Sjors Provoost
a71658cf6d
displayaddress: descriptor support, make --path a named argument 2019-02-15 08:44:41 +01:00
Andrew Chow
daa99c7ea3 Change to building from bitcoin master 2019-02-15 00:36:04 -05:00
Sjors Provoost
163f926d52
Add descriptor class 2019-02-14 09:35:17 +01:00
Sjors Provoost
6fc1524217
HardwareWalletClient: store fingerprint 2019-02-14 09:35:16 +01:00
Andrew Chow
0ec664dba7
Merge #120: Replace device libraries with stripped down versions
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
2019-02-14 01:02:11 -05:00
Andrew Chow
7c0fd1e06d Update dependencies in the readme 2019-02-14 00:49:18 -05:00
Andrew Chow
681a52d3da Replace btchip-python with our own stripped down version of it 2019-02-12 17:26:27 -05:00
Andrew Chow
f7d04ff2eb Replace ckcc dependency with our own version of the library itself 2019-02-12 17:26:27 -05:00
Andrew Chow
f0c5aa7d3c Add Keepkey to Trezorlib and have KeepkeyClient use TrezorClient 2019-02-12 17:26:27 -05:00
Andrew Chow
2693ae34f6 Change TrezorClient to do what TrezorNoInit did 2019-02-12 17:26:27 -05:00
Andrew Chow
aa3665c971 Replace trezorlib with our own stripped down version 2019-02-12 17:26:27 -05:00
Andrew Chow
754adc93dc
Merge #122: Do basic keypath check for display/signmessage for ledger
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
2019-02-12 17:24:11 -05:00
Andrew Chow
1790a01804
Merge #118: Add more tests and related fixes
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
2019-02-12 16:57:43 -05:00
Gregory Sanders
3e52a4f87a Do basic keypath check for display/signmessage for ledger 2019-02-12 16:35:13 -05:00
Andrew Chow
a38e993607 Tests and fixes for remaining Ledger commands
Tests and fixes for promptpin, sendpin, setup, wipe, restore, backup,
and signmessage commands
2019-02-10 10:45:29 -05:00
Andrew Chow
d627634ce6 Tests and fixes for remainig Keepkey commands.
Tests for setup, wipe, restore, backup, promptpin, sendpin
2019-02-10 10:45:29 -05:00
Andrew Chow
cf152b709a Tests and fixes for remaining Trezor commands
Tests and fixes for Trezor signmessage, setup, wipe, backup, promptpin, and sendpin
2019-02-10 10:45:29 -05:00
Andrew Chow
40abbc2927 Tests and fixes for remaining Digital Bitbox commands
Adds tests for setup, wipe, backup, restore, displayaddress,
promptpin, and sendpin.
2019-02-10 10:45:29 -05:00
Andrew Chow
0085b8fd2c Tests and fixes remaining commands for Coldcard
Tests and fixes for promptpin, sendpin, and restore and backup commands on Coldcard
2019-02-10 10:45:29 -05:00
Andrew Chow
5c54c0f6ee Add tests and fixes for invalid paths 2019-02-10 10:45:29 -05:00
Andrew Chow
a7d0121c7b Tests for nonexistent fingerprints and device types 2019-02-10 10:45:29 -05:00
Andrew Chow
cd0c994d6d Test signtx with all three output types as tx outputs 2019-02-10 10:45:29 -05:00
Andrew Chow
a1b36e2121 Remove several unused functions 2019-02-10 10:45:29 -05:00
Andrew Chow
6349dd149c
Merge #116: Handle all exceptions so that none are shown to the user
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
2019-02-07 20:49:38 -05:00
Andrew Chow
b2035856cf Handle Ledger error codes 2019-02-04 10:04:30 -05:00
Andrew Chow
7a8e38c78c Handle Digital Bitbox errors 2019-02-04 10:04:30 -05:00
Andrew Chow
d279a7e21c Handle KeepKey bad arguments 2019-02-04 10:04:30 -05:00
Andrew Chow
7de7e543a6 Handle Coldcard canceled actions and bad arguments 2019-02-04 10:04:30 -05:00
Andrew Chow
4e49da29ad Handle Trezor canceled actions and bad arguments to trezorlib 2019-02-04 10:04:30 -05:00
Andrew Chow
9d52695699 Add ActionCanceledError, DeviceConnectionError, DeviceBusyError 2019-02-04 10:04:30 -05:00
Andrew Chow
0a809b2754 Handle errors to have cli output always be JSON
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.
2019-02-04 10:04:30 -05:00
Andrew Chow
4c3a6df1b7 Use HWWErrors instead of built-ins 2019-02-04 10:04:30 -05:00