simpleledger / Electron-Cash-SLP

Electron Cash for SLP Tokens
https://simpleledger.cash/project/electron-cash-slp-edition/
MIT License
67 stars 53 forks source link

Multisig hardware wallet; different signers, different paths, same device #89

Closed jcramer closed 5 years ago

jcramer commented 5 years ago

In master branch testing a new multi-sig with a single hardware wallet. Here is an error that needs to be managed (trace shown below) instead of having this display then close the program:

image

Steps to reproduce:

  1. File > New/Restore Wallet > Create a new "Multi-signature wallet" file
  2. Select 2-of-2 co-signers
  3. Choose "Use a hardware device"
  4. Select default path "m/44'/245'/0'"
  5. Select "Cosign with a hardward device" > Choose the same device
  6. Edit path to be: "'m/44'/145'/0'" > Next (results in the below stack trace)
Traceback (most recent call last):
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/__init__.py", line 530, in start_new_window
    wallet = wizard.run_and_get_wallet()
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 294, in run_and_get_wallet
    self.run(action)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 93, in new
    self.choice_dialog(title=title, message=message, choices=choices, run_next=self.on_wallet_type)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 103, in on_wallet_type
    self.run(action)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 111, in choose_multisig
    self.multisig_dialog(run_next=on_multisig)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 110, in on_multisig
    self.run('choose_keystore')
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 135, in choose_keystore
    self.choice_dialog(title=title, message=message, choices=choices, run_next=self.run)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 249, in choose_hw_device
    disabled_tooltip = _('This hardware wallet device'
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 279, in on_device
    self.derivation_dialog(f, default_derivation)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 290, in derivation_dialog
    self.line_dialog(run_next=f, title=_('Derivation for {} wallet').format(self.wallet_type), message=message, default=default_derivation, test=bitcoin.is_bip32_derivation)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 272, in <lambda>
    f = lambda x: self.run('on_hw_derivation', name, device_info, str(x))
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 309, in on_hw_derivation
    self.on_keystore(k)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 386, in on_keystore
    self.run('show_xpub_and_add_cosigners', xpub)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 427, in show_xpub_and_add_cosigners
    self.show_xpub_dialog(xpub=xpub, run_next=lambda x: self.run('choose_keystore'))
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 427, in <lambda>
    self.show_xpub_dialog(xpub=xpub, run_next=lambda x: self.run('choose_keystore'))
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 135, in choose_keystore
    self.choice_dialog(title=title, message=message, choices=choices, run_next=self.run)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 249, in choose_hw_device
    disabled_tooltip = _('This hardware wallet device'
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 279, in on_device
    self.derivation_dialog(f, default_derivation)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 290, in derivation_dialog
    self.line_dialog(run_next=f, title=_('Derivation for {} wallet').format(self.wallet_type), message=message, default=default_derivation, test=bitcoin.is_bip32_derivation)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/gui/qt/installwizard.py", line 91, in func_wrapper
    run_next(*out)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 272, in <lambda>
    f = lambda x: self.run('on_hw_derivation', name, device_info, str(x))
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 309, in on_hw_derivation
    self.on_keystore(k)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 390, in on_keystore
    self.run('create_wallet')
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 67, in run
    f(*args)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 397, in create_wallet
    self.on_password(None, False)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/base_wizard.py", line 419, in on_password
    self.wallet = Multisig_Wallet(self.storage)
  File "/Users/jamescramer/Source/Electron-Cash-SLP/lib/wallet.py", line 2995, in __init__
    self.m, self.n = multisig_type(self.wallet_type)
TypeError: cannot unpack non-iterable NoneType object
jcramer commented 5 years ago

This is resolved by deleting the middle line here in base_wizard.py:

31c10ae77 (James Cramer   2019-04-16 14:45:20 -0400 414)         elif self.wallet_type == 'slp_multisig':
9f4b595b0 (Calin Culianu  2019-08-02 10:50:14 +0300 415)             self.storage.put('wallet_type', self.wallet_type)
3ac357171 (ThomasV        2016-08-25 12:18:51 +0200 416)             for i, k in enumerate(self.keystores):

@cculianu Do you recall why this was needed? Its not in the EC mainline code base.

jcramer commented 5 years ago

I updated the commit title to be more accurate, and less severe sounding.