Browse Source

qt wizard: show warning when trying to restore 2fa seed as std wallet

With wallet_type=="standard", if the user enters a 2fa electrum seed, the "next" btn is disabled.
This is a regression in the new wizard, the old one used to "redirect" seamlessly.
This commit does not fix this, but at least shows a user-friendly warning message.

Note: would be nice if the wizard redirected automatically, in both directions (2fa->std, std->2fa).
The old wizard implemented std->2fa (probably the more common case hit by users), and had this
warning message shown for the 2fa->std case. Now I am repurposing the warning also for std->2fa.
master
SomberNight 2 years ago
parent
commit
77c55d78b7
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 8
      electrum/gui/qt/seed_dialog.py
  2. 3
      electrum/gui/qt/wizard/wallet.py

8
electrum/gui/qt/seed_dialog.py

@ -32,7 +32,7 @@ from PyQt5.QtWidgets import (QVBoxLayout, QCheckBox, QHBoxLayout, QLineEdit,
QScrollArea, QWidget, QPushButton)
from electrum.i18n import _
from electrum.mnemonic import Mnemonic, seed_type
from electrum.mnemonic import Mnemonic, seed_type, is_any_2fa_seed_type
from electrum import old_mnemonic
from electrum import slip39
@ -295,10 +295,14 @@ class SeedLayout(QVBoxLayout):
t = seed_type(s)
label = _('Seed Type') + ': ' + t if t else ''
if t and not b: # electrum seed, but does not conform to dialog rules
# FIXME we should just accept any electrum seed and "redirect" the wizard automatically.
# i.e. if user selected wallet_type=="standard" but entered a 2fa seed, accept and redirect
# if user selected wallet_type=="2fa" but entered a std electrum seed, accept and redirect
wiztype_fullname = _('Wallet with two-factor authentication') if is_any_2fa_seed_type(t) else _("Standard wallet")
msg = ' '.join([
'<b>' + _('Warning') + ':</b> ',
_("Looks like you have entered a valid seed of type '{}' but this dialog does not support such seeds.").format(t),
_("If unsure, try restoring as '{}'.").format(_("Standard wallet")),
_("If unsure, try restoring as '{}'.").format(wiztype_fullname),
])
self.seed_warning.setText(msg)
else:

3
electrum/gui/qt/wizard/wallet.py

@ -628,10 +628,11 @@ class WCHaveSeed(WalletWizardComponent, Logger):
def is_seed(self, x):
t = mnemonic.seed_type(x)
if self.wizard_data['wallet_type'] == 'standard':
return mnemonic.is_seed(x)
return mnemonic.is_seed(x) and not mnemonic.is_any_2fa_seed_type(t)
elif self.wizard_data['wallet_type'] == '2fa':
return mnemonic.is_any_2fa_seed_type(t)
else:
# multisig? by default, only accept modern non-2fa electrum seeds
return t in ['standard', 'segwit']
def validate(self):

Loading…
Cancel
Save