diff --git a/electrum/gui/qml/components/wizard/WCHaveSeed.qml b/electrum/gui/qml/components/wizard/WCHaveSeed.qml index 95ce6cd6f53..63199db6331 100644 --- a/electrum/gui/qml/components/wizard/WCHaveSeed.qml +++ b/electrum/gui/qml/components/wizard/WCHaveSeed.qml @@ -20,6 +20,7 @@ WizardComponent { property string _seedType property string _validationMessage + property string _warning property bool _canPassphrase property bool _seedValid @@ -72,11 +73,18 @@ WizardComponent { var verifyResult = wiz.verifySeed(seedtext.text, seed_variant_cb.currentValue, wizard_data['wallet_type']) _validationMessage = verifyResult.message + _warning = verifyResult.warning _seedType = verifyResult.type _canPassphrase = verifyResult.can_passphrase if (!cosigner || !verifyResult.valid) { _seedValid = verifyResult.valid + if (_warning) { + infotext.text = _warning + infotext.visible = true + } else { + setSeedTypeHelpText() + } } else { // bip39 validate after derivation path is known if (seed_variant_cb.currentValue == 'electrum') { @@ -190,6 +198,7 @@ WizardComponent { Layout.fillWidth: true Layout.columnSpan: 2 Layout.topMargin: constants.paddingLarge + iconStyle: root._warning === infotext.text ? InfoTextArea.IconStyle.Warn : InfoTextArea.IconStyle.Info compact: true backgroundColor: constants.darkerDialogBackground } diff --git a/electrum/gui/qml/qewizard.py b/electrum/gui/qml/qewizard.py index 3bd3f33ece6..558b7513efe 100644 --- a/electrum/gui/qml/qewizard.py +++ b/electrum/gui/qml/qewizard.py @@ -116,11 +116,12 @@ def isMatchingSeed(self, seed, seed_again): @pyqtSlot(str, str, str, result='QVariantMap') def verifySeed(self, seed, seed_variant, wallet_type='standard'): - seed_valid, seed_type, validation_message, can_passphrase = self.validate_seed(seed, seed_variant, wallet_type) + seed_valid, seed_type, validation_message, warning, can_passphrase = self.validate_seed(seed, seed_variant, wallet_type) return { 'valid': seed_valid, 'type': seed_type, 'message': validation_message, + 'warning': warning, 'can_passphrase': can_passphrase } diff --git a/electrum/gui/qt/wizard/wallet.py b/electrum/gui/qt/wizard/wallet.py index 8c1ca11a7f0..6990ad06a57 100644 --- a/electrum/gui/qt/wizard/wallet.py +++ b/electrum/gui/qt/wizard/wallet.py @@ -634,7 +634,7 @@ def validate(self): seed = self.seed_widget.get_seed() seed_variant = self.seed_widget.seed_type wallet_type = self.wizard_data['wallet_type'] - seed_valid, seed_type, validation_message, self.can_passphrase = self.wizard.validate_seed(seed, seed_variant, wallet_type) + seed_valid, seed_type, validation_message, warning, self.can_passphrase = self.wizard.validate_seed(seed, seed_variant, wallet_type) is_cosigner = self.wizard_data['wallet_type'] == 'multisig' and 'multisig_current_cosigner' in self.wizard_data diff --git a/electrum/wizard.py b/electrum/wizard.py index 6b2e7b65d2c..328defef329 100644 --- a/electrum/wizard.py +++ b/electrum/wizard.py @@ -312,10 +312,23 @@ def on_hardware_device(self, wizard_data: dict, new_wallet=True) -> str: run_hook('init_wallet_wizard', self) # TODO: currently only used for hww, hook name might be confusing return plugin.wizard_entry_for_device(_info, new_wallet=new_wallet) - def validate_seed(self, seed: str, seed_variant: str, wallet_type: str) -> Tuple[bool, str, str, bool]: + def _warning_wrong_electrum_seed_type(self, seed_type: str) -> str: + if not seed_type: + return '' + wiztype_fullname = _('Wallet with two-factor authentication') if is_any_2fa_seed_type(seed_type) \ + else _("Standard wallet") + msg = ' '.join([ + _("Looks like you have entered a valid seed of type '{}' but this dialog does not support such seeds.").format( + seed_type), + _("If unsure, try restoring as '{}'.").format(wiztype_fullname), + ]) + return msg + + def validate_seed(self, seed: str, seed_variant: str, wallet_type: str) -> Tuple[bool, str, str, str, bool]: seed_type = '' seed_valid = False validation_message = '' + warning = '' can_passphrase = True if seed_variant == 'electrum': @@ -345,14 +358,17 @@ def validate_seed(self, seed: str, seed_variant: str, wallet_type: str) -> Tuple # check if seed matches wallet type if wallet_type == '2fa' and not is_any_2fa_seed_type(seed_type): seed_valid = False + warning = self._warning_wrong_electrum_seed_type(seed_type) elif wallet_type == 'standard' and seed_type not in ['old', 'standard', 'segwit', 'bip39', 'slip39']: seed_valid = False + if seed_variant == 'electrum': + warning = self._warning_wrong_electrum_seed_type(seed_type) elif wallet_type == 'multisig' and seed_type not in ['standard', 'segwit', 'bip39', 'slip39']: seed_valid = False self._logger.debug(f'seed verified: {seed_valid}, type={seed_type!r}, validation_message={validation_message}') - return seed_valid, seed_type, validation_message, can_passphrase + return seed_valid, seed_type, validation_message, warning, can_passphrase def keystore_from_data(self, wallet_type: str, data: dict): if data['keystore_type'] in ['createseed', 'haveseed'] and 'seed' in data: