Skip to content

Commit 2217a6b

Browse files
committed
add seed type differentiation
1 parent 9a20864 commit 2217a6b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

src/seedsigner/models/seed.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ class InvalidSeedException(Exception):
1919

2020

2121
class Seed:
22+
TYPE__BIP39 = "bip39"
23+
TYPE__ELECTRUM = "electrum"
24+
2225
def __init__(self,
2326
mnemonic: List[str] = None,
2427
passphrase: str = "",

src/seedsigner/views/seed_views.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -209,18 +209,19 @@ def run(self):
209209

210210

211211
class SeedMnemonicEntryView(View):
212-
def __init__(self, cur_word_index: int = 0, is_calc_final_word: bool=False):
212+
def __init__(self, cur_word_index: int = 0, is_calc_final_word: bool=False, seed_type: str = Seed.TYPE__BIP39):
213213
super().__init__()
214214
self.cur_word_index = cur_word_index
215215
self.cur_word = self.controller.storage.get_pending_mnemonic_word(cur_word_index)
216216
self.is_calc_final_word = is_calc_final_word
217+
self.seed_type = seed_type
217218

218219

219220
def run(self):
220221
is_final_word = (
221222
self.cur_word_index == self.controller.storage.pending_mnemonic_length - 1 and
222223
not self.is_calc_final_word and
223-
self.settings.get_value(SettingsConstants.SETTING__ELECTRUM_SEEDS) == SettingsConstants.OPTION__DISABLED
224+
self.seed_type == Seed.TYPE__BIP39
224225
)
225226

226227
partial_mnemonic = None
@@ -264,7 +265,8 @@ def run(self):
264265
SeedMnemonicEntryView,
265266
view_args={
266267
"cur_word_index": self.cur_word_index + 1,
267-
"is_calc_final_word": self.is_calc_final_word
268+
"is_calc_final_word": self.is_calc_final_word,
269+
"seed_type": self.seed_type
268270
}
269271
)
270272
else:
@@ -299,7 +301,8 @@ def run(self):
299301
)
300302

301303
if button_data[selected_menu_num] == self.EDIT:
302-
return Destination(SeedMnemonicEntryView, view_args={"cur_word_index": 0})
304+
seed_type = Seed.TYPE__ELECTRUM if self.controller.storage._pending_is_electrum else Seed.TYPE__BIP39
305+
return Destination(SeedMnemonicEntryView, view_args={"cur_word_index": 0, "seed_type": seed_type})
303306

304307
elif button_data[selected_menu_num] == self.DISCARD:
305308
self.controller.storage.discard_pending_mnemonic()
@@ -526,7 +529,7 @@ def run(self):
526529

527530
self.controller.storage.init_pending_mnemonic(num_words=12, is_electrum=True)
528531

529-
return Destination(SeedMnemonicEntryView)
532+
return Destination(SeedMnemonicEntryView, view_args={"seed_type": Seed.TYPE__ELECTRUM})
530533

531534

532535

0 commit comments

Comments
 (0)