Commit graph

262 commits

Author SHA1 Message Date
ghost43
21c3572600
hardware devices: run all device communication on dedicated thread (#6561)
hidapi/libusb etc are not thread-safe.

related: #6554
2020-09-08 15:52:53 +00:00
SomberNight
a7199696d3
json_db: exempt keystore from StoredDict conversion
The keystore logic would need to be significantly changed to nicely
interoperate with StoredDict/json_db logic.
(just see KeyStore.__init__() and KeyStore.dump())
For now we exempt the keystore from the recursive StoredDict conversion, as
it is a smaller change that is also easier to review for correctness.

fixes #6066
fixes #6401

also reverts 2d3c2eeea9 (which was an even hackier workaround for #6066)
2020-09-04 16:11:01 +02:00
SomberNight
f36cc5b6e0
trezor: cache whether TrezorBridge is available to speedup scan_devices
If the Bridge is unavailable, on my machine it takes 2 seconds to timeout.
i.e. call_bridge("enumerate") and BridgeTransport.enumerate() both take 2 seconds each.
With this change, if the Bridge is unavailable, DeviceMgr.scan_devices() takes 4 seconds less.
In below log, with 6 different hw devices connected, scan time was originally ~7.5 seconds;
with this change it became ~3.5 seconds.

Now the time is dominated by WebUsbTransport.enumerate(), called by Trezor,
KeepKey, SafeT, ~1.1 seconds each.

-----

I | plugin.DeviceMgr | scan_devices() entered. 1598666278.6756
I | plugin.DeviceMgr | scan_devices(). _scan_devices_with_hid() DONE. 1598666278.7583
I | plugin.DeviceMgr | scan_devices(). starting custom enumeration loop. 1598666278.7593
I | plugin.DeviceMgr | scan_devices(). custom enumeration iter DONE, for <bound method SafeTPlugin.enumerate of <electrum.plugins.safe_t.qt.Plugin object at 0x000001F60060A730>>. 1598666279.9345
I | plugins.trezor.qt.Plugin | trezor custom enumeration entered. 1598666279.9345
I | plugins.trezor.qt.Plugin | trezor custom enumeration. call_bridge('enumerate') DONE. 1598666281.9385
>> trezorlib enumerating <class 'trezorlib.transport.bridge.BridgeTransport'> DONE at 1598666283.9500.
>> trezorlib enumerating <class 'trezorlib.transport.webusb.WebUsbTransport'> DONE at 1598666285.0427.
>> trezorlib enumerating <class 'trezorlib.transport.hid.HidTransport'> DONE at 1598666285.1198.
>> trezorlib enumerating <class 'trezorlib.transport.udp.UdpTransport'> DONE at 1598666285.1237.
I | plugins.trezor.qt.Plugin | trezor custom enumeration. trezorlib.transport.enumerate_devices() DONE. 1598666285.1257
I | plugin.DeviceMgr | scan_devices(). custom enumeration iter DONE, for <bound method TrezorPlugin.enumerate of <electrum.plugins.trezor.qt.Plugin object at 0x000001F60C16F4C0>>. 1598666285.1257
I | plugin.DeviceMgr | scan_devices(). custom enumeration iter DONE, for <bound method KeepKeyPlugin.enumerate of <electrum.plugins.keepkey.qt.Plugin object at 0x000001F60BADF130>>. 1598666286.2251
I | plugin.DeviceMgr | scan_devices(). custom enumeration iter DONE, for <bound method ColdcardPlugin.detect_simulator of <electrum.plugins.coldcard.qt.Plugin object at 0x000001F60BAA5AC0>>. 1598666286.2251
I | plugin.DeviceMgr | scan_devices(). custom enumeration loop DONE. 1598666286.2251
I | plugin.DeviceMgr | scan_devices(). find out what was disconnected DONE. 1598666286.2251
I | plugin.DeviceMgr | scan_devices(). Unpair disconnected devices DONE. 1598666286.2251
2020-08-29 04:22:55 +02:00
SomberNight
c313c702fd
qt wallet>info: use QStackedWidget, one stack item for each keystore
Instead of single mpk_text widget for each ks and changing the contents
when switching, create an mpk_text widget for each ks and switch between those.
This allows putting the "show xpub on device" button inside mpk_text.
2020-08-28 20:10:58 +02:00
matejcik
a669c6b765
trezor: use init_device instead of ping to check connection (fixes #6457) (#6471) 2020-08-25 14:34:42 +00:00
aaronisme
3ed5f32c6c fix the coldcard multi-sig show address issue 2020-08-18 15:42:39 +08:00
Marko Bencun
061305cd97
bitbox02: add fingerprint to label
See comment in commit.
2020-07-15 15:41:27 +02:00
Marko Bencun
c0ad40b562
bitbox02: implement label()
So the device can be identified more easily in dialogs.
2020-07-15 15:41:27 +02:00
Marko Bencun
5457abfab5
bitbox02: drop unused wizard argument 2020-07-15 15:41:25 +02:00
Marko Bencun
106688ea54
bitbox02: implement get_soft_device_id so multisig runs more smoothly
Without it, if you have say a 1-of-2 multisig with two BitBox02s, you
would run into trouble if the first keystore would try to match to the
wrong inserted BitBox02 (wrong order, or the first one is not
inserted, etc. ).

With the soft device id, the device manager can figure it on its own
which keystore belongs to which connected bb02.
2020-07-15 15:41:09 +02:00
ghost43
4aed1df0e8
Merge pull request #6293 from btchip/ledger_segwit_trustedinputs
Ledger : Remove warning on Segwit inputs and newer Bitcoin application, use generic signing for P2SH inputs
2020-07-02 10:47:32 +00:00
SomberNight
b042c4118f
ledger: speed-up sign_transaction
really slow to scan usb devices for e.g. every tx input...
if user disconnects mid-signing, we would fail anyway.
2020-07-02 12:45:42 +02:00
SomberNight
48993118ad
ledger: bump min btchip-python version
and minor simplification
2020-07-02 12:45:38 +02:00
ghost43
db063517ec
Merge pull request #6309 from benma/bitbox02
plugins/bitbox02: fix compatibility with bitbox02-4.0.0
2020-07-01 16:49:03 +00:00
Marko Bencun
b1e756ac96
plugins/bitbox02: fix compatibility with bitbox02-4.0.0 2020-07-01 17:49:53 +02:00
zebra-lucky
949b247b19
fix raise UserCacnelled calls (#6304) 2020-07-01 15:37:31 +00:00
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
BTChip github
c1101ee258
Remove warning on Segwit inputs and newer Bitcoin application, use generic signing for P2SH inputs 2020-06-27 18:26:54 +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