What changed, and why it matters
This commit is a simple code cleanup: it pulls duplicated code for drawing a wallet information screen into a single reusable helper function. There is no change to what the program does, no new behavior, and no security issue visible in the diff.
No security action needed; this is a routine refactor.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The change refactors two places in src/krux/pages/login.py that created a Menu after clearing the display and drawing wallet info text. The duplicated logic is moved into a new private method _wallet_info_menu(). The call sites now pass key, wallet_info, network_name, and menu_items to this helper. The logic, imports used, and menu behavior remain equivalent. A small functional note: the second call site now increments index by 1 after choosing from the reduced submenu, which preserves the original menu flow mapping.
Changed components
src/krux/pages/login.pyInspect captured patch +41 / −44
diff --git a/src/krux/pages/login.py b/src/krux/pages/login.py
index f8f0bed..fedd3bd 100644
--- a/src/krux/pages/login.py
+++ b/src/krux/pages/login.py
@@ -199,6 +199,38 @@ class Login(MnemonicLoader):
return self._load_key_from_words(entropy_mnemonic.split(), new=True)
return MENU_CONTINUE
+ def _wallet_info_menu(self, key, wallet_info, network_name, menu_items):
+ """Draws the wallet info box and returns a menu placed below it"""
+ from ..themes import theme
+ from .utils import Utils
+
+ self.ctx.display.clear()
+ menu = Menu(
+ self.ctx,
+ menu_items,
+ offset=(
+ self.ctx.display.draw_hcentered_text(wallet_info, info_box=True)
+ * FONT_HEIGHT
+ + DEFAULT_PADDING
+ ),
+ )
+
+ # draw fingerprint with highlight color
+ self.ctx.display.draw_hcentered_text(
+ key.fingerprint_hex_str(True),
+ color=theme.highlight_color,
+ bg_color=theme.info_bg_color,
+ )
+
+ # draw network with highlight color
+ self.ctx.display.draw_hcentered_text(
+ network_name,
+ DEFAULT_PADDING + FONT_HEIGHT,
+ color=Utils.get_network_color(network_name),
+ bg_color=theme.info_bg_color,
+ )
+ return menu
+
def _load_key_from_words(self, words, charset=LETTERS, new=False):
mnemonic = " ".join(words)
@@ -256,7 +288,6 @@ class Login(MnemonicLoader):
derivation_path = ""
from ..wallet import Wallet
- from ..themes import theme
from .utils import Utils
utils = Utils(self.ctx)
@@ -283,9 +314,10 @@ class Login(MnemonicLoader):
else t("Passphrase") + " (%d): *…*" % len(passphrase)
)
- self.ctx.display.clear()
- submenu = Menu(
- self.ctx,
+ submenu = self._wallet_info_menu(
+ key,
+ wallet_info,
+ network_name,
(
[
(t("Continue"), lambda: None),
@@ -298,26 +330,6 @@ class Login(MnemonicLoader):
(t("Customize"), lambda: None),
]
),
- offset=(
- self.ctx.display.draw_hcentered_text(wallet_info, info_box=True)
- * FONT_HEIGHT
- + DEFAULT_PADDING
- ),
- )
-
- # draw fingerprint with highlight color
- self.ctx.display.draw_hcentered_text(
- key.fingerprint_hex_str(True),
- color=theme.highlight_color,
- bg_color=theme.info_bg_color,
- )
-
- # draw network with highlight color
- self.ctx.display.draw_hcentered_text(
- network_name,
- DEFAULT_PADDING + FONT_HEIGHT,
- color=Utils.get_network_color(network_name),
- bg_color=theme.info_bg_color,
)
index, _ = submenu.run_loop()
@@ -329,35 +341,20 @@ class Login(MnemonicLoader):
if index == 0:
break
if new and index == 1:
- self.ctx.display.clear()
- submenu = Menu(
- self.ctx,
+ submenu = self._wallet_info_menu(
+ key,
+ wallet_info,
+ network_name,
[
(t("Passphrase"), lambda: None),
(t("Customize"), lambda: None),
],
- offset=(
- self.ctx.display.draw_hcentered_text(wallet_info, info_box=True)
- * FONT_HEIGHT
- + DEFAULT_PADDING
- ),
- )
-
- self.ctx.display.draw_hcentered_text(
- key.fingerprint_hex_str(True),
- color=theme.highlight_color,
- bg_color=theme.info_bg_color,
- )
- self.ctx.display.draw_hcentered_text(
- network_name,
- DEFAULT_PADDING + FONT_HEIGHT,
- color=Utils.get_network_color(network_name),
- bg_color=theme.info_bg_color,
)
index, _ = submenu.run_loop()
if index == submenu.back_index:
continue
+ # shift onto the Passphrase and Customize arms of the main menu
index += 1
if index == 1:
from .wallet_settings import PassphraseEditor
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.