From 77c55d78b79ad83b825fc98a891ffabf0e8c4066 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 5 Jan 2024 15:00:45 +0000 Subject: [PATCH] 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. --- electrum/gui/qt/seed_dialog.py | 8 ++++++-- electrum/gui/qt/wizard/wallet.py | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/electrum/gui/qt/seed_dialog.py b/electrum/gui/qt/seed_dialog.py index cd4af5e0e..6971e649f 100644 --- a/electrum/gui/qt/seed_dialog.py +++ b/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([ '' + _('Warning') + ': ', _("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: diff --git a/electrum/gui/qt/wizard/wallet.py b/electrum/gui/qt/wizard/wallet.py index 3789ed7b8..bf6ebbd74 100644 --- a/electrum/gui/qt/wizard/wallet.py +++ b/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):