From e5e86e1b074bdfbff4410c0fbf7eb018f2ebda75 Mon Sep 17 00:00:00 2001 From: BamaHodl Date: Sat, 20 Jul 2024 10:23:53 -0500 Subject: [PATCH 1/4] Adding support for Electrum Standard (P2PKH) seed phrases --- src/seedsigner/gui/screens/seed_screens.py | 15 ++++++++++ src/seedsigner/models/seed.py | 23 +++++++++++---- src/seedsigner/models/settings_definition.py | 1 - src/seedsigner/views/seed_views.py | 31 ++++++++++++++++++++ tests/test_flows_psbt.py | 1 + tests/test_flows_seed.py | 6 ++++ tests/test_flows_tools.py | 1 + tests/test_seed.py | 17 +++++------ 8 files changed, 78 insertions(+), 17 deletions(-) diff --git a/src/seedsigner/gui/screens/seed_screens.py b/src/seedsigner/gui/screens/seed_screens.py index 64fb7ea98..c9ff80c58 100644 --- a/src/seedsigner/gui/screens/seed_screens.py +++ b/src/seedsigner/gui/screens/seed_screens.py @@ -1359,6 +1359,21 @@ def __post_init__(self): +@dataclass +class SeedElectrumMnemonicLengthScreen(ButtonListScreen): + text: str = "" + + def __post_init__(self): + self.is_bottom_list = True + super().__post_init__() + + self.components.append(TextArea( + text=self.text, + screen_y=self.top_nav.height, + )) + + + @dataclass class SeedAddressVerificationScreen(ButtonListScreen): """ diff --git a/src/seedsigner/models/seed.py b/src/seedsigner/models/seed.py index 2218ae6cd..70979a5c2 100644 --- a/src/seedsigner/models/seed.py +++ b/src/seedsigner/models/seed.py @@ -170,18 +170,26 @@ def __eq__(self, other): class ElectrumSeed(Seed): def _generate_seed(self): - if len(self._mnemonic) != 12: - raise InvalidSeedException(f"Unsupported Electrum seed length: {len(self._mnemonic)}") s = hmac.digest(b"Seed version", self.mnemonic_str.encode('utf8'), hashlib.sha512).hex() prefix = s[0:3] # only support Electrum Segwit version for now if SettingsConstants.ELECTRUM_SEED_SEGWIT == prefix: - self.seed_bytes=hashlib.pbkdf2_hmac('sha512', self.mnemonic_str.encode('utf-8'), b'electrum' + self._passphrase.encode('utf-8'), iterations = SettingsConstants.ELECTRUM_PBKDF2_ROUNDS) + self._singlesig_derivation = "m/0h" + self._multisig_derivation = "m/1h" + self._script_override = SettingsConstants.NATIVE_SEGWIT + self._electrum_seed_type = SettingsConstants.ELECTRUM_SEED_SEGWIT + + elif prefix.startswith(SettingsConstants.ELECTRUM_SEED_STANDARD): + self._singlesig_derivation = "m" + self._multisig_derivation = "m" + self._script_override = SettingsConstants.LEGACY_P2PKH + self._electrum_seed_type = SettingsConstants.ELECTRUM_SEED_STANDARD else: raise InvalidSeedException(f"Unsupported Electrum seed format: {prefix}") + self.seed_bytes=hashlib.pbkdf2_hmac('sha512', self.mnemonic_str.encode('utf-8'), b'electrum' + self._passphrase.encode('utf-8'), iterations = SettingsConstants.ELECTRUM_PBKDF2_ROUNDS) def set_passphrase(self, passphrase: str, regenerate_seed: bool = True): @@ -209,16 +217,19 @@ def normalize_electrum_passphrase(passphrase : str) -> str: @property def script_override(self) -> str: - return SettingsConstants.NATIVE_SEGWIT + return self._script_override def derivation_override(self, sig_type: str = SettingsConstants.SINGLE_SIG) -> str: - return "m/0h" if sig_type == SettingsConstants.SINGLE_SIG else "m/1h" + return self._singlesig_derivation if SettingsConstants.SINGLE_SIG == sig_type else self._multisig_derivation def detect_version(self, derivation_path: str, network: str = SettingsConstants.MAINNET, sig_type: str = SettingsConstants.SINGLE_SIG) -> str: embit_network = NETWORKS[SettingsConstants.map_network_to_embit(network)] - return embit_network["zpub"] if sig_type == SettingsConstants.SINGLE_SIG else embit_network["Zpub"] + if SettingsConstants.ELECTRUM_SEED_SEGWIT == self._electrum_seed_type: + return embit_network["zpub"] if SettingsConstants.SINGLE_SIG == sig_type else embit_network["Zpub"] + else: + return embit_network["xpub"] @property diff --git a/src/seedsigner/models/settings_definition.py b/src/seedsigner/models/settings_definition.py index 089a94b21..4cc618d81 100644 --- a/src/seedsigner/models/settings_definition.py +++ b/src/seedsigner/models/settings_definition.py @@ -475,7 +475,6 @@ class SettingsDefinition: attr_name=SettingsConstants.SETTING__ELECTRUM_SEEDS, abbreviated_name="electrum", display_name="Electrum seeds", - help_text="Native Segwit only", visibility=SettingsConstants.VISIBILITY__ADVANCED, default_value=SettingsConstants.OPTION__DISABLED), diff --git a/src/seedsigner/views/seed_views.py b/src/seedsigner/views/seed_views.py index 9483c1119..798b2e23f 100644 --- a/src/seedsigner/views/seed_views.py +++ b/src/seedsigner/views/seed_views.py @@ -492,6 +492,37 @@ def run(self): self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True) + return Destination(SeedElectrumMnemonicLengthView) + + + +class SeedElectrumMnemonicLengthView(View): + TYPE_12WORD = "12-word Electrum seed" + TYPE_13WORD = "13-word Electrum seed" + + def run(self): + button_data = [ + self.TYPE_12WORD, + self.TYPE_13WORD, + ] + + selected_menu_num = self.run_screen( + seed_screens.SeedElectrumMnemonicLengthScreen, + title="Seed length", + text="Electrum seed length. Note: 13th word does NOT refer to the custom extension (passphrase). See docs if unsure.", + is_button_text_centered=False, + button_data=button_data, + show_back_button=True, + ) + + if RET_CODE__BACK_BUTTON == selected_menu_num: + return Destination(BackStackView) + + elif button_data[selected_menu_num] == self.TYPE_12WORD: + self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True) + elif button_data[selected_menu_num] == self.TYPE_13WORD: + self.controller.storage.init_pending_mnemonic(num_words=13, is_electrum=True) + return Destination(SeedMnemonicEntryView) diff --git a/tests/test_flows_psbt.py b/tests/test_flows_psbt.py index 964b0d67b..57f4154b2 100644 --- a/tests/test_flows_psbt.py +++ b/tests/test_flows_psbt.py @@ -74,6 +74,7 @@ def load_psbt_into_decoder(view: scan_views.ScanView): FlowStep(scan_views.ScanView, before_run=load_psbt_into_decoder), # simulate read PSBT; ret val is ignored FlowStep(psbt_views.PSBTSelectSeedView, button_data_selection=psbt_views.PSBTSelectSeedView.TYPE_ELECTRUM), FlowStep(seed_views.SeedElectrumMnemonicStartView), + FlowStep(seed_views.SeedElectrumMnemonicLengthView, button_data_selection=seed_views.SeedElectrumMnemonicLengthView.TYPE_12WORD), ] # Load the associated Electrum mnemonic during the flow diff --git a/tests/test_flows_seed.py b/tests/test_flows_seed.py index f6ef501d4..16825fc39 100644 --- a/tests/test_flows_seed.py +++ b/tests/test_flows_seed.py @@ -131,11 +131,14 @@ def test_with_mnemonic(mnemonic: list[str], custom_extension: str = None, expect settings = Settings.get_instance() settings.set_value(SettingsConstants.SETTING__ELECTRUM_SEEDS, SettingsConstants.OPTION__ENABLED) + length_choice = seed_views.SeedElectrumMnemonicLengthView.TYPE_13WORD if 13==len(mnemonic) else seed_views.SeedElectrumMnemonicLengthView.TYPE_12WORD + sequence = [ FlowStep(MainMenuView, button_data_selection=MainMenuView.SEEDS), FlowStep(seed_views.SeedsMenuView, is_redirect=True), # When no seeds are loaded it auto-redirects to LoadSeedView FlowStep(seed_views.LoadSeedView, button_data_selection=seed_views.LoadSeedView.TYPE_ELECTRUM), FlowStep(seed_views.SeedElectrumMnemonicStartView), # Warning screen; no relevant button data selection. + FlowStep(seed_views.SeedElectrumMnemonicLengthView, button_data_selection=length_choice), ] # Now add each manual word entry step @@ -175,6 +178,9 @@ def test_with_mnemonic(mnemonic: list[str], custom_extension: str = None, expect test_with_mnemonic("basket print toy noodle betray weird filter ticket insect copy force machine".split(), custom_extension="test") test_with_mnemonic("basket print toy noodle betray weird filter ticket insect copy force machine".split(), custom_extension="monkey fling orange coin good") + # Test 13 word seed generated by Electrum v2 + test_with_mnemonic("usual burger donate pig aim cycle expose economy pause hint argue dish ability".split()) + # Most BIP-39 seeds should fail; test seed generated by bitcoiner.guide test_with_mnemonic("pioneer divide volcano art victory family grow novel mandate bicycle senior adjust".split(), expects_electrum_seed_is_valid=False) diff --git a/tests/test_flows_tools.py b/tests/test_flows_tools.py index 588859bea..6feb86e9b 100644 --- a/tests/test_flows_tools.py +++ b/tests/test_flows_tools.py @@ -84,6 +84,7 @@ def test__address_explorer__load_electrum_seed__sideflow(self): FlowStep(tools_views.ToolsMenuView, button_data_selection=tools_views.ToolsMenuView.ADDRESS_EXPLORER), FlowStep(tools_views.ToolsAddressExplorerSelectSourceView, button_data_selection=tools_views.ToolsAddressExplorerSelectSourceView.TYPE_ELECTRUM), FlowStep(seed_views.SeedElectrumMnemonicStartView), + FlowStep(seed_views.SeedElectrumMnemonicLengthView, button_data_selection=seed_views.SeedElectrumMnemonicLengthView.TYPE_12WORD), ] # Load an Electrum mnemonic during the flow (same one used in test_seed.py) diff --git a/tests/test_seed.py b/tests/test_seed.py index 4dd8af930..f87993a79 100644 --- a/tests/test_seed.py +++ b/tests/test_seed.py @@ -38,9 +38,9 @@ def test_seed(): # assert seed.passphrase == "test" -def test_electrum_seed(): +def test_electrum_segwit_seed(): """ - ElectrumSeed should correctly parse a modern Electrum mnemonic. + ElectrumSeed should correctly parse a Native Segwit Electrum mnemonic. """ seed = ElectrumSeed(mnemonic="regular reject rare profit once math fringe chase until ketchup century escape".split()) @@ -49,18 +49,15 @@ def test_electrum_seed(): assert seed.seed_bytes == intended_seed -def test_electrum_mnemonic_format(): +def test_electrum_standard_seed(): """ - ElectrumSeed should reject mnemonics that are not 12 words long. + ElectrumSeed should correctly parse a Standard Electrum mnemonic. """ - with pytest.raises(InvalidSeedException): - ElectrumSeed(mnemonic=["regular"] * 11) + seed = ElectrumSeed(mnemonic="valve attack fence zero swim frequent visa myth tobacco dismiss useless marble".split()) - with pytest.raises(InvalidSeedException): - ElectrumSeed(mnemonic=["regular"] * 13) + intended_seed = b'\x0c$\x97\xb1r\x11{\xdf\xa8\xe6\xb8\xa7!_\xf6\xb9\xacz\x08\xbe5Fa\xeb\xd6\xb7.#\xb6:=\xf7_hZY\xc2\x9b:W\xdc!f\x16\x7f\x98\x99k\x90\x8f1t>Qq\xeb\xf3\x96@\x91}\x19\x1cy' - with pytest.raises(InvalidSeedException): - ElectrumSeed(mnemonic=["regular"] * 24) + assert seed.seed_bytes == intended_seed def test_electrum_seed_rejects_most_bip39_mnemonics(): From a532362a17617659ad5af73e89fbcdce7c255bed Mon Sep 17 00:00:00 2001 From: BamaHodl Date: Sat, 20 Jul 2024 10:35:51 -0500 Subject: [PATCH 2/4] updating electrum support documentation --- README.md | 2 +- docs/electrum.md | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 59fe0d805..9d0fd7339 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ If you have specific questions about the project, our [Telegram Group](https://t * Optimized seed word entry interface * Support for Bitcoin Mainnet & Testnet * Support for custom user-defined derivation paths -* Support for loading Electrum Segwit seed phrases with feature limitations: [Electrum support info](docs/electrum.md) +* Support for loading Electrum seed phrases with feature limitations: [Electrum support info](docs/electrum.md) * On-demand receive address verification * Address Explorer for single sig and multisig wallets * User-configurable QR code display density diff --git a/docs/electrum.md b/docs/electrum.md index 6c07ca31b..9ff27e023 100644 --- a/docs/electrum.md +++ b/docs/electrum.md @@ -1,9 +1,11 @@ # SeedSigner Electrum seed phrase support -SeedSigner supports loading of [Electrum's Segwit seed phrases](https://electrum.readthedocs.io/en/latest/seedphrase.html#electrum-seed-version-system). This is considered an Advanced feature that is disabled by default. +SeedSigner supports loading of [Electrum's Standard(P2PKH) and Native Segwit seed phrases](https://electrum.readthedocs.io/en/latest/seedphrase.html#electrum-seed-version-system). The "old" mnemonics used prior to Electrum wallet software version 2.0 are not currently supported. To load an Electrum Segwit seed phrase, first enable Electrum seed support in Settings -> Advanced -> Electrum seed support. After this option is enabled, the user will now be able to enter an Electrum seed phrase by selecting "Enter Electrum seed" in the Load Seed screen. +The user has the option to load a 12 word or 13 word seed phrase. Note that the 13th word does NOT refer to the custom extension words (passphrase), but rather Electrum wallet software used 13 word seed phrases from version 2.0 up until prior to version 2.7. If you need to enter the words you used for "Extend this seed with custom words" in the electrum software, first enter the seed, then before finalizing you will be given the option to add a custom extension similar to the workflow for entering a BIP-39 seed and BIP-39 passphrase. + Some SeedSigner functionality is deliberately disabled when using an Electrum mnemonic: - BIP-85 child seeds From a261cd60c272f11a0ac043f6850631b7c5ff9ad1 Mon Sep 17 00:00:00 2001 From: BamaHodl Date: Fri, 30 Aug 2024 17:18:46 -0500 Subject: [PATCH 3/4] Move electrum seed length selection to the setting entry where users can choose one of Disabled, 12 Words, 13 Words --- docs/electrum.md | 2 +- src/seedsigner/models/settings_definition.py | 13 ++++++- src/seedsigner/views/seed_views.py | 37 +++++++------------- src/seedsigner/views/tools_views.py | 2 +- 4 files changed, 26 insertions(+), 28 deletions(-) diff --git a/docs/electrum.md b/docs/electrum.md index 9ff27e023..d4d5b48e6 100644 --- a/docs/electrum.md +++ b/docs/electrum.md @@ -2,7 +2,7 @@ SeedSigner supports loading of [Electrum's Standard(P2PKH) and Native Segwit seed phrases](https://electrum.readthedocs.io/en/latest/seedphrase.html#electrum-seed-version-system). The "old" mnemonics used prior to Electrum wallet software version 2.0 are not currently supported. -To load an Electrum Segwit seed phrase, first enable Electrum seed support in Settings -> Advanced -> Electrum seed support. After this option is enabled, the user will now be able to enter an Electrum seed phrase by selecting "Enter Electrum seed" in the Load Seed screen. +To load an Electrum Segwit seed phrase, first enable Electrum seed support in Settings -> Advanced -> Electrum seed support. After an electrum seed length is selected, the user will now be able to enter an Electrum seed phrase by selecting "Enter Electrum seed" in the Load Seed screen. The user has the option to load a 12 word or 13 word seed phrase. Note that the 13th word does NOT refer to the custom extension words (passphrase), but rather Electrum wallet software used 13 word seed phrases from version 2.0 up until prior to version 2.7. If you need to enter the words you used for "Extend this seed with custom words" in the electrum software, first enter the seed, then before finalizing you will be given the option to add a custom extension similar to the workflow for entering a BIP-39 seed and BIP-39 passphrase. diff --git a/src/seedsigner/models/settings_definition.py b/src/seedsigner/models/settings_definition.py index 4cc618d81..c1fad2576 100644 --- a/src/seedsigner/models/settings_definition.py +++ b/src/seedsigner/models/settings_definition.py @@ -205,6 +205,14 @@ def map_network_to_embit(cls, network) -> str: ELECTRUM_SEED_SEGWIT = "100" ELECTRUM_SEED_2FA = "101" ELECTRUM_PBKDF2_ROUNDS=2048 + ELECTRUM_SEED_NONE="electrum_none" + ELECTRUM_SEED_12WORD="electrum_12w" + ELECTRUM_SEED_13WORD="electrum_13w" + ALL_ELECTRUM_SEEDS = [ + (ELECTRUM_SEED_NONE, "Disabled"), + (ELECTRUM_SEED_12WORD, "12 Word Seeds"), + (ELECTRUM_SEED_13WORD, "13 Word Seeds"), + ] # Label strings LABEL__BIP39_PASSPHRASE = "BIP-39 Passphrase" @@ -475,8 +483,11 @@ class SettingsDefinition: attr_name=SettingsConstants.SETTING__ELECTRUM_SEEDS, abbreviated_name="electrum", display_name="Electrum seeds", + help_text="Most Electrum seeds are 12 words, see docs if unsure", + type=SettingsConstants.TYPE__SELECT_1, + selection_options=SettingsConstants.ALL_ELECTRUM_SEEDS, visibility=SettingsConstants.VISIBILITY__ADVANCED, - default_value=SettingsConstants.OPTION__DISABLED), + default_value=SettingsConstants.ELECTRUM_SEED_NONE), SettingsEntry(category=SettingsConstants.CATEGORY__FEATURES, attr_name=SettingsConstants.SETTING__MESSAGE_SIGNING, diff --git a/src/seedsigner/views/seed_views.py b/src/seedsigner/views/seed_views.py index 798b2e23f..3ba4ff011 100644 --- a/src/seedsigner/views/seed_views.py +++ b/src/seedsigner/views/seed_views.py @@ -121,7 +121,7 @@ def run(self): button_data.append(self.TYPE_12WORD) button_data.append(self.TYPE_24WORD) - if self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS) == SettingsConstants.OPTION__ENABLED: + if SettingsConstants.ELECTRUM_SEED_NONE != self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS): button_data.append(self.TYPE_ELECTRUM) selected_menu_num = self.run_screen( @@ -181,7 +181,7 @@ def run(self): self.TYPE_24WORD, ] - if self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS) == SettingsConstants.OPTION__ENABLED: + if SettingsConstants.ELECTRUM_SEED_NONE != self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS): button_data.append(self.TYPE_ELECTRUM) button_data.append(self.CREATE) @@ -492,7 +492,7 @@ def run(self): self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True) - return Destination(SeedElectrumMnemonicLengthView) + return Destination(SeedElectrumMnemonicLengthView, skip_current_view=True) @@ -500,30 +500,17 @@ class SeedElectrumMnemonicLengthView(View): TYPE_12WORD = "12-word Electrum seed" TYPE_13WORD = "13-word Electrum seed" - def run(self): - button_data = [ - self.TYPE_12WORD, - self.TYPE_13WORD, - ] - - selected_menu_num = self.run_screen( - seed_screens.SeedElectrumMnemonicLengthScreen, - title="Seed length", - text="Electrum seed length. Note: 13th word does NOT refer to the custom extension (passphrase). See docs if unsure.", - is_button_text_centered=False, - button_data=button_data, - show_back_button=True, - ) - - if RET_CODE__BACK_BUTTON == selected_menu_num: - return Destination(BackStackView) - - elif button_data[selected_menu_num] == self.TYPE_12WORD: - self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True) - elif button_data[selected_menu_num] == self.TYPE_13WORD: + def __init__(self): + super().__init__() + enabled_electrum_length = self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS) + if SettingsConstants.ELECTRUM_SEED_13WORD == enabled_electrum_length: self.controller.storage.init_pending_mnemonic(num_words=13, is_electrum=True) + else: + self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True) + + self.set_redirect(Destination(SeedMnemonicEntryView)) + return - return Destination(SeedMnemonicEntryView) diff --git a/src/seedsigner/views/tools_views.py b/src/seedsigner/views/tools_views.py index eabb1171c..d4521f3fb 100644 --- a/src/seedsigner/views/tools_views.py +++ b/src/seedsigner/views/tools_views.py @@ -452,7 +452,7 @@ def run(self): button_str = seed.get_fingerprint(self.settings.get_value(SettingsConstants.SETTING__NETWORK)) button_data.append((button_str, SeedSignerIconConstants.FINGERPRINT)) button_data = button_data + [self.SCAN_SEED, self.SCAN_DESCRIPTOR, self.TYPE_12WORD, self.TYPE_24WORD] - if self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS) == SettingsConstants.OPTION__ENABLED: + if SettingsConstants.ELECTRUM_SEED_NONE != self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS): button_data.append(self.TYPE_ELECTRUM) selected_menu_num = self.run_screen( From 87333ef6f7a42d51e26d1c26f4622a0a887ac75b Mon Sep 17 00:00:00 2001 From: BamaHodl Date: Fri, 30 Aug 2024 18:12:49 -0500 Subject: [PATCH 4/4] removing electrum length screen and views now that it's in settings and updating affected tests --- src/seedsigner/gui/screens/seed_screens.py | 15 --------------- src/seedsigner/views/seed_views.py | 15 +-------------- tests/test_flows_psbt.py | 1 - tests/test_flows_seed.py | 6 +++--- tests/test_flows_tools.py | 1 - 5 files changed, 4 insertions(+), 34 deletions(-) diff --git a/src/seedsigner/gui/screens/seed_screens.py b/src/seedsigner/gui/screens/seed_screens.py index c9ff80c58..64fb7ea98 100644 --- a/src/seedsigner/gui/screens/seed_screens.py +++ b/src/seedsigner/gui/screens/seed_screens.py @@ -1359,21 +1359,6 @@ def __post_init__(self): -@dataclass -class SeedElectrumMnemonicLengthScreen(ButtonListScreen): - text: str = "" - - def __post_init__(self): - self.is_bottom_list = True - super().__post_init__() - - self.components.append(TextArea( - text=self.text, - screen_y=self.top_nav.height, - )) - - - @dataclass class SeedAddressVerificationScreen(ButtonListScreen): """ diff --git a/src/seedsigner/views/seed_views.py b/src/seedsigner/views/seed_views.py index 3ba4ff011..af8c1815e 100644 --- a/src/seedsigner/views/seed_views.py +++ b/src/seedsigner/views/seed_views.py @@ -490,26 +490,13 @@ def run(self): show_back_button=False, ) - self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True) - - return Destination(SeedElectrumMnemonicLengthView, skip_current_view=True) - - - -class SeedElectrumMnemonicLengthView(View): - TYPE_12WORD = "12-word Electrum seed" - TYPE_13WORD = "13-word Electrum seed" - - def __init__(self): - super().__init__() enabled_electrum_length = self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS) if SettingsConstants.ELECTRUM_SEED_13WORD == enabled_electrum_length: self.controller.storage.init_pending_mnemonic(num_words=13, is_electrum=True) else: self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True) - self.set_redirect(Destination(SeedMnemonicEntryView)) - return + return Destination(SeedMnemonicEntryView, skip_current_view=True) diff --git a/tests/test_flows_psbt.py b/tests/test_flows_psbt.py index 57f4154b2..964b0d67b 100644 --- a/tests/test_flows_psbt.py +++ b/tests/test_flows_psbt.py @@ -74,7 +74,6 @@ def load_psbt_into_decoder(view: scan_views.ScanView): FlowStep(scan_views.ScanView, before_run=load_psbt_into_decoder), # simulate read PSBT; ret val is ignored FlowStep(psbt_views.PSBTSelectSeedView, button_data_selection=psbt_views.PSBTSelectSeedView.TYPE_ELECTRUM), FlowStep(seed_views.SeedElectrumMnemonicStartView), - FlowStep(seed_views.SeedElectrumMnemonicLengthView, button_data_selection=seed_views.SeedElectrumMnemonicLengthView.TYPE_12WORD), ] # Load the associated Electrum mnemonic during the flow diff --git a/tests/test_flows_seed.py b/tests/test_flows_seed.py index 16825fc39..a2e43ee36 100644 --- a/tests/test_flows_seed.py +++ b/tests/test_flows_seed.py @@ -129,16 +129,16 @@ def test_electrum_mnemonic_entry_flow(self): def test_with_mnemonic(mnemonic: list[str], custom_extension: str = None, expects_electrum_seed_is_valid: bool = True): Settings.HOSTNAME = "not seedsigner-os" settings = Settings.get_instance() - settings.set_value(SettingsConstants.SETTING__ELECTRUM_SEEDS, SettingsConstants.OPTION__ENABLED) - length_choice = seed_views.SeedElectrumMnemonicLengthView.TYPE_13WORD if 13==len(mnemonic) else seed_views.SeedElectrumMnemonicLengthView.TYPE_12WORD + length_choice = SettingsConstants.ELECTRUM_SEED_13WORD if 13==len(mnemonic) else SettingsConstants.ELECTRUM_SEED_12WORD + settings.set_value(SettingsConstants.SETTING__ELECTRUM_SEEDS, length_choice) + sequence = [ FlowStep(MainMenuView, button_data_selection=MainMenuView.SEEDS), FlowStep(seed_views.SeedsMenuView, is_redirect=True), # When no seeds are loaded it auto-redirects to LoadSeedView FlowStep(seed_views.LoadSeedView, button_data_selection=seed_views.LoadSeedView.TYPE_ELECTRUM), FlowStep(seed_views.SeedElectrumMnemonicStartView), # Warning screen; no relevant button data selection. - FlowStep(seed_views.SeedElectrumMnemonicLengthView, button_data_selection=length_choice), ] # Now add each manual word entry step diff --git a/tests/test_flows_tools.py b/tests/test_flows_tools.py index 6feb86e9b..588859bea 100644 --- a/tests/test_flows_tools.py +++ b/tests/test_flows_tools.py @@ -84,7 +84,6 @@ def test__address_explorer__load_electrum_seed__sideflow(self): FlowStep(tools_views.ToolsMenuView, button_data_selection=tools_views.ToolsMenuView.ADDRESS_EXPLORER), FlowStep(tools_views.ToolsAddressExplorerSelectSourceView, button_data_selection=tools_views.ToolsAddressExplorerSelectSourceView.TYPE_ELECTRUM), FlowStep(seed_views.SeedElectrumMnemonicStartView), - FlowStep(seed_views.SeedElectrumMnemonicLengthView, button_data_selection=seed_views.SeedElectrumMnemonicLengthView.TYPE_12WORD), ] # Load an Electrum mnemonic during the flow (same one used in test_seed.py)