Skip to content

Commit

Permalink
contd-impl. of dipunm's feedback in issue SeedSigner#43
Browse files Browse the repository at this point in the history
    * cleanup: get_seedxor_seeds() replaces redundant cut/pastes
    * bugfix: back from SeedXOR to Finalize, not Scan
  • Loading branch information
Jean Do committed Jan 19, 2023
1 parent dd9928a commit c0fc09a
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/seedsigner/views/seed_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,17 @@



def get_seedxor_seeds(seed, other_seeds):
"""returns list of candidate seeds for SeedXOR"""
candidate_seeds = []
for other in other_seeds:
if len(other.mnemonic_list) == len(seed.mnemonic_list) \
and other.mnemonic_list != seed.mnemonic_list \
and len(other.passphrase) == 0:
candidate_seeds.append(other)
return candidate_seeds



class SeedsMenuView(View):
def __init__(self):
Expand Down Expand Up @@ -221,10 +232,7 @@ def run(self):
button_data.append(PASSPHRASE)

if self.settings.get_value(SettingsConstants.SETTING__SEED_XOR) == SettingsConstants.OPTION__ENABLED \
and len([x for x in self.controller.storage.seeds # todo: in 3 places, make it just 1
if len(x.mnemonic_list) == len(self.seed.mnemonic_list) \
and x.mnemonic_list != self.seed.mnemonic_list \
and len(x.passphrase) == 0]):
and len(get_seedxor_seeds(self.seed, self.controller.storage.seeds)):
button_data.append(SEED_XOR)

selected_menu_num = seed_screens.SeedFinalizeScreen(
Expand All @@ -240,7 +248,7 @@ def run(self):
return Destination(SeedAddPassphraseView)

elif button_data[selected_menu_num] == SEED_XOR:
return Destination(SeedXORSelectSeedView, skip_current_view=True)
return Destination(SeedXORSelectSeedView)



Expand Down Expand Up @@ -312,10 +320,7 @@ def __init__(self):
self.seed = self.controller.storage.get_pending_seed()

def run(self):
seeds = [x for x in self.controller.storage.seeds # todo: in many places, make it just 1
if len(x.mnemonic_list) == len(self.seed.mnemonic_list) \
and x.mnemonic_list != self.seed.mnemonic_list \
and len(x.passphrase) == 0]
seeds = get_seedxor_seeds(self.seed, self.controller.storage.seeds)
title = "Seed XOR"
text = "Select seed to XOR"
button_data = []
Expand Down Expand Up @@ -343,10 +348,7 @@ class SeedXORApplyView(View):
def __init__(self, seed_num: int = None):
super().__init__()
self.seed = self.controller.storage.get_pending_seed()
seeds = [x for x in self.controller.storage.seeds # todo: in many places, make it just 1
if len(x.mnemonic_list) == len(self.seed.mnemonic_list) \
and x.mnemonic_list != self.seed.mnemonic_list \
and len(x.passphrase) == 0]
seeds = get_seedxor_seeds(self.seed, self.controller.storage.seeds)
if seed_num is not None:
self.other = seeds[seed_num]

Expand Down

0 comments on commit c0fc09a

Please sign in to comment.