1
0
Commit Graph

84 Commits

Author SHA1 Message Date
SomberNight
a4276102f2 hw DeviceMgr: don't filter already paired devices in wizard
Related to prev commit: multiple (compatible) keystores can now match
with the same HardwareClientBase, so we might as well also allow
reusing existing Clients for the wizard.
2022-12-19 13:10:20 +00:00
SomberNight
cea4238b81 hw DeviceMgr: mostly switch away from xpubs for device pairing
- the DeviceMgr no longer uses xpubs to keep track of paired hw devices
- instead, introduce keystore.pairing_code(), based on soft_device_id
- xpubs are now only used in a single place when the actual pairing happens
- motivation is to allow pairing a single device with multiple generic
  output script descriptors, not just a single account-level xpub
- as a side-effect, we now allow pairing a device with multiple open
  windows simultaneously (if keystores have the same root fingerprint
  -- was already the case before if keystores had the same xpub)
2022-12-19 08:19:19 +00:00
Andrew Kozlik
0dce13a1dd Implement SLIP-0039 wallet recovery. 2021-04-30 19:55:47 +02:00
Andrew Kozlik
19d04546df Replace from_bip39_seed() with from_bip43_rootseed(). 2021-04-30 19:43:53 +02:00
SomberNight
e5295701d2 wizard: let UserCancelled propagate out in hw wallet flow
Note that clicking "x" to close the wizard or pressing ESC also raises
a UserCancelled:
raising ChooseHwDeviceAgain was not letting the wizard close.

E | gui.qt.installwizard.InstallWizard |
Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/base_wizard.py", line 371, in on_device
    client = self.plugin.setup_device(device_info, self, purpose)
  File "/home/user/wspace/electrum/electrum/plugins/trezor/trezor.py", line 305, in setup_device
    self.initialize_device(device_id, wizard, client.handler)
  File "/home/user/wspace/electrum/electrum/plugins/trezor/trezor.py", line 231, in initialize_device
    wizard.choice_dialog(title=_('Initialize Device'), message=msg, choices=choices, run_next=f)
  File "/home/user/wspace/electrum/electrum/gui/qt/installwizard.py", line 106, in func_wrapper
    out = func(*args, **kwargs)
  File "/home/user/wspace/electrum/electrum/gui/qt/installwizard.py", line 614, in choice_dialog
    self.exec_layout(vbox, title)
  File "/home/user/wspace/electrum/electrum/gui/qt/installwizard.py", line 434, in exec_layout
    raise UserCancelled()
electrum.util.UserCancelled

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/wspace/electrum/electrum/base_wizard.py", line 277, in choose_hw_device
    self._choose_hw_device(purpose=purpose, storage=storage)
  File "/home/user/wspace/electrum/electrum/base_wizard.py", line 363, in _choose_hw_device
    self.choice_dialog(title=title, message=msg, choices=choices,
  File "/home/user/wspace/electrum/electrum/gui/qt/installwizard.py", line 120, in func_wrapper
    run_next(*out)
  File "/home/user/wspace/electrum/electrum/base_wizard.py", line 364, in <lambda>
    run_next=lambda *args: self.on_device(*args, purpose=purpose, storage=storage))
  File "/home/user/wspace/electrum/electrum/base_wizard.py", line 386, in on_device
    raise ChooseHwDeviceAgain()
electrum.base_wizard.ChooseHwDeviceAgain
E | gui.qt.installwizard.InstallWizard | choose_hw_device(). while iter starts.
I | plugin.DeviceMgr | scanning devices...
2021-04-06 18:44:16 +02:00
SomberNight
35bc461fe1 keystore: encapsulate "can_have_deterministic_lightning_xprv" logic 2021-03-30 21:31:37 +02:00
ThomasV
64a931f21e Deterministic NodeID:
- use_recoverable_channel is a user setting, available
   only in standard wallets with a 'segwit' seed_type
 - if enabled, 'lightning_xprv' is derived from seed
 - otherwise, wallets use the existing 'lightning_privkey2'

