Commit graph

245 commits

Author SHA1 Message Date
SomberNight
7a6ec23b6e
cosigner pool: use single thread to send messages
ServerProxy does not seem to be thread-safe.
For e.g. a 2of3 multisig wallet, which would send two messages,
one msg would get sent but the other might error out. See trace:

E | plugins.cosigner_pool.qt.Plugin | on_failure
Traceback (most recent call last):
  File "...\electrum\electrum\gui\qt\util.py", line 832, in run
    result = task.task()
  File "...\electrum\electrum\plugins\cosigner_pool\qt.py", line 199, in <lambda>
    task = lambda: server.put(_hash, message)
  File "...\Python38\lib\xmlrpc\client.py", line 1109, in __call__
    return self.__send(self.__name, args)
  File "...\Python38\lib\xmlrpc\client.py", line 1450, in __request
    response = self.__transport.request(
  File "...\Python38\lib\xmlrpc\client.py", line 1153, in request
    return self.single_request(host, handler, request_body, verbose)
  File "...\Python38\lib\xmlrpc\client.py", line 1165, in single_request
    http_conn = self.send_request(host, handler, request_body, verbose)
  File "...\Python38\lib\xmlrpc\client.py", line 1271, in send_request
    connection.putrequest("POST", handler, skip_accept_encoding=True)
  File "...\Python38\lib\http\client.py", line 1088, in putrequest
    raise CannotSendRequest(self.__state)
http.client.CannotSendRequest: Request-sent
2020-06-29 02:19:03 +02:00
SomberNight
1a9e6a434f
cosigner pool: user certifi instead of system ssl cert store
related: https://github.com/spesmilo/electrum/issues/5678#issuecomment-650837465
2020-06-29 02:15:01 +02:00
SomberNight
eb39aa143b
try fixing email plugin 2020-06-13 19:12:22 +02:00
SomberNight
0b224ba685
invoices: minor clean-up (type hints, mark broken things)
also rm some dead code
2020-06-13 18:54:22 +02:00
ghost43
8e12b43b5d
Merge pull request #6199 from benma/bb02
plugins/bitbox02: fix compatibility with bitbox02-3.0.0
2020-06-04 17:43:11 +00:00
SomberNight
db5cf22ff4
bitbox02: get prev tx from psbt instead of wallet db
- for symmetry with other plugins
- and because this is a superset. txin.utxo gets populated from the wallet db (or network);
  but the wallet db does not import txs from txin.utxo (so if a psbt already had an
  unknown tx there, it will not get imported)
2020-06-04 19:41:34 +02:00
SomberNight
dc6dbe5bfb
HW_PluginBase: small clean-up for 'maximum_library' 2020-06-04 18:52:08 +02:00
SomberNight
309ba15745
invoices: follow-up fixes re clean-up
follow-up 6058829870 and related
2020-06-03 21:00:03 +02:00
matejcik
e058ee2957
psbt: always include full prev tx (#6198)
* enable streaming full UTXOs for all types of inputs

Co-authored-by: SomberNight <somber.night@protonmail.com>
2020-06-03 18:03:12 +00:00
Marko Bencun
b9b08b768f
plugins/bitbox02: fix min version check
Inform the user that they need to upgrade if their firmware version is
out of date.

The previous `check_device_firmware_version()` was dead code, and the
bb02 function called inside also does not exist.
2020-06-03 15:36:15 +02:00
Marko Bencun
b863150fe3
plugins/bitbox02: fix compatibility with bitbox02-3.0.0 2020-06-03 15:35:43 +02:00
SomberNight
4a4b0922e5
trustedcoin: (trivial) add a stub method in plugin base class 2020-05-29 20:51:52 +02:00
SomberNight
e6e587b7da
trustedcoin: use psbt format on wire. rm psbt to legacy tx conversion.
closes #6123
2020-05-29 18:58:30 +02:00
SomberNight
24221f8fca
plugins: fix labels plugin FIXME re "just enabled plugin" 2020-05-25 17:31:13 +02:00
SomberNight
41aa50a3f3
coldcard: log exception traceback in create_client
related: https://github.com/Coldcard/ckcc-protocol/pull/9
2020-05-13 18:11:53 +02:00
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