-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Qml wizard warn wrong electrum seed #10895
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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: | ||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This could be used to deduplicate the identical warning in electrum/electrum/gui/qt/seed_dialog.py Lines 325 to 331 in a8ff16a
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
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
(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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
why would that be a circular dependency? it looks fine to me |
||||||||||||||||
| 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 | ||||||||||||||||
|
|
||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
|
||||||||||||||||
| 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: | ||||||||||||||||
|
|
||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.