Commit graph

230 commits

Author SHA1 Message Date
SomberNight
b1d2389656
hww: stop keystore.thread when closing wallet
previously left running? Qt on macOS was complaining:
```
QThread: Destroyed while thread is still running
Abort trap: 6
```
2020-04-17 19:53:42 +02:00
SomberNight
2cfa3bd6c8
hww hidapi usage: try to mitigate some thread-safety issues
related: #6097
2020-04-17 19:53:39 +02:00
SomberNight
98d2ab5bd6
hww: fix HardwareClientBase not having reference to plugin
it was incorrectly documented that it did (previously only for some plugins)
2020-04-17 19:53:35 +02:00
SomberNight
10c358dd38
bitbox02: rm plugin.get_client method: just use default impl 2020-04-12 15:34:19 +02:00
SomberNight
dda20583c2
bitbox02: rm BitBox02Client.label override
if placeholder anyway, just use base impl
(alternatively we should list it in electrum.plugin.PLACEHOLDER_HW_CLIENT_LABELS)
2020-04-12 15:34:19 +02:00
SomberNight
e830ef309f
hww: factor out part of hid scan code to HW_PluginBase
so that bitbox02 can override it
2020-04-12 15:34:19 +02:00
SomberNight
66c264f613
bitcoin.py: change API of address_to_hash 2020-04-12 15:34:19 +02:00
SomberNight
cc4aa1812d
rm some unused imports 2020-04-12 15:34:19 +02:00
SomberNight
ffe3cef21a
bitbox02: don't run show_xpub on GUI thread 2020-04-12 15:34:19 +02:00
SomberNight
0268b63fcb
bitbox02: rm some dead code 2020-04-12 15:34:19 +02:00
SomberNight
15102855c1
bitbox02: fix pairing_dialog 2020-04-12 15:34:19 +02:00
SomberNight
c0c3627bd2
bitbox02: adapt to updated master 2020-04-12 15:34:19 +02:00
TheCharlatan
a4fe14bb82
BitBox02 Electrum plugin support
This commit adds support for the BitBox02 hardware wallet.
It supports both single and multisig for the electrum gui wallet.

To use the plugin a local installation of the BitBox02 python library is
required. It can be found on PiPy under the name 'bitbox02' and can be
installed from the bitbox02-firmware repository in the py/bitbox02
directory.

All communication to and from the BitBox02 is noise encrypted, the keys
required for this are stored in the wallet config file under the
bitbox02 key.

The BitBox02 registers a multisig configuration before allowing
transaction signing. This multisig configuration includes the threshold,
cosigner xpubs, keypath, a variable to indicate for mainnet and testnet,
and a name that the user can choose during configuration registration.
The user is asked to register the multisig configuration either during
address verification or during transaction signing.

The check the xpub of the BitBox02 for other hardware wallets, a button
is added in the wallet info dialog.

The wallet encryption key is fetched in a separate api call, requiring a
slightly tweaked override version of the wallet encryption password.
2020-04-12 15:34:37 +02:00
SomberNight
4b1d835304
wizard hww: scan devices fewer times and move away from GUI thread 2020-04-09 19:45:31 +02:00
SomberNight
bf067f7558
HardwareClientBase: provide default implementation for label
and add warning about placeholders
2020-04-08 18:28:21 +02:00
SomberNight
db1ff4915f
hww: show model name in device enum lists (e.g. "Trezor T") 2020-04-08 17:53:40 +02:00
SomberNight
4ef313a1ac
hww: smarter auto-selection of which device to pair with
scenario1:
- 2of2 multisig wallet with trezor1 and trezor2 keystores
- only trezor2 connected
- previously we would pair first keystore with connected device and then display error.
  now we will pair the device with the correct keystore on the first try

scenario2:
- standard wallet with trezor1 keystore
- trezor2 connected (different device)
- previously we would pair trezor2 with the keystore and then display error.
  now we will prompt the user to select which device to pair with (out of one)

related: #5789
2020-04-08 17:53:33 +02:00
SomberNight
9d0bb295e6
hww: distinguish devices based on "soft device id" (not just labels)
fixes #5759
2020-04-08 14:44:42 +02:00
SomberNight
caefea19dd
trezor pin dialog: only show PIN "strength" when creating/changing
fixes #4832
2020-04-07 18:58:45 +02:00
SomberNight
c798e5d9a1
qt: introduce PasswordLineEdit(QLineEdit) 2020-04-07 18:58:37 +02:00
ghost43
4d980cd4bd
Merge pull request #6064 from matejcik/trezor-0.12-passphrase
trezor: bump lib version, implement new passphrase-on-device UI
2020-04-06 17:53:59 +00:00
SomberNight
fb5382f75f
follow-up prev (typo) 2020-04-06 19:49:56 +02:00
SomberNight
371f55a0f9
hww: fix some threading issues in wizard
fixes #3377
related: #6064  (passphrase dialog not rendered correctly)
2020-04-01 21:09:17 +02:00
SomberNight
81fc3fcce2
hww: rm some code duplication: add "scan_and_create_client_for_device" 2020-04-01 21:09:14 +02:00
SomberNight
e6d43b60fa
qt hww show_settings_dialog: don't scan devices in GUI thread
Just makes sense in general.
Also, previously, the GUI would freeze if right after startup the user
clicked the hww status bar icon (especially with multiple hww connected).
2020-04-01 21:09:06 +02:00
SomberNight
276631fab7
digitalbitbox: (trivial) user handler instead of handler.win 2020-04-01 21:09:03 +02:00
SomberNight
7f1c7955dc
DeviceMgr: clean-up locks a bit 2020-04-01 21:09:00 +02:00
SomberNight
e68b6447cc
hww: catch exceptions when user clicks on hww qt status bar icon
E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 167, in perform_hw1_preflight
    firmwareInfo = self.dongleObject.getFirmwareVersion()
  File "...\Python38\site-packages\btchip\btchip.py", line 561, in getFirmwareVersion
    response = self.dongle.exchange(bytearray(apdu))
  File "...\Python38\site-packages\btchip\btchipComm.py", line 127, in exchange
    raise BTChipException("Invalid status %04x" % sw, sw)
btchip.btchipException.BTChipException: Exception : Invalid status 6faa

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\main_window.py", line 120, in onPress
    self.func()
  File "...\electrum\electrum\plugins\hw_wallet\qt.py", line 260, in show_settings_dialog
    device_id = self.choose_device(window, keystore)
  File "...\electrum\electrum\plugins\hw_wallet\qt.py", line 253, in choose_device
    info = self.device_manager().select_device(self, keystore.handler, keystore)
  File "...\electrum\electrum\plugin.py", line 554, in select_device
    infos = self.unpaired_device_infos(handler, plugin, devices)
  File "...\electrum\electrum\plugin.py", line 545, in unpaired_device_infos
    soft_device_id=client.get_soft_device_id()))
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 88, in get_soft_device_id
    self._soft_device_id = self.request_root_fingerprint_from_device()
  File "...\electrum\electrum\plugins\hw_wallet\plugin.py", line 197, in request_root_fingerprint_from_device
    child_of_root_xpub = self.get_xpub("m/0'", xtype='standard')
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 55, in catch_exception
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 103, in get_xpub
    self.checkDevice()
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 210, in checkDevice
    self.perform_hw1_preflight()
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 198, in perform_hw1_preflight
    raise UserFacingException("Dongle is temporarily locked - please unplug it and replug it again")
electrum.util.UserFacingException: Dongle is temporarily locked - please unplug it and replug it again
2020-04-01 21:08:50 +02:00
SomberNight
2d3c2eeea9
keystore: add workaround for StoredDict issue #6066
note: not a proper fix... but works for now
2020-04-01 13:33:38 +02:00
SomberNight
18d245ad5c
hw wallets: during wallet creation, make sure to save correct label
When initialising a Trezor as part of the wallet creation,
device_info.label is still the old (None) label in on_hw_derivation.
This is because device_info was created during the initial scan.

related: #6063
2020-03-31 15:56:54 +02:00
SomberNight
7297e94970
hw wallets: handle cancellation for "query_choice" in wizard
E | gui.qt.exception_window.Exception_Hook | exception caught by crash reporter
Traceback (most recent call last):
  File "...\electrum\electrum\plugins\hw_wallet\qt.py", line 193, in win_query_choice
    self.choice = self.win.query_choice(msg, labels)
  File "...\electrum\electrum\gui\qt\installwizard.py", line 545, in query_choice
    self.exec_layout(vbox, '')
  File "...\electrum\electrum\gui\qt\installwizard.py", line 392, in exec_layout
    raise UserCancelled