Recoverable channels:
 - channel recovery data is added funding tx using an OP_RETURN
 - recovery data = 4 magic bytes + node id[0:16]
 - recovery data is chacha20 encrypted using funding_address as nonce.
   (this will allow to fund multiple channels in the same tx)

GUI:
  - whether channels are recoverable is shown in wallet info dialog.
  - if the wallet can have recoverable channels but has an old node_id,
    users are told to close their channels and restore from seed
    to have that feature.
2021-03-19 10:17:02 +01:00
ThomasV
620a6aaf99 kivy: fix confirm_seed_dialog (broken in 77e0d3745e) 2021-01-13 11:07:48 +01:00
ThomasV
641968fcf8 Wizard: do not ask seed type, default to segwit
segwit addresses are widely supported today.
2021-01-12 11:03:21 +01:00
ThomasV
b2ab2a9f6a wizard: call on_restore_seed, on_restore_bip39 through self.run. fixes #6895 2021-01-02 14:24:11 +01:00
SomberNight
933d8861ce mnemonic.make_seed: de-duplicate num_bits default magic number 2020-12-08 10:00:34 +01:00
ThomasV
47afc3bc7b follow-up 427779350f 2020-12-04 17:38:40 +01:00
ThomasV
3d2736b014 add debug option to avoid retyping the seed in kivy 2020-11-30 14:37:32 +01:00
SomberNight
f3c1313a4f coldcard: avoid creating keystore with testnet/mainnet mixed up
fixes #6722
2020-11-18 00:47:20 +01:00
SomberNight
193c29af87 wizard, multisig: on bip39/hw ks, only ask for script type for 1st ks
When setting up a multisig wallet, there is no point in asking for the
script type for each cosigner (bip39/hw) -- we can just ask for the
first one. If the first keystore is an electrum seed, we end up never asking :)
2020-11-05 01:02:11 +01:00
SomberNight
cc33b752e2 wizard: on adding bip39/hw ks, don't offer path scanning for multisig
follow-up #6219

