Skip to content

Commit

Permalink
reinit apps if new key was loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
stepansnigirev committed Nov 15, 2022
1 parent 59bdd6e commit e5bc8b7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/keystore/flash.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ async def init(self, show_fn, show_loader):
await super().init(show_fn, show_loader)

async def storage_menu(self):
"""Manage storage"""
"""Manage storage, return True if new key was loaded"""
buttons = [
# id, text
(None, "Key management"),
Expand All @@ -254,7 +254,7 @@ async def storage_menu(self):
# process the menu button:
# back button
if menuitem == 255:
return
return False
elif menuitem == 0:
await self.save_mnemonic()
await self.show(
Expand All @@ -267,6 +267,7 @@ async def storage_menu(self):
await self.show(
Alert("Success!", "Your key is loaded.", button_text="OK")
)
return True
elif menuitem == 2:
await self.delete_mnemonic()
await self.show(
Expand Down
5 changes: 3 additions & 2 deletions src/keystore/memorycard.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ def hexid(self):
return hexlify(tagged_hash("smartcard/pubkey", self.applet.card_pubkey)[:4]).decode()

async def storage_menu(self):
"""Manage storage"""
"""Manage storage, return True if new key was loaded"""
enabled = self.connection.isCardInserted()
buttons = [
# id, text, enabled, color
Expand All @@ -356,7 +356,7 @@ async def storage_menu(self):
# process the menu button:
# back button
if menuitem == 255:
return
return False
elif menuitem == 0:
await self.save_mnemonic()
await self.show(
Expand All @@ -371,6 +371,7 @@ async def storage_menu(self):
await self.show(
Alert("Success!", "Your key is loaded.", button_text="OK")
)
return True
elif menuitem == 2:
if await self.show(Prompt(
"Are you sure?",
Expand Down
5 changes: 3 additions & 2 deletions src/keystore/sdcard.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ async def export_mnemonic(self):


async def storage_menu(self):
"""Manage storage"""
"""Manage storage, return True if new key was loaded"""
buttons = [
# id, text
(None, "Manage keys on SD card and internal flash"),
Expand All @@ -256,7 +256,7 @@ async def storage_menu(self):
# process the menu button:
# back button
if menuitem == 255:
return
return False
elif menuitem == 0:
filename = await self.save_mnemonic()
if filename:
Expand All @@ -268,6 +268,7 @@ async def storage_menu(self):
await self.show(
Alert("Success!", "Your key is loaded.", button_text="OK")
)
return True
elif menuitem == 2:
if await self.delete_mnemonic():
await self.show(
Expand Down
5 changes: 4 additions & 1 deletion src/specter.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,10 @@ async def settingsmenu(self):
if menuitem == 255:
return self.mainmenu
elif menuitem == 1:
await self.keystore.storage_menu()
res = await self.keystore.storage_menu()
# storage_menu returns True if app reinit is required
if res:
self.init_apps()
elif menuitem == 2:
pwd = await self.gui.get_input()
if pwd is None:
Expand Down

0 comments on commit e5bc8b7

Please sign in to comment.