Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ From the wonderful land of Korea, a new creation arrives: the WonderK PRO. Creat
### Other Bug Fixes and Improvements
- Added backtick ` to keypad
- Bugfix: Screensaver not activating in menu pages without statusbar
- Screensaver: Now appears on menu screens that display info boxes
- Embit: Improved BIP39 mnemonic validation

# Changelog 25.10.1 - October 2025
Expand Down
7 changes: 5 additions & 2 deletions src/krux/pages/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -651,9 +651,11 @@ def __init__(
disable_statusbar=False,
back_label="Back",
back_status=lambda: MENU_EXIT,
infobox_callback=lambda: None,
):
self.ctx = ctx
self.menu = menu
self.infobox_callback = infobox_callback
if back_label:
back_label = t("Back") if back_label == "Back" else back_label
self.menu += [("< " + back_label, back_status)]
Expand Down Expand Up @@ -785,9 +787,10 @@ def run_loop(self, start_from_index=None, swipe_up_fnc=None, swipe_down_fnc=None
)
if isinstance(selected_item_index, tuple):
return selected_item_index
elif btn is None and self.menu_offset <= STATUS_BAR_HEIGHT:
# Activates screensaver if there's no info_box(other things draw on the screen)
elif btn is None:
# Activate screensaver (it's time!)
self.screensaver()
self.infobox_callback()

def _clicked_item(self, selected_item_index):
item = self.menu_view[selected_item_index]
Expand Down
3 changes: 2 additions & 1 deletion src/krux/pages/datum_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,8 @@ def view_contents(self, try_decrypt=True, offer_convert=False):
self.ctx,
todo_menu,
offset=info_len * FONT_HEIGHT + DEFAULT_PADDING,
**back_status
**back_status,
infobox_callback=self._info_box
)
_, status = menu.run_loop()

Expand Down
46 changes: 25 additions & 21 deletions src/krux/pages/device_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,28 +159,31 @@ def test_suite(self, interactive=False):
wdt.feed()

# info_box summary
self.ctx.display.clear()
failures = len([x for x in self.results if not x[1]])
total = len(self.results)
num_lines = self.ctx.display.draw_hcentered_text(
"\n".join(
[
x
for x in [
t("Test Suite Results"),
t("success rate:")
+ " {}%".format(int((total - failures) / (total) * 100)),
(
t("failed:") + " {}/{}".format(failures, total)
if failures
else None
),
def _print_infobox():
self.ctx.display.clear()
failures = len([x for x in self.results if not x[1]])
total = len(self.results)
return self.ctx.display.draw_hcentered_text(
"\n".join(
[
x
for x in [
t("Test Suite Results"),
t("success rate:")
+ " {}%".format(int((total - failures) / (total) * 100)),
(
t("failed:") + " {}/{}".format(failures, total)
if failures
else None
),
]
if x is not None
]
if x is not None
]
),
info_box=True,
)
),
info_box=True,
)
Comment on lines +162 to +184
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


num_lines = _print_infobox()

# results menu
line_fmt = "{:" + str(chars_per_line - 3) + "s} {:>2s}"
Expand All @@ -201,6 +204,7 @@ def test_suite(self, interactive=False):
for x in self.results
],
offset=(num_lines + 1) * FONT_HEIGHT,
infobox_callback=_print_infobox,
)
idx, _ = results_menu.run_loop()
if idx == len(self.results):
Expand Down
17 changes: 10 additions & 7 deletions src/krux/pages/home_pages/bip85.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,19 @@ def _derive_base64_password(self):
),
),
]
self.ctx.display.clear()
info_len = self.ctx.display.draw_hcentered_text(
info, info_box=True, highlight_prefix=":"
)
info_len *= FONT_HEIGHT
info_len += DEFAULT_PADDING

def _print_infobox():
self.ctx.display.clear()
return self.ctx.display.draw_hcentered_text(
info, info_box=True, highlight_prefix=":"
)
Comment on lines +163 to +167
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not define it as a private method in the class instead a anon function?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I defined it inside the function because it’s an implementation detail, not a reusable behavior of the class. Its scope is explicit: it cannot be called from anywhere else.


info_len = _print_infobox()
submenu = Menu(
self.ctx,
menu_items,
offset=info_len,
offset=info_len * FONT_HEIGHT + DEFAULT_PADDING,
infobox_callback=_print_infobox,
)
index, _ = submenu.run_loop()
if index == submenu.back_index:
Expand Down
33 changes: 21 additions & 12 deletions src/krux/pages/home_pages/pub_key_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,28 @@ def _pub_key_text(version):
+ "\n\n"
+ full_pub_key
)

def _print_infobox():
self.ctx.display.clear()
self.ctx.display.draw_hcentered_text(
info_text,
offset_y=FONT_HEIGHT,
info_box=True,
)
self.ctx.display.draw_hcentered_text(
self.ctx.wallet.key.fingerprint_hex_str(pretty=True),
offset_y=FONT_HEIGHT,
color=theme.highlight_color,
bg_color=theme.info_bg_color,
)
Comment on lines +82 to +94
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


_print_infobox()
menu_offset = (len(self.ctx.display.to_lines(info_text)) + 1) * FONT_HEIGHT
pub_key_menu = Menu(self.ctx, pub_text_menu_items, offset=menu_offset)
self.ctx.display.clear()
self.ctx.display.draw_hcentered_text(
info_text,
offset_y=FONT_HEIGHT,
info_box=True,
)
self.ctx.display.draw_hcentered_text(
self.ctx.wallet.key.fingerprint_hex_str(pretty=True),
offset_y=FONT_HEIGHT,
color=theme.highlight_color,
bg_color=theme.info_bg_color,
pub_key_menu = Menu(
self.ctx,
pub_text_menu_items,
offset=menu_offset,
infobox_callback=_print_infobox,
)
pub_key_menu.run_loop()

Expand Down
51 changes: 29 additions & 22 deletions src/krux/pages/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def new_key_from_snapshot(self):
return self._load_key_from_words(entropy_mnemonic.split(), new=True)
return MENU_CONTINUE

# pylint: disable=too-many-locals
def _load_key_from_words(self, words, charset=LETTERS, new=False):
mnemonic = " ".join(words)

Expand All @@ -218,7 +219,6 @@ def _load_key_from_words(self, words, charset=LETTERS, new=False):
if mnemonic is None:
return MENU_CONTINUE

passphrase = ""
if not hasattr(Settings().wallet, "policy_type") and hasattr(
Settings().wallet, "multisig"
):
Expand Down Expand Up @@ -257,6 +257,7 @@ def _load_key_from_words(self, words, charset=LETTERS, new=False):
Settings().wallet.script_type, P2WSH
)

passphrase = ""
derivation_path = ""

from ..wallet import Wallet
Expand Down Expand Up @@ -287,34 +288,40 @@ def _load_key_from_words(self, words, charset=LETTERS, new=False):
else t("Passphrase") + " (%d): *…*" % len(passphrase)
)

self.ctx.display.clear()
def _print_infobox():
self.ctx.display.clear()
num_lines = self.ctx.display.draw_hcentered_text(
wallet_info, info_box=True
)

# 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 num_lines
Comment on lines +291 to +312
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.


num_lines = _print_infobox()

submenu = Menu(
self.ctx,
[
(t("Load Wallet"), lambda: None),
(t("Passphrase"), lambda: None),
(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,
offset=num_lines * FONT_HEIGHT + DEFAULT_PADDING,
infobox_callback=_print_infobox,
)

index, _ = submenu.run_loop()
Expand Down
26 changes: 16 additions & 10 deletions src/krux/pages/new_mnemonic/dice_rolls.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,25 +308,31 @@ def delete_roll(buffer):
entropy = (
"".join(self.rolls) if self.num_sides < 10 else "-".join(self.rolls)
)
self.ctx.display.clear()
rolls_str = "\n\n%s" % entropy
max_lines = TOTAL_LINES - 6 # room for menu
menu_offset = self.ctx.display.draw_hcentered_text(
rolls_str, info_box=True, max_lines=max_lines
)
self.ctx.display.draw_hcentered_text(
t("Rolls:"), color=theme.highlight_color, bg_color=theme.info_bg_color
)
menu_offset *= FONT_HEIGHT
menu_offset += DEFAULT_PADDING

def _print_infobox():
self.ctx.display.clear()
n_lines = self.ctx.display.draw_hcentered_text(
rolls_str, info_box=True, max_lines=max_lines
)
self.ctx.display.draw_hcentered_text(
t("Rolls:"),
color=theme.highlight_color,
bg_color=theme.info_bg_color,
)
return n_lines
Comment on lines +314 to +324
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


menu_offset = _print_infobox()
submenu = Menu(
self.ctx,
[
(t("Stats for Nerds"), lambda: MENU_EXIT),
(t("Generate Mnemonic"), lambda: MENU_EXIT),
],
offset=menu_offset,
offset=menu_offset * FONT_HEIGHT + DEFAULT_PADDING,
back_label=None,
infobox_callback=_print_infobox,
)
index, _ = submenu.run_loop()
if index == 0:
Expand Down
21 changes: 16 additions & 5 deletions src/krux/pages/qr_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,10 +460,15 @@ def save_qr_image_menu(self):
resolution *= 2
if resolution <= 480:
bmp_resolutions.append(resolution)
self.ctx.display.clear()
self.ctx.display.draw_hcentered_text(
t("Res. - Format"), FONT_HEIGHT, info_box=True
)

def _print_infobox():
self.ctx.display.clear()
self.ctx.display.draw_hcentered_text(
t("Res. - Format"), FONT_HEIGHT, info_box=True
)
Comment on lines +464 to +468
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same Here


_print_infobox()

qr_menu = []
qr_menu.append(
(
Expand All @@ -486,7 +491,13 @@ def save_qr_image_menu(self):
lambda: self.save_svg_image(suggested_file_name),
)
)
submenu = Menu(self.ctx, qr_menu, offset=2 * FONT_HEIGHT, back_label=None)
submenu = Menu(
self.ctx,
qr_menu,
offset=2 * FONT_HEIGHT,
back_label=None,
infobox_callback=_print_infobox,
)
submenu.run_loop()
return MENU_CONTINUE
# return MENU_EXIT # Use this to exit QR Viewer after saving
Expand Down
27 changes: 18 additions & 9 deletions src/krux/pages/wallet_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,24 @@ def customize_wallet(self, key):
network_name, policy_type, script_type, derivation_path
)

self.ctx.display.clear()
derivation_path = self.fit_to_line(derivation_path, crop_middle=False)
info_len = self.ctx.display.draw_hcentered_text(wallet_info, info_box=True)

def _print_infobox():
self.ctx.display.clear()
n_lines = self.ctx.display.draw_hcentered_text(
wallet_info, info_box=True
)

# draw network with highlight color
self.ctx.display.draw_hcentered_text(
network_name,
color=Utils.get_network_color(network_name),
bg_color=theme.info_bg_color,
)

return n_lines
Comment on lines +200 to +213
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here


info_len = _print_infobox()

# if the wallet is P2SH, we need to change
# the "Account" label to "Cossiger Index"
Expand All @@ -216,13 +231,7 @@ def customize_wallet(self, key):
(account_txt, lambda: None),
],
offset=info_len * FONT_HEIGHT + DEFAULT_PADDING,
)

# draw network with highlight color
self.ctx.display.draw_hcentered_text(
network_name,
color=Utils.get_network_color(network_name),
bg_color=theme.info_bg_color,
infobox_callback=_print_infobox,
)

index, _ = submenu.run_loop()
Expand Down