for multisig, it's just confusing and useless as-is
2020-11-05 00:18:54 +01:00
ThomasV
5313438140 fix display of Zpub in Kivy during multisig wallet creation (see #6456) 2020-08-26 20:26:59 +02:00
SomberNight
df82d9c017 bip39 scan: follow-up prev
- use logger
- allow qt dialog to be GC-ed
- (trivial) add typing; minor formatting
2020-08-20 18:58:52 +02:00
Luke Childs
7b122d2679 Automated BIP39 Recovery, squashed 2020-08-20 17:50:39 +02:00
relativistic electron
fbc539e2cc One can now click the back button in the show_xpub_and_add_cosigners wizard step 2020-05-07 10:19:48 +02:00
SomberNight
08118ca167 qt wizard: tweak GoBack behaviour to recalc inputs to previous dialog
follow-up f13f46c555

When on dialog n user presses "Back",
- previously, we went back to when dialog n-1 appeared
- now, go back to just after dialog n-2 finishes
This way, any calculations between when dialog n-2 finishes and
dialog n-1 appears will rerun, potentially populating dialog n-1 differently.

Namely if the user presses back on the confirm_seed_dialog, we want to
go back to the show_seed_dialog but with a freshly generated seed.
2020-04-11 15:50:12 +02:00
SomberNight
b6bac0182f wizard hww: use exception handling to choose hw device again
- no need to pass args, caller knows what it wanted
- avoids deepening the call stack on every rescan
  (nicer tracebacks, no stack overflow)
2020-04-09 19:45:45 +02:00
SomberNight
71eed1d4cb wizard: (trivial) add show_error to base class, document API 2020-04-09 19:45:42 +02:00
SomberNight
08a7925235 wizard.create_storage: state API and abide by it
none of the callers was handling the return None case properly...
2020-04-09 19:45:38 +02:00
SomberNight
a3e1b2e00c wizard: hww creation flow: don't just swallow exception
if we just return here, the calling code will try to create the storage and fail
2020-04-09 19:45:35 +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
7c830cb221 wizard hww: move devmgr.scan_devices() away from GUI thread 2020-04-08 18:54:11 +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
9d0bb295e6 hww: distinguish devices based on "soft device id" (not just labels)
fixes #5759
2020-04-08 14:44:42 +02:00
SomberNight
f13f46c555 qt wizard: make "GoBack" unroll the call stack to avoid stack overflow
fixes #6069
2020-04-03 18:58:51 +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
18c98483ac wizard: (trivial) add some type hints 2020-04-01 21:09:10 +02:00
SomberNight
c0b170acb7 hww wizard: better handle UserFacingException in one case
E | gui.qt.installwizard.InstallWizard |
Traceback (most recent call last):
  File "...\electrum\electrum\base_wizard.py", line 340, in on_device
    self.plugin.setup_device(device_info, self, purpose)
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 719, in setup_device
    client.get_xpub("m/44'/0'", 'standard')
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 120, in get_xpub
    reply = self._get_xpub(bip32_path)
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 114, in _get_xpub
    if self.check_device_dialog():
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 223, in check_device_dialog
    self.recover_or_erase_dialog() # Already seeded
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 244, in recover_or_erase_dialog
    if not self.dbb_load_backup():
  File "...\electrum\electrum\plugins\digitalbitbox\digitalbitbox.py", line 340, in dbb_load_backup
    raise UserFacingException(backups['error']['message'])
electrum.util.UserFacingException: Please insert SD card.
2020-04-01 21:08:56 +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
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
SomberNight
f8ba660583 clean-up hw-wallet "get_password_for_storage_encryption"-related code 2020-02-28 19:47:56 +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
9b28f6df7b wallet: encrypt storage by default
notably, now also in kivy
2019-12-19 14:22:47 +01:00
SomberNight
f73b6b5d23 keystore: cache derive_pubkey 2019-12-09 03:35:20 +01:00
SomberNight
d3fd87ebd0 hardware wallets: wizard no longer requests xpub at path "m"
This was done to calculate the bip32 root fingerprint but it broke
the digitalbitbox. The keystore already had a different way to get
the root fingerprint for existing wallets, specifically handling this
case; the code in base_wizard used when creating new wallets was
duplicating that code originally and was then forgotten to be updated.
Now these codepaths are unified.

closes #5816
2019-12-02 19:31:17 +01:00
SomberNight
88307357ec add some type hints
mostly related to hw wallets
2019-11-22 22:59:33 +01:00
SomberNight
e6c841d05f psbt: put fake xpubs into globals. keystores handle xfp/der_prefix missing 2019-11-04 22:24:59 +01:00
SomberNight
bafe8a2fff integrate PSBT support natively. WIP 2019-11-04 22:24:36 +01:00
SomberNight
99b83f7527 fix #5617 2019-09-04 13:53:38 +02:00
SomberNight
a42a773d19 storage: replace STO_EV_* ints with IntEnum 2019-09-04 13:31:49 +02:00
SomberNight
bffc2a1d4b wizard: try harder to have temporarily stored pw erased from memory 2019-08-14 17:27:38 +02:00
ThomasV
aa7aeb9014 disable go_back button in wizard password dialog (fix #5509) 2019-08-14 10:14:28 +02:00
ThomasV
a7b61fcab9 kivy: support bip39 seeds 2019-08-13 17:14:54 +02:00
SomberNight
fb76fcc886 trezor: use only Bridge when available
fixes #5420
2019-07-02 21:21:39 +02:00
SomberNight
371e1a6ebf hw: allow bypassing "too old firmware" error when using hw wallets
The framework here is generic enough that it can be used for any hw plugin,
however atm only Trezor is implemented.

closes #5391
2019-05-31 04:09:03 +02:00