Skip to content

Qml wizard warn wrong electrum seed - #10895

Open
accumulator wants to merge 1 commit into
spesmilo:masterfrom
accumulator:qml_wizard_warn_wrong_electrum_seed
Open

Qml wizard warn wrong electrum seed#10895
accumulator wants to merge 1 commit into
spesmilo:masterfrom
accumulator:qml_wizard_warn_wrong_electrum_seed

Conversation

@accumulator

Copy link
Copy Markdown
Member

No description provided.

@accumulator
accumulator force-pushed the qml_wizard_warn_wrong_electrum_seed branch 2 times, most recently from dcbf073 to 2617807 Compare August 25, 2026 15:25
@accumulator
accumulator marked this pull request as ready for review August 26, 2026 06:49
Comment thread electrum/gui/qml/components/wizard/WCHaveSeed.qml
Comment thread electrum/wizard.py
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:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be used to deduplicate the identical warning in seed_dialog.py:

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(wiztype_fullname),
])
self.seed_warning.setText(msg)

This works (click to expand)
diff --git a/electrum/gui/qt/seed_dialog.py b/electrum/gui/qt/seed_dialog.py
index 0b0da25ae3..e5ffe9c6b9 100644
--- a/electrum/gui/qt/seed_dialog.py
+++ b/electrum/gui/qt/seed_dialog.py
@@ -36,6 +36,7 @@ from electrum.mnemonic import Mnemonic, calc_seed_type, is_any_2fa_seed_type
 from electrum import old_mnemonic
 from electrum import slip39
 from electrum.util import ChoiceItem
+from electrum.wizard import KeystoreWizard
 
 from .util import (
     Buttons, OkButton, WWLabel, ButtonsTextEdit, icon_path, EnterButton,
@@ -322,13 +323,7 @@ class SeedWidget(QWidget):
             t = calc_seed_type(s)
             label = _('Seed Type') + ': ' + t if t else ''
             if t and not valid:  # electrum seed, but does not conform to dialog rules
-                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(wiztype_fullname),
-                ])
-                self.seed_warning.setText(msg)
+                self.seed_warning.setText(KeystoreWizard.warning_wrong_electrum_seed_type(t))
             else:
                 self.seed_warning.setText("")
 
diff --git a/electrum/wizard.py b/electrum/wizard.py
index d8773f82a1..2b15a06e47 100644
--- a/electrum/wizard.py
+++ b/electrum/wizard.py
@@ -312,7 +312,8 @@ class KeystoreWizard(AbstractWizard):
         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 _warning_wrong_electrum_seed_type(self, seed_type: str) -> str:
+    @staticmethod
+    def warning_wrong_electrum_seed_type(seed_type: str) -> str:
         if not seed_type:
             return ''
         wiztype_fullname = _('Wallet with two-factor authentication') if is_any_2fa_seed_type(seed_type) \
@@ -359,11 +360,11 @@ class KeystoreWizard(AbstractWizard):
         # 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)
+            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)
+                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
 

@accumulator accumulator Aug 27, 2026

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I saw that, but I held off on refactoring this like you suggested above because it felt like a circular dependency using the class and its static member in a control that is typically imported in a wizard.

@SomberNight SomberNight Aug 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

somewhat related, I have long thought we have too many top-level modules (.py files directly in electrum/). One idea for a new folder is mnemonic/, which would include:

  • mnemonic.py
  • old_mnemonic.py
  • slip39.py
  • the "bip39" parts extracted from keystore.py, in a new bip39.py

(EDIT: there is also bip39_recovery.py, bip39_wallet_formats.json, perhaps even the whole wordlist/ folder)

If we had that folder, you could somewhat more cleanly also add another module there for shared UI code, and put this function there.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also add a FIXME pointing out where the duplication is, and we can fix it later, if you want. We should definitely try to avoid unmarked duplication though.
I can do the above mentioned refactor but don't want to hold up this PR on that.

Comment thread electrum/wizard.py Outdated
Comment thread electrum/wizard.py
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

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On desktop we also show a warning if the user enters the wrong seed type into the multisig wizard:

Suggested change
warning = self._warning_wrong_electrum_seed_type(seed_type)

@accumulator
accumulator force-pushed the qml_wizard_warn_wrong_electrum_seed branch from 2617807 to 90fd2c5 Compare August 27, 2026 07:27
@accumulator
accumulator force-pushed the qml_wizard_warn_wrong_electrum_seed branch from 90fd2c5 to be9fb4b Compare August 27, 2026 07:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants