1
0
Commit Graph

56 Commits

Author SHA1 Message Date
Sander van Grieken
4101946ff5 wizard: add non-hardened derivation path check for digital bitbox, re-add rescan button in choose hw device,
clear clipboard before confirming seed.
2023-09-20 14:34:31 +02:00
Sander van Grieken
b7612605c5 wizard: add Digital Bitbox initialization to new wizard, remove rescan button
Note: the option to load a backup from SD card when the device already has a seed
has been removed. The device always returns an error when attempting this.
2023-09-20 14:34:31 +02:00
Sander van Grieken
087718f3a7 hww: mark device_model_name(self) as @abstractmethod and override in hww clients that did not define it. 2023-09-20 14:34:31 +02:00
Sander van Grieken
0aebc1a31e qt+plugins: cleanup. remove all old wizard code 2023-09-20 14:34:31 +02:00
Sander van Grieken
656442ce64 wizard: add missing imports 2023-09-20 14:34:31 +02:00
Sander van Grieken
d70831392d wizard: add keepkey to new wizard 2023-09-20 14:34:31 +02:00
Sander van Grieken
48fb4911a3 wizard: add digital bitbox to new wizard 2023-09-20 14:34:31 +02:00
SomberNight
22b8c4e397 hww: fix digitalbitbox(1) support
regression from cea4238b81

```
975.04 | E | plugin.DeviceMgr | failed to create client for digitalbitbox at <REDACTED>: AttributeError("'NoneType' object has no attribute 'get_passphrase'")
Traceback (most recent call last):
  File "...\electrum\electrum\plugin.py", line 620, in list_pairable_device_infos
    soft_device_id = client.get_soft_device_id()
  File "...\electrum\electrum\plugins\hw_wallet\plugin.py", line 251, in get_soft_device_id
    root_fp = self.request_root_fingerprint_from_device()
  File "...\electrum\electrum\plugin.py", line 362, in wrapper
    return run_in_hwd_thread(partial(func, *args, **kwargs))
  File "...\electrum\electrum\plugin.py", line 352, in run_in_hwd_thread
    return func()
  File "...\electrum\electrum\plugins\hw_wallet\plugin.py", line 264, in request_root_fingerprint_from_device
    child_of_root_xpub = self.get_xpub("m/0'", xtype='standard')
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 115, in get_xpub
    reply = self._get_xpub(bip32_path)
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 110, in _get_xpub
    if self.check_device_dialog():
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 197, in check_device_dialog
    if not self.password_dialog(msg):
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 159, in password_dialog
    password = self.handler.get_passphrase(msg, False)
AttributeError: 'NoneType' object has no attribute 'get_passphrase'
```
2023-04-27 17:33:54 +00:00
SomberNight
499f51535f bip32: fix hardened char "h" vs "'" compatibility for some hw wallets
in particular, ledger: fix sign_message for some wallets

```
156.02 | E | plugins.ledger.ledger |
Traceback (most recent call last):
  File "...\electrum\electrum\plugins\ledger\ledger.py", line 1265, in sign_message
    result = base64.b64decode(self.client.sign_message(message, address_path))
  File "...\Python310\site-packages\ledger_bitcoin\client.py", line 230, in sign_message
    sw, response = self._make_request(self.builder.sign_message(message_bytes, bip32_path), client_intepreter)
  File "...\Python310\site-packages\ledger_bitcoin\command_builder.py", line 176, in sign_message
    bip32_path: List[bytes] = bip32_path_from_string(bip32_path)
  File "...\Python310\site-packages\ledger_bitcoin\common.py", line 68, in bip32_path_from_string
    return [int(p).to_bytes(4, byteorder="big") if "'" not in p
  File "...\Python310\site-packages\ledger_bitcoin\common.py", line 68, in <listcomp>
    return [int(p).to_bytes(4, byteorder="big") if "'" not in p
ValueError: invalid literal for int() with base 10: '84h'
```

Regression from df2bd61de6, where the
default hardened char was changed from "'" to "h". Note that there was
no corresponding wallet db upgrade, so some files use one char and
others use the other.
2023-04-27 17:03:16 +00:00
SomberNight
312f2641e7 don't use bare except
use "except Exception", or if really needed explicitly "except BaseException"
2023-04-24 12:58:01 +00:00
SomberNight
be159b5b95 bugfix: assert walrus (":=") combo side-eff. breaks w/ asserts disabled
```
$ python3 -O
Python 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> assert (x := 2)
>>> x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined
```

pity. it looked to be a neat and concise pattern.
2023-04-20 15:17:36 +00:00
SomberNight
0647a2cf9f transaction.py: rm PartialTxInput.{num_sig, script_type} 2023-03-03 16:40:12 +00:00
SomberNight
1ce37c8bb1 transaction: rm hardcoded sighash magic numbers 2023-02-17 11:40:12 +00:00
SomberNight
01b5e3f8e0 flake8: enable more mandatory tests 2022-10-31 16:13:22 +00:00
SomberNight
79fec3417a crypto.py: rm {En,De}codeAES_base64. instead use {En,De}codeAES_bytes 2022-07-12 15:50:42 +02:00
SomberNight
6c50d3b0a3 hw plugins: (cleanup) rm no-op clear_client argument from keystore.give_error
The keystore does not have a "client" field.
One is supposed to use the "get_client" method instead (the generic API is `plugin.get_client(keystore)`)
Remnants of old code.
2022-05-11 19:30:14 +02:00
SomberNight
aab8e664ed hw plugins: (cleanup) Plugin objects should not have a Client field
Clients are per-connected-device, plugins are ~singletons.
These were mostly remnants of old code.
2022-05-11 19:16:18 +02:00
SomberNight
30623c3529 hw plugins: (cleanup) Plugin objects should not have a Handler field
Handlers are per-client (connected device), plugins are ~singletons.
These were mostly remnants of old code.
2022-05-11 19:13:00 +02:00
SomberNight
9599254d43 hw: rm dead code from Hardware_KeyStore subclasses
- force_watching_only is long since unused
- comment was just duplicated from the base class
2022-05-09 20:09:10 +02:00
SomberNight
376fc01b27 keystore.sign_message: add optional script_type argument
this is used by trezor
(and also by bitbox02, which was using a workaround previously)

fixes https://github.com/spesmilo/electrum/issues/7670
2022-02-22 19:20:03 +01:00
SomberNight
5cdb4471ec signmessage: also accept Trezor-type sigs for p2wpkh and p2wpkh-p2sh addrs
The signatures we create are unchanged but we now also accept signatures created by Trezor and others.

see https://github.com/spesmilo/electrum/issues/3861
2022-02-16 19:25:46 +01:00
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
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
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
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
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
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
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
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
c2b0039935 bitcoin.py: remove some remnants of TYPE_ADDRESS, TYPE_SCRIPT 2019-11-21 18:51:38 +01:00
SomberNight
f8c84fbb1e hardware wallets: create base class for HW Clients. add some type hints 2019-11-11 17:04:12 +01:00
SomberNight
dd14a3fde5 psbt: follow-ups: fix digital bitbox 2019-11-05 22:06:46 +01:00
SomberNight
bafe8a2fff integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
TheCharlatan
e7079f1bea Digital BitBox: Fix sending to self
Make sure that a pubkey is only appended to the checkpub array if it
corresponds to a change address. Signing will fail otherwise, if a
non-change pubkey is sent as part of the checkpub list to the Digital
BitBox.
2019-09-09 15:07:51 +02:00
SomberNight
3385a94753 logging: basics 2019-05-02 15:19:03 +02:00
SomberNight
85a7aa291e bip32: refactor whole module. clean-up. 2019-02-22 18:50:24 +01:00
SomberNight
16bac5fd73 rm qt icons file
so we don't need pyrcc5, which is not deterministic,
and so we don't need the submodule for the icons

based on electrumsv/electrumsv@bf8802c2ea
2019-02-01 20:15:28 +01:00
benma
6c20340338 bitbox: fix seed command (#4906)
Entropy required to be 64 bytes.
2018-12-08 17:02:24 +01:00
Janus
e1f4865844 digitalbitbox, trustedcoin: proxied http client
use common cross-thread HTTP method, which is put in network.py,
since that is where the proxy is. TrustedCoin tested successfully,
but DigitalBitbox can't be tested completely due to #4903

before this commit, digitalbitbox would not use any proxying
2018-12-07 19:19:40 +01:00
Janus
0169ec880c digitalbitbox: make constant strings 2018-12-07 19:18:33 +01:00
Janus
9a3f2e8fcc digitalbitbox: fix stretch_key bytes/str confusion 2018-12-07 18:41:40 +01:00
Marko Bencun
92a9cda4fc plugins/digitalbitbox: compatibility with firmware v5.0.0 2018-12-03 22:11:36 +01:00
SomberNight
48b0de7871 keystore: stronger pbkdf for encryption 2018-11-10 16:36:41 +01:00
SomberNight
bd32b88f62 introduce UserFacingException
we should not raise generic Exception when wanting to communicate with
the user. it makes distinguishing programming errors and messages hard,
as the caller will necessarily need to catch all Exceptions then
2018-11-08 19:46:15 +01:00
SomberNight
082a83dd85 rename crypto.Hash to sha256d 2018-10-25 22:28:24 +02:00
SomberNight
a88a2dea82 split bip32 from bitcoin.py 2018-10-25 22:20:33 +02:00