electrum.util.UserCancelled
2020-03-31 15:11:10 +02:00
SomberNight
6760c3f252
hw wallets: introduce HardwareHandlerBase
previously, client.handler was sometimes
- an InstallWizard
- a QtHandlerBase where win was an ElectrumWindow
- a QtHandlerBase where win was an InstallWizard
- a CmdLineHandler

That's just too much dynamic untyped undocumented polymorphism...
Now it will never be an InstallWizard (replaced with QtHandlerBase where win is an InstallWizard),
and now in all cases client.handler is an instance of HardwareHandlerBase, yay.

related: #6063
2020-03-31 14:40:25 +02:00
matejcik
4cd50dd75a trezor: bump lib version, implement new passphrase-on-device UI 2020-03-31 12:26:48 +02:00
SomberNight
f8ba660583
clean-up hw-wallet "get_password_for_storage_encryption"-related code 2020-02-28 19:47:56 +01:00
SomberNight
22861b70ee
Qt tx dialog: make "export with xpubs" option always available
not just if one of the keystores is a coldcard

related: https://github.com/spesmilo/electrum/issues/5969#issuecomment-591441399
2020-02-27 03:14:13 +01:00
SomberNight
36629f0957
cosigner_pool plugin: don't show button in tx dialog before finalizing
(previously button would be shown for a watch-only multisig wallet)
2020-02-23 20:38:57 +01:00
SomberNight
7f8d667e85
Revert "qt/hww: temporarily bundle our own version of safetlib.qt.pinmatrix"
This reverts commit 7f3de8241c.

(can finally undo this due to bb94712a14)
2020-02-21 18:32:58 +01:00
ThomasV
9a462ac9b5 trustedcoin: fix wallet constructor 2020-02-20 20:59:18 +01:00
SomberNight
9c5e49f432
ecc.ECPubkey: also accept bytearray in __init__
regression since #5947

Traceback (most recent call last):
  File "...\electrum\electrum\base_wizard.py", line 339, in on_device
    self.plugin.setup_device(device_info, self, purpose)
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 598, in setup_device
    client.get_xpub("m/44'/0'", 'standard') # TODO replace by direct derivation once Nano S > 1.1
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 55, in catch_exception
    return func(self, *args, **kwargs)
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 124, in get_xpub
    eckey=ecc.ECPubkey(publicKey),
  File "...\electrum\electrum\ecc.py", line 145, in __init__
    self._x, self._y = _x_and_y_from_pubkey_bytes(b)
  File "...\electrum\electrum\ecc.py", line 119, in _x_and_y_from_pubkey_bytes
    ret = _libsecp256k1.secp256k1_ec_pubkey_parse(
ctypes.ArgumentError: argument 3: <class 'TypeError'>: wrong type
2020-02-19 00:40:33 +01:00
SomberNight
07f5d6b745
keystore: 'get_tx_derivations' no longer public 2020-02-12 18:14:00 +01:00
ThomasV
e1ce3aace7 Separate db from storage
- storage is content-agnostic
 - db and storage are passed to wallet contructor
2020-02-10 17:45:23 +01:00
SomberNight
34392e82b9
cosigner pool: easy fix (works but with worse than previous behaviour)
got broken as part of PSBT changes in #5721
2020-02-07 20:09:40 +01:00
ThomasV
dbceed2647 Restructure wallet storage:
- Perform json deserializations in wallet_db
 - use StoredDict class that keeps tracks of its modifications
2020-02-04 13:35:58 +01:00
SomberNight
d2f132738a
wallet: only select mature coins by default
this is a regression from #5721

Removed the `TxInput.is_coinbase` method as I think it is a confusing API,
instead we now have `TxInput.is_coinbase_input` and `TxInput.is_coinbase_output`.

related #5872
2020-01-02 00:43:49 +01:00
SomberNight
a8e81c0bd2
keepkey: use libusb to enumerate devices instead of hid 2019-12-20 01:30:10 +01:00
SomberNight
18209fc782
trezor: when restoring, hide Shamir options by default
They become visible once user clicks "Show expert settings"
2019-12-19 16:50:35 +01:00
matejcik
006c6c1a58 trezor: use BIP39 backup by default even if Shamir is available 2019-12-18 12:36:13 +01:00
matejcik
da41e4c289 trezor: bump library requirement 2019-12-18 12:36:13 +01:00
matejcik
3fc70bd97a trezor: implement support for Shamir recovery 2019-12-18 12:36:13 +01:00
matejcik
f4e2781786 trezor: link button messages to enum names 2019-12-18 12:36:13 +01:00