Browse Source

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 :)
patch-4
SomberNight 5 years ago
parent
commit
193c29af87
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 31
      electrum/base_wizard.py
  2. 4
      electrum/gui/qt/installwizard.py

31
electrum/base_wizard.py

@ -410,6 +410,7 @@ class BaseWizard(Logger):
_('You can override the suggested derivation path.'), _('You can override the suggested derivation path.'),
_('If you are not sure what this is, leave this field unchanged.') _('If you are not sure what this is, leave this field unchanged.')
]) ])
hide_choices = False
if self.wallet_type == 'multisig': if self.wallet_type == 'multisig':
# There is no general standard for HD multisig. # There is no general standard for HD multisig.
# For legacy, this is partially compatible with BIP45; assumes index=0 # For legacy, this is partially compatible with BIP45; assumes index=0
@ -420,6 +421,14 @@ class BaseWizard(Logger):
('p2wsh-p2sh', 'p2sh-segwit multisig (p2wsh-p2sh)', purpose48_derivation(0, xtype='p2wsh-p2sh')), ('p2wsh-p2sh', 'p2sh-segwit multisig (p2wsh-p2sh)', purpose48_derivation(0, xtype='p2wsh-p2sh')),
('p2wsh', 'native segwit multisig (p2wsh)', purpose48_derivation(0, xtype='p2wsh')), ('p2wsh', 'native segwit multisig (p2wsh)', purpose48_derivation(0, xtype='p2wsh')),
] ]
# if this is not the first cosigner, pre-select the expected script type,
# and hide the choices
script_type = self.get_script_type_of_wallet()
if script_type is not None:
script_types = [*zip(*choices)][0]
chosen_idx = script_types.index(script_type)
default_choice_idx = chosen_idx
hide_choices = True
else: else:
default_choice_idx = 2 default_choice_idx = 2
choices = [ choices = [
@ -430,9 +439,16 @@ class BaseWizard(Logger):
while True: while True:
try: try:
self.derivation_and_script_type_gui_specific_dialog( self.derivation_and_script_type_gui_specific_dialog(
run_next=f, title=_('Script type and Derivation path'), message1=message1, run_next=f,
message2=message2, choices=choices, test_text=is_bip32_derivation, title=_('Script type and Derivation path'),
default_choice_idx=default_choice_idx, get_account_xpub=get_account_xpub) message1=message1,
message2=message2,
choices=choices,
test_text=is_bip32_derivation,
default_choice_idx=default_choice_idx,
get_account_xpub=get_account_xpub,
hide_choices=hide_choices,
)
return return
except ScriptTypeNotSupported as e: except ScriptTypeNotSupported as e:
self.show_error(e) self.show_error(e)
@ -529,7 +545,14 @@ class BaseWizard(Logger):
k = keystore.from_bip39_seed(seed, passphrase, derivation, xtype=script_type) k = keystore.from_bip39_seed(seed, passphrase, derivation, xtype=script_type)
self.on_keystore(k) self.on_keystore(k)
def on_keystore(self, k): def get_script_type_of_wallet(self) -> Optional[str]:
if len(self.keystores) > 0:
ks = self.keystores[0]
if isinstance(ks, keystore.Xpub):
return xpub_type(ks.xpub)
return None
def on_keystore(self, k: KeyStore):
has_xpub = isinstance(k, keystore.Xpub) has_xpub = isinstance(k, keystore.Xpub)
if has_xpub: if has_xpub:
t1 = xpub_type(k.xpub) t1 = xpub_type(k.xpub)

4
electrum/gui/qt/installwizard.py

@ -610,11 +610,12 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
title: str, title: str,
message1: str, message1: str,
choices: List[Tuple[str, str, str]], choices: List[Tuple[str, str, str]],
hide_choices: bool = False,
message2: str, message2: str,
test_text: Callable[[str], int], test_text: Callable[[str], int],
run_next, run_next,
default_choice_idx: int = 0, default_choice_idx: int = 0,
get_account_xpub=None get_account_xpub=None,
) -> Tuple[str, str]: ) -> Tuple[str, str]:
vbox = QVBoxLayout() vbox = QVBoxLayout()
@ -640,6 +641,7 @@ class InstallWizard(QDialog, MessageBoxMixin, BaseWizard):
line.setText(c_default_text[idx]) line.setText(c_default_text[idx])
clayout = ChoicesLayout(message1, c_titles, on_choice_click, clayout = ChoicesLayout(message1, c_titles, on_choice_click,
checked_index=default_choice_idx) checked_index=default_choice_idx)
if not hide_choices:
vbox.addLayout(clayout.layout()) vbox.addLayout(clayout.layout())
vbox.addWidget(WWLabel(message2)) vbox.addWidget(WWLabel(message2))

Loading…
Cancel
Save