Skip to content

feat: support attach to pin#355

Closed
guowei0105 wants to merge 19 commits intoOneKeyHQ:mainfrom
guowei0105:passphrase_pin_updated
Closed

feat: support attach to pin#355
guowei0105 wants to merge 19 commits intoOneKeyHQ:mainfrom
guowei0105:passphrase_pin_updated

Conversation

@guowei0105
Copy link
Copy Markdown
Contributor

@guowei0105 guowei0105 commented Jul 16, 2025

Summary by CodeRabbit

  • New Features

    • Introduced an "Attach to PIN" feature linking passphrases with specific PINs for enhanced wallet security.
    • Added comprehensive UI flows for attaching, confirming, and managing passphrase PINs.
    • Added device capabilities, settings, and message types supporting passphrase PIN attachment and state management.
    • Extended CLI and library interfaces for passphrase state queries and device unlocking.
  • Enhancements

    • Improved PIN and passphrase entry UIs with configurable minimum lengths and contextual prompts.
    • Added session and cache management supporting passphrase PIN workflows.
    • Updated translations and user-facing messages for clarity in multi-share backup and PIN/passphrase operations.
    • Refined backup handling with extended SLIP39 support and multi-share backup UI improvements.
    • Enhanced Ethereum app to support Gnosis Safe transaction confirmations.
    • Added haptic feedback to various UI components and events.
    • Improved motor control with new vibration patterns and unified playback methods.
    • Improved address and derivation UI components with new chain support and refactoring.
    • Improved recovery device flow and UI for SLIP39 shares and multi-share backups.
  • Bug Fixes

    • Enhanced error handling and validation during PIN and passphrase setup and confirmation.
    • Improved device lock/unlock flows to respect new passphrase PIN states and session termination.
    • Fixed UI event handling and layout issues in various screens.
    • Corrected mnemonic and backup share validation and confirmation logic.
  • Documentation

    • Updated CLI command documentation and help texts for new device management commands.
  • Chores

    • Refined code structure, constants, and message handling for PIN/passphrase management across the application.
    • Refactored motor, vibration, and UI component APIs for clarity and extensibility.
    • Cleaned up imports and internal module references for better maintainability.
    • Updated protobuf schemas and enums for new features and message types.
    • Improved localization strings across multiple languages for backup and PIN features.

@guowei0105 guowei0105 requested a review from a team as a code owner July 16, 2025 05:32
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jul 16, 2025

Walkthrough

This update introduces a new "attach to pin" feature. It adds new message types, fields, and enums for managing passphrase and PIN attachment. The UI and device logic are extended to support attaching passphrases to PINs, session handling, and related error flows. CLI and Python APIs are updated.

Changes

Files/Paths Change Summary
common/protob/messages-common.proto, core/src/trezor/messages.py, python/src/trezorlib/messages.py New fields for attach pin in passphrase messages; new message types for passphrase state and unlock.
common/protob/messages-management.proto, core/src/trezor/messages.py, python/src/trezorlib/messages.py New fields and messages for passphrase state, PIN attachment, and device unlock.
common/protob/messages.proto, core/src/trezor/messages.py, python/src/trezorlib/messages.py Added/modified message type enums for new passphrase and unlock messages.
core/embed/extmod/modtrezorconfig/modtrezorconfig.c Updated unlock/check_pin functions for pin type and tuple result.
core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h Added session, pin-passphrase, and address check functions/constants.
core/embed/trezorhal/se_thd89.c, core/embed/trezorhal/se_thd89.h Extended PIN/passphrase/session logic, new result enums, new functions for attach pin handling.
core/src/all_modules.py Added imports for attach_to_pin UI and pin constants.
core/src/apps/base.py Added attach-to-pin capability checks, session logic, new handlers for passphrase state/unlock.
core/src/apps/common/passphrase.py New status queries, attach pin flow, on-device attach logic.
core/src/apps/common/pin_constants.py New constants for PIN result, type, and attach pin minimum length.
core/src/apps/common/request_pin.py PIN type support, error handling, UI flow flags, new error function.
core/src/apps/common/seed.py Conditional passphrase retrieval based on passphrase pin status.
core/src/apps/management/change_pin.py, core/src/apps/management/recovery_device/__init__.py, core/src/apps/management/wipe_device.py PIN type logic in verification, translation function update.
core/src/apps/ur_registry/chains/hardware_requests/hardware_call.py Always raise error on fingerprint mismatch.
core/src/apps/ur_registry/helpers.py Append device name suffix if passphrase pin enabled.
core/src/apps/workflow_handlers.py Version compatibility check for address derivation handlers.
core/src/boot.py Explicit PIN type in bootscreen pin verification.
core/src/storage/cache.py New sessionless cache key/field for attach pin client flag.
core/src/storage/device.py New flags and getters/setters for passphrase pin and auto status.
core/src/trezor/enums/ButtonRequestType.py, core/src/trezor/enums/Capability.py, core/src/trezor/enums/MessageType.py, core/src/trezor/enums/__init__.py Added enum values for attach pin, capability, and new message types.
core/src/trezor/lvglui/i18n/locales/ja.py Updated Japanese translation strings for hidden wallet PIN.
core/src/trezor/lvglui/scrs/address.py Store previous session ID after ending cache session.
core/src/trezor/lvglui/scrs/components/keyboard.py PassphraseKeyboard: min_len param, OK button enable/disable logic.
core/src/trezor/lvglui/scrs/components/listitem.py Adjusted text letter spacing.
core/src/trezor/lvglui/scrs/homescreen.py UI/logic for attach-to-pin, session handling, new screens, crypto settings, layout tweaks.
core/src/trezor/lvglui/scrs/lockscreen.py Added debug prints, safer attribute checks.
core/src/trezor/lvglui/scrs/passphrase.py PassphraseRequest: min_len param, keyboard state updates.
core/src/trezor/lvglui/scrs/pinscreen.py InputPin: min_len, subtitle styling, new passphrase/main pin screens and flows.
core/src/trezor/uart.py End session if passphrase pin enabled on lock events.
core/src/trezor/ui/layouts/lvgl/__init__.py Passphrase/PIN request: min_len, wall_only flags, attach pin UI flow, prompt tweaks.
core/src/trezor/ui/layouts/lvgl/attach_to_pin.py New module: full attach-to-pin UI flow, error/confirm dialogs, attach logic.
core/src/trezor/wire/errors.py New AppVersionLow error class.
python/src/trezorlib/cli/device.py New CLI commands: initialize, unlock.
python/src/trezorlib/device.py New functions: initialize, unlock_device.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Clippy (1.86.0)

warning: default_features is deprecated in favor of default-features and will not work in the 2024 edition
(in the cstr_core dependency)
warning: default_features is deprecated in favor of default-features and will not work in the 2024 edition
(in the heapless dependency)
warning: default_features is deprecated in favor of default-features and will not work in the 2024 edition
(in the num-traits dependency)
warning: default_features is deprecated in favor of default-features and will not work in the 2024 edition
(in the bindgen dependency)
Updating crates.io index
warning: failed to write cache, path: /usr/local/registry/index/index.crates.io-1949cf8c6b5b557f/.cache/cs/tr/cstr_core, error: Permission denied (os error 13)
Downloading crates ...
Downloaded peeking_take_while v0.1.2
error: failed to create directory /usr/local/registry/cache/index.crates.io-1949cf8c6b5b557f

Caused by:
Permission denied (os error 13)

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@revan-zhang
Copy link
Copy Markdown
Contributor

revan-zhang commented Jul 16, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 29

🔭 Outside diff range comments (2)
core/src/apps/common/request_pin.py (1)

277-277: Add missing parentheses: _set_last_unlock_time()

core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (1)

495-498: Wrong error message.

   if (se_aes256_decrypt(data.buf, data.len, piv, value.buf, value.len,
                         (uint8_t *)vstr.buf) != 0) {
-    mp_raise_ValueError("Encrypt failed");
+    mp_raise_ValueError("Decrypt failed");
   }
🧹 Nitpick comments (14)
core/src/trezor/wire/errors.py (1)

86-88: Same error code as FirmwareError might confuse clients.

Both use FailureType.FirmwareError. Is this intentional?

core/src/apps/common/passphrase.py (1)

67-67: Magic number should be a constant.

Extract 30 as a named constant for clarity.

core/src/storage/device.py (1)

361-362: Fix hex notation.

Use lowercase 0x17 instead of 0X17 for consistency.

-    _AUTO_PASSPHRASE           = (0X17)
+    _AUTO_PASSPHRASE           = (0x17)
core/src/trezor/ui/layouts/lvgl/__init__.py (2)

1274-1279: Simplify the if-else block.

-    min_len = 4
-    if attach_wall_only:
-        min_len = 6
-    else:
-        min_len = 4
+    min_len = 6 if attach_wall_only else 4

1274-1278: Use ternary operator.

Replace with min_len = 6 if attach_wall_only else 4.

-    min_len = 4
-    if attach_wall_only:
-        min_len = 6
-    else:
-        min_len = 4
+    min_len = 6 if attach_wall_only else 4
core/src/apps/base.py (1)

719-721: Use idiomatic empty check.

-        if session_id is None or session_id == b"":
+        if not session_id:
core/src/trezor/lvglui/scrs/pinscreen.py (3)

189-189: Typo: "standy_wall_only"

Should be "standard_wall_only".

-        self.standy_wall_only = kwargs.get("standy_wall_only", False)
+        self.standard_wall_only = kwargs.get("standard_wall_only", False)

239-239: Incomplete comment

Remove or complete the comment.

-        # if standy_wall_only :

320-320: Typo: "standy_wall_only"

Should be "standard_wall_only".

-                if self.standy_wall_only and passphrase.is_passphrase_pin_enabled():
+                if self.standard_wall_only and passphrase.is_passphrase_pin_enabled():
core/embed/trezorhal/se_thd89.c (2)

1162-1162: Use PIN_MAX_LEN instead of 50.

-  uint8_t pin_buf[50 + 2] = {0};
+  uint8_t pin_buf[PIN_MAX_LEN + 2] = {0};

1227-1234: Remove dead code.

core/src/trezor/lvglui/scrs/homescreen.py (2)

1001-1002: Remove commented code.

Delete unused code instead of commenting it out.

-                    # device.set_passphrase_auto_status(False)

4557-4558: Combine the nested if statements.

Use a single if with and instead of nesting.

-        if code == lv.EVENT.CLICKED:
-            if target == self.attach_to_pin:
+        if code == lv.EVENT.CLICKED and target == self.attach_to_pin:
core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (1)

1001-1003: Error message lacks detail.

The message doesn't specify the minimum length of 6.

   if (passphrase_pin_buf.len < 6) {
-    mp_raise_ValueError("Passphrase pin length not valid");
+    mp_raise_ValueError("Passphrase pin must be at least 6 characters");
   }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between e421c66 and 581cfd7.

⛔ Files ignored due to path filters (2)
  • core/mocks/generated/trezorconfig.pyi is excluded by !**/generated/**
  • core/mocks/generated/trezorcrypto/se_thd89.pyi is excluded by !**/generated/**
📒 Files selected for processing (42)
  • common/protob/messages-common.proto (3 hunks)
  • common/protob/messages-management.proto (4 hunks)
  • common/protob/messages.proto (3 hunks)
  • core/embed/extmod/modtrezorconfig/modtrezorconfig.c (1 hunks)
  • core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (5 hunks)
  • core/embed/trezorhal/se_thd89.c (10 hunks)
  • core/embed/trezorhal/se_thd89.h (4 hunks)
  • core/src/all_modules.py (2 hunks)
  • core/src/apps/base.py (10 hunks)
  • core/src/apps/common/passphrase.py (4 hunks)
  • core/src/apps/common/pin_constants.py (1 hunks)
  • core/src/apps/common/request_pin.py (8 hunks)
  • core/src/apps/common/seed.py (2 hunks)
  • core/src/apps/management/change_pin.py (3 hunks)
  • core/src/apps/management/recovery_device/__init__.py (4 hunks)
  • core/src/apps/management/wipe_device.py (1 hunks)
  • core/src/apps/ur_registry/chains/hardware_requests/hardware_call.py (1 hunks)
  • core/src/apps/ur_registry/helpers.py (1 hunks)
  • core/src/apps/workflow_handlers.py (2 hunks)
  • core/src/boot.py (1 hunks)
  • core/src/storage/cache.py (2 hunks)
  • core/src/storage/device.py (7 hunks)
  • core/src/trezor/enums/ButtonRequestType.py (1 hunks)
  • core/src/trezor/enums/Capability.py (1 hunks)
  • core/src/trezor/enums/MessageType.py (2 hunks)
  • core/src/trezor/enums/__init__.py (3 hunks)
  • core/src/trezor/lvglui/i18n/locales/ja.py (2 hunks)
  • core/src/trezor/lvglui/scrs/address.py (1 hunks)
  • core/src/trezor/lvglui/scrs/components/keyboard.py (5 hunks)
  • core/src/trezor/lvglui/scrs/components/listitem.py (1 hunks)
  • core/src/trezor/lvglui/scrs/homescreen.py (18 hunks)
  • core/src/trezor/lvglui/scrs/lockscreen.py (3 hunks)
  • core/src/trezor/lvglui/scrs/passphrase.py (2 hunks)
  • core/src/trezor/lvglui/scrs/pinscreen.py (5 hunks)
  • core/src/trezor/messages.py (6 hunks)
  • core/src/trezor/uart.py (2 hunks)
  • core/src/trezor/ui/layouts/lvgl/__init__.py (4 hunks)
  • core/src/trezor/ui/layouts/lvgl/attach_to_pin.py (1 hunks)
  • core/src/trezor/wire/errors.py (1 hunks)
  • python/src/trezorlib/cli/device.py (2 hunks)
  • python/src/trezorlib/device.py (2 hunks)
  • python/src/trezorlib/messages.py (12 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (10)
core/src/apps/ur_registry/chains/hardware_requests/hardware_call.py (1)
core/src/apps/ur_registry/chains/__init__.py (1)
  • MismatchError (7-9)
core/src/trezor/lvglui/scrs/address.py (1)
core/src/storage/cache.py (1)
  • get_session_id (238-239)
core/src/trezor/wire/errors.py (1)
core/src/trezor/enums/__init__.py (1)
  • FailureType (453-468)
core/src/apps/ur_registry/helpers.py (2)
core/src/apps/common/passphrase.py (2)
  • is_enabled (11-12)
  • is_passphrase_pin_enabled (15-16)
core/src/storage/device.py (1)
  • is_passphrase_pin_enabled (1424-1432)
core/src/apps/management/recovery_device/__init__.py (3)
core/src/trezor/lvglui/i18n/__init__.py (2)
  • gettext (31-32)
  • i18n_refresh (18-25)
core/src/trezor/ui/layouts/lvgl/__init__.py (2)
  • show_popup (1166-1183)
  • confirm_action (96-145)
core/src/apps/common/pin_constants.py (1)
  • PinType (17-23)
core/src/trezor/enums/__init__.py (2)
core/src/trezor/messages.py (4)
  • GetPassphraseState (3948-3964)
  • PassphraseState (3966-3982)
  • UnLockDevice (3984-3988)
  • UnLockDeviceResponse (3990-4006)
python/src/trezorlib/messages.py (4)
  • GetPassphraseState (5526-5543)
  • PassphraseState (5546-5563)
  • UnLockDevice (5566-5567)
  • UnLockDeviceResponse (5570-5587)
core/src/apps/workflow_handlers.py (3)
core/src/trezor/enums/__init__.py (1)
  • MessageType (27-451)
core/src/trezor/messages.py (9)
  • BatchGetPublickeys (2860-2876)
  • GetAddress (958-980)
  • GetPublicKey (916-938)
  • EthereumGetAddress (5610-5626)
  • CardanoGetAddress (1816-1838)
  • BinanceGetAddress (556-570)
  • BinanceGetPublicKey (586-600)
  • EthereumGetPublicKey (5578-5592)
  • NostrGetPublicKey (7554-7568)
core/src/apps/base.py (3)
  • wrapper (31-34)
  • wrapper (661-663)
  • check_version_compatibility (19-27)
core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (2)
core/embed/trezorhal/se_thd89.c (6)
  • se_session_get_type (1954-1960)
  • se_get_pin_passphrase_space (1473-1479)
  • se_set_pin_passphrase (1397-1412)
  • se_get_pin_passphrase_ret (1482-1482)
  • se_delete_pin_passphrase (1438-1450)
  • se_check_passphrase_btc_test_address (1452-1471)
core/embed/trezorhal/se_thd89.h (6)
  • se_session_get_type (139-139)
  • se_get_pin_passphrase_space (121-121)
  • se_set_pin_passphrase (117-118)
  • se_get_pin_passphrase_ret (120-120)
  • se_delete_pin_passphrase (119-119)
  • se_check_passphrase_btc_test_address (122-122)
python/src/trezorlib/messages.py (3)
core/src/trezor/messages.py (4)
  • GetPassphraseState (3948-3964)
  • PassphraseState (3966-3982)
  • UnLockDevice (3984-3988)
  • UnLockDeviceResponse (3990-4006)
python/src/trezorlib/protobuf.py (2)
  • Field (148-179)
  • MessageType (189-249)
core/src/trezor/enums/__init__.py (1)
  • MessageType (27-451)
core/src/trezor/lvglui/scrs/pinscreen.py (8)
core/src/apps/common/passphrase.py (2)
  • get (23-30)
  • is_passphrase_pin_enabled (15-16)
core/src/trezor/lvglui/lv_colors.py (1)
  • lv_colors (9-69)
core/src/trezor/lvglui/scrs/lockscreen.py (1)
  • _show_fingerprint_prompt_if_necessary (161-169)
core/src/trezor/lvglui/scrs/components/keyboard.py (1)
  • NumberKeyboard (399-613)
core/src/storage/device.py (1)
  • is_passphrase_pin_enabled (1424-1432)
core/src/trezor/loop.py (2)
  • publish (461-466)
  • wait (277-293)
core/src/trezor/lvglui/scrs/common.py (5)
  • destroy (619-623)
  • FullSizeWindow (362-703)
  • request (148-149)
  • request (307-308)
  • request (589-607)
core/src/trezor/ui/layouts/lvgl/__init__.py (1)
  • show_warning (508-532)
🪛 Ruff (0.12.2)
core/src/apps/common/request_pin.py

154-154: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


160-160: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


162-162: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


181-181: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


196-196: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


223-223: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


241-241: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


305-305: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

core/src/trezor/ui/layouts/lvgl/__init__.py

1275-1278: Use ternary operator min_len = 6 if attach_wall_only else 4 instead of if-else-block

Replace if-else-block with min_len = 6 if attach_wall_only else 4

(SIM108)

core/src/apps/base.py

706-711: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

core/src/trezor/lvglui/scrs/homescreen.py

5557-5558: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Defs check
  • GitHub Check: Gen check
  • GitHub Check: Style check
🔇 Additional comments (73)
core/src/trezor/enums/ButtonRequestType.py (1)

24-24: LGTM! Enum value follows existing pattern.

core/src/trezor/lvglui/scrs/components/listitem.py (1)

32-32: Minor styling improvement looks good.

core/src/apps/management/wipe_device.py (1)

24-28: Good enhancement - adds type safety to PIN verification.

core/src/trezor/enums/Capability.py (1)

12-12: Capability addition follows proper sequential numbering.

core/src/apps/ur_registry/chains/hardware_requests/hardware_call.py (1)

78-80: Good improvement - makes error handling consistent across debug modes.

core/src/trezor/lvglui/i18n/locales/ja.py (1)

897-947: Translation updates look good.

The wording changes improve clarity for hidden PIN functionality.

core/src/trezor/lvglui/scrs/address.py (1)

126-126: Session ID tracking addition looks correct.

Proper placement between session end and start.

core/src/all_modules.py (2)

370-371: New module import follows existing pattern.

Correct qstring interning approach.


584-585: Pin constants module import looks good.

Follows the established pattern.

core/src/boot.py (1)

36-38: PIN type specification looks correct.

Proper integration with new PIN management.

core/src/apps/ur_registry/helpers.py (1)

75-77: Logic correctly extends suffix condition for passphrase PIN mode.

The OR condition properly handles both regular passphrase and passphrase PIN scenarios for device name derivation.

core/src/trezor/enums/MessageType.py (1)

107-108: New message types properly defined.

Values follow the established numbering scheme and support the unlock device functionality.

core/src/storage/cache.py (2)

35-35: Cache key properly defined with sessionless flag.

Follows existing pattern for sessionless cache keys.


146-146: Field allocation correctly sized for boolean flag.

1-byte field is appropriate for the attach client flag.

core/src/trezor/enums/__init__.py (3)

448-451: Message type enums correctly added.

Values align with protobuf definitions and follow established numbering.


491-491: Button request type properly defined.

AttachPin value follows the pattern for special button types.


656-656: Capability enum correctly extended.

AttachToPin capability properly numbered sequentially.

core/src/trezor/lvglui/scrs/passphrase.py (3)

9-9: Default value maintains backward compatibility.

min_len parameter properly defaults to 0.


21-21: Minimum length passed to keyboard component.

Correctly forwards the constraint to the keyboard.


25-26: UI state properly updated for pre-filled text.

Button state and count tips correctly refreshed when result is provided.

core/src/apps/management/change_pin.py (1)

37-38: Imports Verified

PinType and PinResult exist in apps.common.pin_constants. No action needed.

core/src/trezor/lvglui/scrs/lockscreen.py (1)

19-31: LGTM!

Debug prints are properly guarded and the safer attribute check improves robustness.

Also applies to: 76-101, 126-127

common/protob/messages-common.proto (1)

78-78: LGTM!

Protobuf extensions for attach pin feature are properly defined.

Also applies to: 123-123, 134-134

common/protob/messages.proto (2)

80-80: Verify wire_tiny removal is intentional.

Removing wire_tiny from MessageType_Initialize changes behavior. Confirm this is needed for attach pin feature.


609-612: LGTM!

New message types for passphrase state and device unlock are properly defined.

core/src/apps/common/pin_constants.py (1)

1-28: LGTM!

New constants file is well-structured.

core/src/apps/common/seed.py (1)

70-154: LGTM!

Conditional passphrase handling is consistent throughout.

core/src/trezor/lvglui/scrs/components/keyboard.py (2)

891-891: Fix LVGL constant usage.

Changed from FLAG.FOCUSED to STATE.FOCUSED. Good catch.


866-868: Minimum length validation properly implemented.

The OK button state updates based on input length. Visual feedback is clear.

Also applies to: 1130-1147, 1210-1218

core/embed/extmod/modtrezorconfig/modtrezorconfig.c (2)

113-167: Function signature and return type updated correctly.

The unlock function now accepts an optional pin_use_type parameter and returns a tuple.


169-180: Consistent update to check_pin function.

Matches the unlock function changes.

core/src/apps/common/passphrase.py (4)

3-3: Import looks good.


15-21: Helper functions look correct.


42-42: Unused return value.

The get_pin_passphrase_space() call result is not used here but is used in _request_on_host(). Is this redundant?


74-88: Attach pin flow looks correct.

python/src/trezorlib/device.py (3)

369-369: Field name uses camelCase.

onlyMainPin doesn't match Python naming style.


443-459: Initialize function looks good.


461-464: Unlock function is correct.

python/src/trezorlib/cli/device.py (3)

206-223: CLI command looks good.


753-781: Initialize command is correct.


783-794: Unlock command implementation is fine.

core/src/apps/workflow_handlers.py (4)

108-109: Handler registration is correct.


393-398: Handler wrapping logic looks good.


442-442: Commented code.

EOSGetPublicKey is commented out. Intentional?


447-456: Version check wrapper is correct.

common/protob/messages-management.proto (5)

42-43: Unusual field numbers.

Field numbers 8000+ are very high. Is this intentional?


134-134: New capability looks correct.


195-196: Feature flags added correctly.


816-816: Comment removed.


821-821: Underscore prefix on new field.

Why does _only_main_pin have an underscore prefix?

core/src/storage/device.py (4)

32-33: LGTM!

Variables follow established naming and typing patterns.


250-253: LGTM!

Struct definitions follow existing patterns correctly.

Also applies to: 289-290


412-412: Verify PIN attempts reduction.

Reducing from 10 to 5 attempts is a breaking change. Confirm this aligns with product requirements.


1484-1485: LGTM!

Cache clearing correctly handles new variables.

Also applies to: 1524-1525

core/src/trezor/messages.py (5)

839-846: Code looks good.

Field addition follows existing patterns.


855-855: Clean implementation.

Also applies to: 862-862


2913-2914: Fields added correctly.

Also applies to: 2921-2922


3025-3026: Proper field definitions.

Also applies to: 3113-3114


3948-4007: New message classes implemented correctly.

All follow standard protobuf patterns.

core/src/trezor/ui/layouts/lvgl/__init__.py (1)

1200-1212: No issues found.

The passphrase request changes look correct.

core/embed/trezorhal/se_thd89.h (7)

15-19: LGTM!


21-35: LGTM!


37-44: LGTM!


112-112: LGTM!


116-122: LGTM!


139-139: LGTM!


256-256: LGTM!

core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (6)

27-28: LGTM!


166-178: LGTM!


964-977: LGTM!


1036-1063: LGTM!


1065-1085: LGTM!


1105-1106: LGTM!

Also applies to: 1163-1174

Comment thread core/src/apps/management/change_pin.py
Comment thread core/src/apps/management/change_pin.py
Comment thread core/src/trezor/uart.py
Comment thread core/src/apps/management/recovery_device/__init__.py
Comment thread core/src/storage/device.py
Comment thread core/embed/trezorhal/se_thd89.c
Comment thread core/embed/trezorhal/se_thd89.c
Comment thread core/src/trezor/lvglui/scrs/homescreen.py
Comment thread core/src/trezor/ui/layouts/lvgl/__init__.py
Comment thread core/src/trezor/ui/layouts/lvgl/__init__.py
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 0de26c1 and a17cd1c.

⛔ Files ignored due to path filters (6)
  • core/src/trezor/lvglui/res/attach-to-pin-guide.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/attach_to_pin_display.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/attach_to_pin_dot_group.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/icon-attach-to-pin.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/nav-icon.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/pin_lock.png is excluded by !**/*.png
📒 Files selected for processing (13)
  • core/src/storage/device.py (9 hunks)
  • core/src/trezor/lvglui/i18n/keys.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/de.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/en.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/es.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/fr.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/it.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ja.py (3 hunks)
  • core/src/trezor/lvglui/i18n/locales/ko.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/pt_br.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/ru.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py (1 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py (1 hunks)
✅ Files skipped from review due to trivial changes (6)
  • core/src/trezor/lvglui/i18n/locales/pt_br.py
  • core/src/trezor/lvglui/i18n/locales/de.py
  • core/src/trezor/lvglui/i18n/locales/es.py
  • core/src/trezor/lvglui/i18n/locales/fr.py
  • core/src/trezor/lvglui/i18n/locales/ru.py
  • core/src/trezor/lvglui/i18n/locales/ko.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • core/src/trezor/lvglui/i18n/locales/ja.py
  • core/src/storage/device.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Defs check
  • GitHub Check: Style check
  • GitHub Check: Gen check
🔇 Additional comments (4)
core/src/trezor/lvglui/i18n/locales/zh_cn.py (1)

1020-1020: Translation looks good.

Clear and grammatically correct Chinese.

core/src/trezor/lvglui/i18n/locales/it.py (1)

1020-1020: Translation looks good.

Clear and grammatically correct Italian.

core/src/trezor/lvglui/i18n/locales/en.py (1)

1020-1020: Translation looks good.

Clear and grammatically correct English.

core/src/trezor/lvglui/i18n/keys.py (1)

1017-1017: LGTM.

Clear message format and appropriate subtitle classification.

Comment thread core/src/trezor/lvglui/i18n/locales/zh_hk.py
@guowei0105 guowei0105 requested a review from somebodyLi July 16, 2025 07:20
Lu1zz
Lu1zz previously approved these changes Jul 16, 2025
somebodyLi
somebodyLi previously approved these changes Jul 16, 2025
@guowei0105 guowei0105 enabled auto-merge (squash) July 16, 2025 07:33
@guowei0105 guowei0105 disabled auto-merge July 16, 2025 07:35
@guowei0105 guowei0105 force-pushed the passphrase_pin_updated branch from a17cd1c to 7b2881d Compare July 16, 2025 08:16
guowei0105 and others added 16 commits July 16, 2025 16:36
* Revert "Revert "disable D-Cache during jpeg decoding. (OneKeyHQ#340)" (OneKeyHQ#341)"

This reverts commit 7ebd207.

* fix(jpeg): resolve issues caused by input cache during decoding.

* feat(ui): draw progress bar using LVGL components.

* fix(btc-only): correct command response error.
* feat(core): add Kaspa address format toggle for Address Book

* feat(core): add support for safe execTransaction/approveHash support

* feat(core): optimize display of ETH zero-value transfers with non-null data

* fix(core): fix the delegate resource issue with tron

* fix(core): optimize vibrate

* feat(core): add support for slip-39 backup

* fix(core): fix gen/style check issue

* fix(Kaspa): add i18n keys

* chore(core): bump version to 4.15.0
@guowei0105 guowei0105 dismissed stale reviews from somebodyLi and Lu1zz via c8d31a4 July 16, 2025 08:39
@guowei0105 guowei0105 force-pushed the passphrase_pin_updated branch from 7b2881d to c8d31a4 Compare July 16, 2025 08:39
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 18

🔭 Outside diff range comments (1)
core/src/apps/common/request_pin.py (1)

277-277: Add missing parentheses.

Function call needs parentheses.

-        _set_last_unlock_time
+        _set_last_unlock_time()
♻️ Duplicate comments (27)
core/src/apps/common/request_pin.py (7)

172-172: Remove debug print.

-            print("usertype", usertype)

154-154: Fix typo: "cancle" → "cancel".

-            raise wire.PinCancelled("cancle")
+            raise wire.PinCancelled("cancel")

162-162: Fix typo: "cancle" → "cancel".

-        raise wire.PinCancelled("cancle")
+        raise wire.PinCancelled("cancel")

181-181: Fix typo: "cancle" → "cancel".

-            raise wire.PinCancelled("cancle")
+            raise wire.PinCancelled("cancel")

196-196: Fix typo: "cancle" → "cancel".

-            raise wire.PinCancelled("cancle")
+            raise wire.PinCancelled("cancel")

223-223: Fix typo: "cancle" → "cancel".

-            raise wire.PinCancelled("cancle")
+            raise wire.PinCancelled("cancel")

241-241: Fix garbled text.

-            raise wire.PinCancelled("cal cale ..")
+            raise wire.PinCancelled("cancel")
python/src/trezorlib/messages.py (5)

459-460: Fix capitalization.

"UnLockDevice" should be "UnlockDevice".


4342-4342: Fix field name.

"is_contains_attach" is bad grammar. Use "contains_attach" or "has_attach".


4352-4352: Fix parameter name.

"is_contains_attach" needs fixing to match the field name change.


5566-5568: Fix class name.

"UnLockDevice" should be "UnlockDevice".


5570-5571: Fix class name.

"UnLockDeviceResponse" should be "UnlockDeviceResponse".

core/src/trezor/lvglui/scrs/pinscreen.py (3)

219-223: Duplicate code

The subtitle text is set twice.


475-477: Remove debug print

Debug prints should not be in production code.


576-577: Inconsistent minimum length check

The check requires 6 but keyboard has min_len=4.

core/src/trezor/ui/layouts/lvgl/attach_to_pin.py (2)

244-244: Remove debug print.


250-252: Wrap debug print in debug check.

core/embed/trezorhal/se_thd89.c (2)

1341-1351: PIN_MAX_LENGTH and PASSPHRASE_MAX_LENGTH are undefined.

Use PIN_MAX_LEN instead.


1417-1419: PIN_MAX_LENGTH is undefined.

Use PIN_MAX_LEN.

core/src/trezor/ui/layouts/lvgl/__init__.py (4)

1210-1211: Inconsistent error handling.

Why return None only when min_len is exactly 1?


1238-1238: Fix typo.

"standy_wall_only" should be "standard_wall_only".


1261-1261: Fix typo.

"standy_wall_only" should be "standard_wall_only".


1283-1283: Fix typo.

"standy_wall_only" should be "standard_wall_only".

core/src/trezor/lvglui/scrs/homescreen.py (1)

991-993: Remove debug print
Debug output must not stay in production.

core/src/apps/base.py (3)

165-169: Magic number needs explaining.


690-699: Incomplete condition check.


746-750: Bare except too broad.

🧹 Nitpick comments (31)
core/embed/trezorhal/jpeg_dma.c (1)

280-280: Consider using actual JPEG size for cache clean.

Using g_inputJpegSize instead of MAX_JPEG_SIZE would be more efficient.

-  SCB_CleanDCache_by_Addr((uint32_t *)g_inputJpegBuffer, MAX_JPEG_SIZE);
+  SCB_CleanDCache_by_Addr((uint32_t *)g_inputJpegBuffer, g_inputJpegSize);
core/src/apps/ethereum/onekey/sign_tx_eip1559.py (1)

105-105: Drop the underscore prefix.

The variable is local, not private.

-    _is_safe_tx = False
+    is_safe_tx_flag = False
core/src/trezor/lvglui/scrs/components/button.py (1)

270-275: Simplify the vibration logic.

Too many branches. Pick one approach.

-            if not self.is_haptic_feedback:
-                motor.vibrate(motor.WHISPER)
-            else:
-                # if self.switch.get_state() != lv.STATE.CHECKED:
-                #     motor.vibrate(motor.WHISPER, force=True)
-                motor.vibrate(motor.WHISPER, force=True)
+            force = self.is_haptic_feedback
+            motor.vibrate(motor.WHISPER, force=force)
core/src/storage/recovery_shares.py (4)

10-15: Remove commented code

Dead code should be deleted, not commented out.


19-27: Remove commented code

Dead code should be deleted, not commented out.


31-32: Remove commented code

Dead code should be deleted, not commented out.


43-47: Remove commented code

Dead code should be deleted, not commented out.

core/src/trezor/lvglui/scrs/recovery_device.py (1)

152-152: Remove commented code

Dead code should be deleted, not commented out.

core/src/apps/common/backup_types.py (1)

70-87: Use a dictionary instead of if statements.

 def get_num_of_words_per_share(
     backup_type: BackupType, secret_length_bytes: int
 ) -> int:
     if is_slip39_backup_type(backup_type):
         if secret_length_bytes == 16:
             return 20
         elif secret_length_bytes == 32:
             return 33
     else:
-        if secret_length_bytes == 16:
-            return 12
-        elif secret_length_bytes == 24:
-            return 18
-        elif secret_length_bytes == 32:
-            return 24
+        bip39_words = {16: 12, 24: 18, 32: 24}
+        if secret_length_bytes in bip39_words:
+            return bip39_words[secret_length_bytes]
     # Invalid backup type and secret length combination
     raise RuntimeError
core/src/trezor/ui/layouts/lvgl/reset.py (3)

43-43: Remove commented code.

Delete the commented line.

-        # header_title = _(i18n_keys.TITLE__RECOVERY_PHRASE)

86-88: Remove debug print.

Debug statements don't belong in production code.

-        if __debug__:
-            print(f"mnemonic display result: {result}")

103-104: Remove commented code.

Delete these commented lines.

-    # # remove current checked words
-    # non_duplicates.remove(share_words[offset])
core/src/trezor/lvglui/scrs/common.py (4)

495-496: Remove debug print.

-        if __debug__:
-            print("on_draw_post_end called.")

502-503: Remove debug print.

-        if __debug__:
-            print("vibrate start...")

514-515: Remove debug print.

-        if __debug__:
-            print(f"vibrate necessary ? {self.icon_path}")

521-522: Remove debug print.

-            if __debug__:
-                print("vibrate necessary: true")
core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (2)

1037-1037: Fix spacing in type annotation.

Missing space after comma in tuple type.

-/// tuple[bool,bool]:
+/// tuple[bool, bool]:

1074-1076: Address length validation is arbitrary.

64-byte limit seems arbitrary without justification.

Consider using Bitcoin address format specific limits instead of arbitrary 64 bytes.

core/embed/trezorhal/motor.c (2)

44-46: Fix typo.

"dont" should be "don't".

-  // dont disable clock, as it may used by other peripherals
+  // don't disable clock, as it may used by other peripherals

117-117: Fix grammar.

"non zero" should be "non-zero".

-  // we don't have to filter non zero values
+  // we don't have to filter non-zero values
core/src/apps/management/recovery_device/homescreen.py (1)

94-94: Fix grammar.

Remove redundant "be".

-    # Both will be either set or unset. We use 'backup_type is None' to detect status of both.
+    # Both will either be set or unset. We use 'backup_type is None' to detect status of both.
core/src/apps/ethereum/onekey/sign_tx.py (1)

265-265: Use formal language.

Replace "aka" with "i.e.".

-        in (196, 228)  # assume data is 00 aka the recipient is not a contract
+        in (196, 228)  # assume data is 00 i.e. the recipient is not a contract
core/src/trezor/ui/layouts/lvgl/attach_to_pin.py (1)

385-385: Remove commented code.

-    # screen.btn_no.enable(lv_colors.ONEKEY_RED_1, text_color=lv_colors.BLACK)
core/src/apps/management/recovery_device/layout.py (4)

112-115: Remove commented code.

-        # if is_slip39:
-        #     text = "The entered recovery\nshares are valid and\nmatch what is currently\nin the device."
-        #     raise
-        # else:

135-137: Remove commented code.

-        # if is_slip39:
-        #     raise
-        # else:

164-166: Remove commented code.

-    # if backup_types.is_slip39_word_count(len(mnemonics)):
-    #     pass
-    # else:

175-179: Remove commented code.

-    # await show_warning(
-    #     ctx,
-    #     "warning_known_share",
-    #     "Share already entered,\nplease enter\na different share.",
-    # )
core/src/trezor/ui/layouts/lvgl/__init__.py (1)

1274-1278: Simplify conditional assignment.

Use ternary operator: min_len = 6 if attach_wall_only else 4

-    min_len = 4
-    if attach_wall_only:
-        min_len = 6
-    else:
-        min_len = 4
+    min_len = 6 if attach_wall_only else 4
core/src/trezor/ui/layouts/lvgl/altcoin.py (1)

27-32: Extract duplicate logic.

Same conditional logic appears in lines 164-169. Extract to helper function.

+def _get_title_and_striped(amount: str, raw_data: bytes | None) -> tuple[str, bool]:
+    if amount.split(" ")[0] == "0" and raw_data is not None:
+        return _(i18n_keys.TITLE_REQUEST_CONFIRMATION), False
+    else:
+        short_amount, striped = strip_amount(amount)
+        return _(i18n_keys.TITLE__SEND_MULTILINE).format(short_amount), striped
core/src/apps/management/reset_device/layout.py (1)

66-68: Long i18n key name hurts readability.

Consider shortening: CONTENT__YOU_HAVE_COMPLETED_VERIFICATION_OF_SHARE_STR_OF_STR_RECOVERY_PHRASE

core/src/apps/base.py (1)

706-711: Combine nested if statements.

-    if (
-        fingerprints.is_available()
-        and fingerprints.is_unlocked()
-        and not config.is_unlocked()
-    ):
-        if storage.device.is_passphrase_pin_enabled():
-            storage.device.set_passphrase_pin_enabled(False)
+    if (
+        fingerprints.is_available()
+        and fingerprints.is_unlocked()
+        and not config.is_unlocked()
+        and storage.device.is_passphrase_pin_enabled()
+    ):
+        storage.device.set_passphrase_pin_enabled(False)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge Base: Disabled due to data retention organization setting

📥 Commits

Reviewing files that changed from the base of the PR and between 7b2881d and c8d31a4.

⛔ Files ignored due to path filters (12)
  • core/mocks/generated/trezorconfig.pyi is excluded by !**/generated/**
  • core/mocks/generated/trezorcrypto/se_thd89.pyi is excluded by !**/generated/**
  • core/mocks/generated/trezorcrypto/slip39.pyi is excluded by !**/generated/**
  • core/mocks/generated/trezorio/__init__.pyi is excluded by !**/generated/**
  • core/src/trezor/lvglui/res/attach-to-pin-guide.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/attach_to_pin_display.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/attach_to_pin_dot_group.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/icon-attach-to-pin.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/nav-icon.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/pin_lock.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/s-arrow-down.png is excluded by !**/*.png
  • core/src/trezor/lvglui/res/ss-mul-share.png is excluded by !**/*.png
📒 Files selected for processing (118)
  • common/protob/messages-common.proto (3 hunks)
  • common/protob/messages-management.proto (5 hunks)
  • common/protob/messages-tron.proto (1 hunks)
  • common/protob/messages.proto (3 hunks)
  • core/embed/extmod/modtrezorconfig/modtrezorconfig.c (4 hunks)
  • core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip39.h (2 hunks)
  • core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (5 hunks)
  • core/embed/extmod/modtrezorcrypto/modtrezorcrypto-shamir.h (3 hunks)
  • core/embed/extmod/modtrezorcrypto/modtrezorcrypto-slip39.h (4 hunks)
  • core/embed/extmod/modtrezorio/modtrezorio-motor.h (1 hunks)
  • core/embed/extmod/modtrezorui/mipi_lcd.c (1 hunks)
  • core/embed/firmware/version.h (1 hunks)
  • core/embed/lvgl/lv_jpeg_stm32.c (1 hunks)
  • core/embed/rust/src/trezorhal/bip39.rs (1 hunks)
  • core/embed/trezorhal/device.c (1 hunks)
  • core/embed/trezorhal/jpeg_dma.c (1 hunks)
  • core/embed/trezorhal/motor.c (3 hunks)
  • core/embed/trezorhal/motor.h (2 hunks)
  • core/embed/trezorhal/motor_patterns.h (1 hunks)
  • core/embed/trezorhal/se_thd89.c (13 hunks)
  • core/embed/trezorhal/se_thd89.h (4 hunks)
  • core/src/all_modules.py (4 hunks)
  • core/src/apps/base.py (10 hunks)
  • core/src/apps/cardano/seed.py (1 hunks)
  • core/src/apps/common/backup.py (1 hunks)
  • core/src/apps/common/backup_types.py (1 hunks)
  • core/src/apps/common/mnemonic.py (2 hunks)
  • core/src/apps/common/passphrase.py (4 hunks)
  • core/src/apps/common/pin_constants.py (1 hunks)
  • core/src/apps/common/request_pin.py (8 hunks)
  • core/src/apps/common/seed.py (2 hunks)
  • core/src/apps/debug/load_device.py (2 hunks)
  • core/src/apps/ethereum/layout.py (4 hunks)
  • core/src/apps/ethereum/onekey/sign_safe_tx.py (3 hunks)
  • core/src/apps/ethereum/onekey/sign_tx.py (7 hunks)
  • core/src/apps/ethereum/onekey/sign_tx_eip1559.py (3 hunks)
  • core/src/apps/ethereum/sign_tx.py (2 hunks)
  • core/src/apps/ethereum/sign_tx_eip1559.py (2 hunks)
  • core/src/apps/ethereum/tokens.py (1 hunks)
  • core/src/apps/ethereum/tokens.py.mako (1 hunks)
  • core/src/apps/management/backup_types.py (0 hunks)
  • core/src/apps/management/change_pin.py (3 hunks)
  • core/src/apps/management/recovery_device/__init__.py (5 hunks)
  • core/src/apps/management/recovery_device/create_mul_shares.py (1 hunks)
  • core/src/apps/management/recovery_device/homescreen.py (13 hunks)
  • core/src/apps/management/recovery_device/layout.py (9 hunks)
  • core/src/apps/management/recovery_device/recover.py (6 hunks)
  • core/src/apps/management/recovery_device/word_validity.py (4 hunks)
  • core/src/apps/management/reset_device/__init__.py (6 hunks)
  • core/src/apps/management/reset_device/layout.py (7 hunks)
  • core/src/apps/management/wipe_device.py (1 hunks)
  • core/src/apps/tron/serialize.py (1 hunks)
  • core/src/apps/tron/sign_tx.py (1 hunks)
  • core/src/apps/ur_registry/chains/hardware_requests/hardware_call.py (1 hunks)
  • core/src/apps/ur_registry/helpers.py (1 hunks)
  • core/src/apps/workflow_handlers.py (1 hunks)
  • core/src/boot.py (1 hunks)
  • core/src/storage/cache.py (2 hunks)
  • core/src/storage/device.py (13 hunks)
  • core/src/storage/recovery.py (1 hunks)
  • core/src/storage/recovery_shares.py (2 hunks)
  • core/src/trezor/crypto/slip39.py (24 hunks)
  • core/src/trezor/enums/BackupType.py (1 hunks)
  • core/src/trezor/enums/ButtonRequestType.py (1 hunks)
  • core/src/trezor/enums/Capability.py (1 hunks)
  • core/src/trezor/enums/MessageType.py (2 hunks)
  • core/src/trezor/enums/__init__.py (4 hunks)
  • core/src/trezor/lvglui/i18n/keys.py (3 hunks)
  • core/src/trezor/lvglui/i18n/locales/de.py (3 hunks)
  • core/src/trezor/lvglui/i18n/locales/en.py (3 hunks)
  • core/src/trezor/lvglui/i18n/locales/es.py (4 hunks)
  • core/src/trezor/lvglui/i18n/locales/fr.py (4 hunks)
  • core/src/trezor/lvglui/i18n/locales/it.py (3 hunks)
  • core/src/trezor/lvglui/i18n/locales/ja.py (6 hunks)
  • core/src/trezor/lvglui/i18n/locales/ko.py (3 hunks)
  • core/src/trezor/lvglui/i18n/locales/pt_br.py (4 hunks)
  • core/src/trezor/lvglui/i18n/locales/ru.py (4 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py (4 hunks)
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py (4 hunks)
  • core/src/trezor/lvglui/scrs/address.py (10 hunks)
  • core/src/trezor/lvglui/scrs/common.py (4 hunks)
  • core/src/trezor/lvglui/scrs/components/button.py (4 hunks)
  • core/src/trezor/lvglui/scrs/components/container.py (1 hunks)
  • core/src/trezor/lvglui/scrs/components/keyboard.py (15 hunks)
  • core/src/trezor/lvglui/scrs/components/listitem.py (5 hunks)
  • core/src/trezor/lvglui/scrs/components/navigation.py (1 hunks)
  • core/src/trezor/lvglui/scrs/components/radio.py (2 hunks)
  • core/src/trezor/lvglui/scrs/components/slider.py (3 hunks)
  • core/src/trezor/lvglui/scrs/fingerprints.py (6 hunks)
  • core/src/trezor/lvglui/scrs/homescreen.py (21 hunks)
  • core/src/trezor/lvglui/scrs/lockscreen.py (3 hunks)
  • core/src/trezor/lvglui/scrs/passphrase.py (2 hunks)
  • core/src/trezor/lvglui/scrs/pinscreen.py (5 hunks)
  • core/src/trezor/lvglui/scrs/recovery_device.py (7 hunks)
  • core/src/trezor/lvglui/scrs/reset_device.py (7 hunks)
  • core/src/trezor/lvglui/scrs/template.py (18 hunks)
  • core/src/trezor/messages.py (8 hunks)
  • core/src/trezor/motor.py (1 hunks)
  • core/src/trezor/pin.py (1 hunks)
  • core/src/trezor/qr.py (1 hunks)
  • core/src/trezor/uart.py (4 hunks)
  • core/src/trezor/ui/components/tt/keyboard_slip39.py (2 hunks)
  • core/src/trezor/ui/layouts/lvgl/__init__.py (7 hunks)
  • core/src/trezor/ui/layouts/lvgl/altcoin.py (6 hunks)
  • core/src/trezor/ui/layouts/lvgl/attach_to_pin.py (1 hunks)
  • core/src/trezor/ui/layouts/lvgl/recovery.py (3 hunks)
  • core/src/trezor/ui/layouts/lvgl/reset.py (4 hunks)
  • core/src/trezor/utils.py (1 hunks)
  • core/src/trezor/wire/errors.py (1 hunks)
  • crypto/bip39.c (4 hunks)
  • crypto/bip39.h (1 hunks)
  • crypto/slip39.c (6 hunks)
  • crypto/slip39.h (2 hunks)
  • crypto/slip39_wordlist.h (2 hunks)
  • python/src/trezorlib/cli/device.py (2 hunks)
  • python/src/trezorlib/device.py (2 hunks)
  • python/src/trezorlib/messages.py (15 hunks)
  • vendor/lvgl_mp (1 hunks)
💤 Files with no reviewable changes (1)
  • core/src/apps/management/backup_types.py
✅ Files skipped from review due to trivial changes (14)
  • core/embed/firmware/version.h
  • core/embed/extmod/modtrezorcrypto/modtrezorcrypto-shamir.h
  • core/embed/lvgl/lv_jpeg_stm32.c
  • vendor/lvgl_mp
  • core/embed/trezorhal/device.c
  • common/protob/messages-tron.proto
  • core/src/trezor/wire/errors.py
  • core/src/trezor/utils.py
  • core/src/all_modules.py
  • core/src/apps/ethereum/sign_tx.py
  • core/src/trezor/lvglui/i18n/locales/pt_br.py
  • crypto/slip39_wordlist.h
  • core/src/trezor/lvglui/i18n/locales/ja.py
  • core/src/trezor/lvglui/i18n/locales/es.py
🚧 Files skipped from review as they are similar to previous changes (33)
  • core/src/trezor/enums/ButtonRequestType.py
  • core/src/apps/management/wipe_device.py
  • core/src/apps/ur_registry/chains/hardware_requests/hardware_call.py
  • core/src/boot.py
  • core/src/apps/ur_registry/helpers.py
  • core/src/trezor/enums/Capability.py
  • core/src/trezor/enums/MessageType.py
  • core/src/trezor/lvglui/i18n/locales/en.py
  • core/src/trezor/lvglui/scrs/passphrase.py
  • core/src/trezor/lvglui/i18n/locales/de.py
  • core/src/trezor/lvglui/scrs/lockscreen.py
  • core/src/storage/cache.py
  • core/src/trezor/uart.py
  • core/src/apps/common/seed.py
  • core/src/apps/management/change_pin.py
  • core/src/apps/common/pin_constants.py
  • python/src/trezorlib/device.py
  • core/src/apps/management/recovery_device/init.py
  • core/src/trezor/lvglui/i18n/locales/zh_hk.py
  • core/src/trezor/lvglui/i18n/locales/zh_cn.py
  • core/src/apps/workflow_handlers.py
  • core/src/trezor/enums/init.py
  • core/src/trezor/lvglui/i18n/locales/ko.py
  • python/src/trezorlib/cli/device.py
  • core/src/trezor/lvglui/i18n/locales/ru.py
  • core/src/apps/common/passphrase.py
  • common/protob/messages.proto
  • core/src/trezor/lvglui/i18n/locales/fr.py
  • core/src/trezor/lvglui/i18n/locales/it.py
  • common/protob/messages-common.proto
  • core/embed/trezorhal/se_thd89.h
  • core/src/storage/device.py
  • common/protob/messages-management.proto
🧰 Additional context used
🧬 Code Graph Analysis (15)
core/src/trezor/qr.py (1)
core/src/trezor/motor.py (2)
  • vibrate (24-47)
  • vibrate (51-54)
core/src/trezor/ui/components/tt/keyboard_slip39.py (1)
crypto/slip39.c (1)
  • button_sequence_to_word (94-112)
core/embed/rust/src/trezorhal/bip39.rs (2)
crypto/bip39.c (1)
  • mnemonic_word_completion_mask (327-342)
crypto/bip39.h (1)
  • mnemonic_word_completion_mask (58-59)
core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip39.h (2)
crypto/bip39.c (2)
  • mnemonic_complete_word (284-317)
  • mnemonic_word_completion_mask (327-342)
crypto/bip39.h (2)
  • mnemonic_complete_word (56-56)
  • mnemonic_word_completion_mask (58-59)
core/src/apps/cardano/seed.py (2)
core/src/apps/common/mnemonic.py (2)
  • is_bip39 (20-25)
  • get_seed (28-68)
core/src/apps/common/seed.py (2)
  • get_seed (123-130)
  • get_seed (137-156)
core/embed/extmod/modtrezorcrypto/modtrezorcrypto-slip39.h (2)
crypto/bip39.c (2)
  • mnemonic_complete_word (284-317)
  • mnemonic_word_completion_mask (327-342)
crypto/bip39.h (2)
  • mnemonic_complete_word (56-56)
  • mnemonic_word_completion_mask (58-59)
core/src/trezor/motor.py (1)
core/src/storage/device.py (1)
  • keyboard_haptic_enabled (710-719)
core/src/trezor/pin.py (3)
core/src/trezor/lvglui/scrs/common.py (1)
  • FullSizeWindow (362-703)
core/src/trezor/lvglui/i18n/__init__.py (1)
  • gettext (31-32)
core/src/trezor/lvglui/lv_colors.py (1)
  • lv_colors (9-69)
core/src/apps/management/recovery_device/word_validity.py (2)
core/src/trezor/enums/__init__.py (1)
  • BackupType (610-616)
core/src/apps/common/backup_types.py (2)
  • is_slip39_backup_type (25-32)
  • is_slip39_advanced_backup_type (35-39)
core/embed/trezorhal/motor.c (2)
core/embed/trezorhal/motor.h (16)
  • motor_ctrl (29-29)
  • motor_reset (32-32)
  • motor_init (27-27)
  • motor_deinit (28-28)
  • motor_is_busy (30-30)
  • motor_play (31-31)
  • motor_resonant_finder (35-35)
  • motor_set_builtin_play_method (38-38)
  • motor_play_whisper (41-41)
  • motor_play_light (42-42)
  • motor_play_medium (43-43)
  • motor_play_heavy (44-44)
  • motor_play_success (47-47)
  • motor_play_warning (48-48)
  • motor_play_error (49-49)
  • motor_play_slide (50-50)
core/embed/trezorhal/motor_patterns.h (8)
  • seq_Success (45-68)
  • seq_Success (45-45)
  • seq_Warning (70-93)
  • seq_Warning (70-70)
  • seq_Error (95-131)
  • seq_Error (95-95)
  • seq_Slide (133-163)
  • seq_Slide (133-133)
core/embed/extmod/modtrezorio/modtrezorio-motor.h (2)
core/embed/trezorhal/motor.c (7)
  • motor_play_whisper (185-188)
  • motor_play_light (190-193)
  • motor_play_medium (195-198)
  • motor_play_heavy (200-203)
  • motor_play_success (206-210)
  • motor_play_warning (212-216)
  • motor_play_error (218-222)
core/embed/trezorhal/motor.h (7)
  • motor_play_whisper (41-41)
  • motor_play_light (42-42)
  • motor_play_medium (43-43)
  • motor_play_heavy (44-44)
  • motor_play_success (47-47)
  • motor_play_warning (48-48)
  • motor_play_error (49-49)
core/src/trezor/lvglui/scrs/pinscreen.py (8)
core/src/trezor/utils.py (2)
  • get (614-620)
  • lcd_resume (168-197)
core/src/apps/common/passphrase.py (2)
  • get (23-30)
  • is_passphrase_pin_enabled (15-16)
core/src/trezor/lvglui/scrs/lockscreen.py (1)
  • _show_fingerprint_prompt_if_necessary (161-169)
core/src/trezor/lvglui/scrs/components/keyboard.py (1)
  • NumberKeyboard (399-613)
core/src/storage/device.py (1)
  • is_passphrase_pin_enabled (1424-1432)
core/src/trezor/loop.py (2)
  • publish (461-466)
  • wait (277-293)
core/src/trezor/lvglui/scrs/common.py (5)
  • destroy (619-623)
  • FullSizeWindow (362-703)
  • request (148-149)
  • request (307-308)
  • request (589-607)
core/src/trezor/wire/__init__.py (4)
  • wait (86-87)
  • wait (136-137)
  • wait (213-219)
  • wait (380-386)
core/src/trezor/lvglui/scrs/address.py (6)
core/src/storage/cache.py (1)
  • get_session_id (238-239)
core/src/trezor/wire/errors.py (1)
  • DataError (21-23)
core/src/trezor/lvglui/i18n/__init__.py (1)
  • gettext (31-32)
core/src/trezor/lvglui/scrs/template.py (1)
  • ADDRESS_OFFLINE_RETURN_TYPE (249-252)
core/src/trezor/enums/__init__.py (1)
  • MessageType (27-451)
core/src/trezor/messages.py (23)
  • GetAddress (958-980)
  • EthereumGetAddressOneKey (5340-5356)
  • SolanaGetAddress (7994-8008)
  • TronGetAddress (9262-9276)
  • TonGetAddress (9084-9108)
  • KaspaGetAddress (5914-5934)
  • SuiGetAddress (8648-8662)
  • CardanoGetAddress (1816-1838)
  • RippleGetAddress (7782-7796)
  • AptosGetAddress (306-320)
  • AlephiumGetAddress (76-94)
  • AlgorandGetAddress (246-260)
  • BenfenGetAddress (424-438)
  • ConfluxGetAddress (2448-2464)
  • CosmosGetAddress (2598-2614)
  • FilecoinGetAddress (5850-5866)
  • NearGetAddress (6902-6916)
  • NervosGetAddress (7352-7368)
  • NeoGetAddress (7286-7300)
  • NexaGetAddress (7454-7470)
  • NostrGetPublicKey (7554-7568)
  • PolkadotGetAddress (7714-7732)
  • ScdoGetAddress (7870-7884)
core/src/trezor/lvglui/scrs/homescreen.py (9)
core/src/trezor/lvglui/scrs/common.py (9)
  • on_click (142-143)
  • on_click (301-302)
  • AnimScreen (56-204)
  • collect_animation_targets (159-160)
  • _load_scr (162-177)
  • _load_scr (318-321)
  • load_screen (187-195)
  • load_screen (331-343)
  • Screen (207-352)
core/src/trezor/lvglui/scrs/components/pageable.py (3)
  • on_gesture (78-102)
  • Indicator (111-133)
  • set_active (127-133)
core/src/trezor/lvglui/scrs/address.py (2)
  • STATE (16-22)
  • AddressManager (13-408)
core/src/trezor/lvglui/scrs/components/container.py (1)
  • ContainerFlexCol (8-48)
core/src/trezor/lvglui/scrs/components/button.py (5)
  • clear_state (277-278)
  • add_state (280-281)
  • ListItemBtnWithSwitch (209-281)
  • ListItemBtn (88-206)
  • enable (71-75)
core/src/storage/device.py (5)
  • is_passphrase_pin_enabled (1424-1432)
  • is_passphrase_enabled (909-913)
  • set_passphrase_always_on_device (1034-1037)
  • set_passphrase_enabled (916-923)
  • set_passphrase_pin_enabled (1435-1450)
core/src/apps/base.py (1)
  • lock_device_if_unlocked (562-566)
core/src/trezor/loop.py (1)
  • spawn (488-602)
core/src/trezor/lvglui/scrs/components/listitem.py (1)
  • DisplayItemWithFont_30 (170-194)
core/src/trezor/messages.py (3)
python/src/trezorlib/messages.py (5)
  • GetPassphraseState (5526-5543)
  • MessageType (36-460)
  • PassphraseState (5546-5563)
  • UnLockDevice (5566-5567)
  • UnLockDeviceResponse (5570-5587)
core/src/trezor/enums/__init__.py (1)
  • MessageType (27-451)
python/src/trezorlib/protobuf.py (1)
  • MessageType (189-249)
🪛 Ruff (0.12.2)
core/src/trezor/pin.py

43-43: Found useless expression. Either assign it to a variable or remove it.

(B018)


80-81: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

core/src/apps/common/backup_types.py

79-84: Use a dictionary instead of consecutive if statements

(SIM116)

core/src/apps/common/request_pin.py

154-154: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


160-160: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


162-162: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


181-181: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


196-196: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


223-223: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


241-241: Within an except clause, raise exceptions with raise ... from err or raise ... from None to distinguish them from errors in exception handling

(B904)


305-305: Do not assert False (python -O removes these calls), raise AssertionError()

Replace assert False

(B011)

core/src/apps/ethereum/onekey/sign_tx.py

344-352: Return the condition directly

(SIM103)


356-365: Return the condition directly

(SIM103)

core/src/trezor/lvglui/scrs/reset_device.py

137-138: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)


401-402: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)


576-577: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

core/src/trezor/ui/layouts/lvgl/__init__.py

1275-1278: Use ternary operator min_len = 6 if attach_wall_only else 4 instead of if-else-block

Replace if-else-block with min_len = 6 if attach_wall_only else 4

(SIM108)

core/src/trezor/lvglui/scrs/homescreen.py

4930-4931: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

core/src/apps/base.py

706-711: Use a single if statement instead of nested if statements

Combine if statements using and

(SIM102)

🔇 Additional comments (110)
core/embed/extmod/modtrezorui/mipi_lcd.c (1)

710-710: Good improvement using symbolic constant.

Replacing the magic number with LTDC_CDSR_VSYNCS improves readability.

core/src/trezor/qr.py (1)

241-241: Good explicit vibration pattern specification.

Using motor.SUCCESS is clearer than relying on default behavior.

core/src/trezor/enums/BackupType.py (1)

8-10: New backup type constants look good.

Sequential values and consistent naming pattern.

core/src/trezor/lvglui/scrs/components/container.py (1)

138-140: LGTM - UI padding refinement

Clean change from uniform vertical padding to separate top/bottom padding control.

crypto/slip39.h (2)

28-28: LGTM - SLIP39 wordlist constant

Standard macro definition for word count.


41-41: LGTM - SLIP39 wordlist declaration

Proper external array declaration.

core/src/apps/tron/serialize.py (1)

201-203: LGTM - Optional field serialization

Correct implementation following existing pattern for optional fields.

core/embed/extmod/modtrezorcrypto/modtrezorcrypto-bip39.h (2)

38-38: LGTM - Updated function call

Correct addition of is_slip39 parameter set to false for BIP39 wordlist.


57-57: LGTM - Updated function call

Correct addition of is_slip39 parameter set to false for BIP39 wordlist.

core/src/apps/ethereum/sign_tx_eip1559.py (2)

87-87: LGTM - Extract raw data logic

Clean extraction of raw data detection logic.


98-98: LGTM - Pass extracted variable

Correct usage of extracted has_raw_data variable.

crypto/slip39.c (1)

34-111: Consistent identifier updates look good.

The standardization of WORDS_COUNT to SLIP39_WORD_COUNT and slip39_wordlist to SLIP39_WORDLIST maintains consistent naming across the codebase.

core/embed/rust/src/trezorhal/bip39.rs (1)

44-44: FFI parameter addition is correct.

The false parameter correctly indicates BIP39 wordlist usage in the updated function signature.

core/src/apps/tron/sign_tx.py (1)

97-103: Verify removal of fee limit check is intentional.

The fee limit safety check was removed. Confirm this won't allow excessive fees without user awareness.

core/src/apps/ethereum/tokens.py.mako (1)

39-49: Consistent return type improvement.

Returning UNKNOWN_TOKEN instead of None eliminates null checks and improves type safety.

core/src/trezor/lvglui/scrs/components/radio.py (2)

104-104: State tracking attribute added.

The changed flag helps track selection modifications.


122-122: Change detection logic is correct.

Setting changed = True when item is selected properly tracks user interactions.

core/src/apps/ethereum/tokens.py (1)

30-30: LGTM! Type safety improvement.

The return type change eliminates null returns and guarantees a valid token response.

core/src/apps/cardano/seed.py (1)

209-217: LGTM! Clear conditional logic.

The branching correctly handles THD89 and mnemonic type cases.

core/src/apps/common/mnemonic.py (3)

1-1: LGTM! Consistent import alias.

The alias is used consistently throughout the file.


48-58: LGTM! Extended SLIP-39 backup support.

The extendable parameter correctly extends backup type handling.


66-67: LGTM! Simplified conditional logic.

Direct error checking removes unnecessary branching.

core/src/trezor/lvglui/i18n/keys.py (3)

2094-2097: Comment updates look good.

Clear, simple language for backup types.


2211-2213: Comment improvement is clear.

Better wording for invalid share message.


2231-2238: New attach-to-pin keys added correctly.

All four new string keys follow the existing pattern.

core/src/apps/ethereum/onekey/sign_safe_tx.py (3)

43-45: Hash precomputation improves flow.

EIP-712 encoding with \x19\x01 prefix is correct.


59-61: Passing precomputed hashes to confirmation function.

Cleaner approach than computing hashes after confirmation.


83-83: Function rename reflects its purpose better.

get_safe_message_hash is more accurate than get_safe_tx_hash.

core/src/apps/common/backup.py (1)

14-46: Stub implementation is well-structured.

Commented code shows clear implementation plan.

core/src/trezor/lvglui/scrs/components/navigation.py (2)

6-12: Parameterization improves flexibility.

Default values maintain backward compatibility.


16-23: Parameters used correctly.

Replaces hardcoded values with configurable options.

core/src/apps/management/recovery_device/word_validity.py (4)

1-4: Import reorganization is clean.

TYPE_CHECKING guard avoids runtime imports.


24-28: Local imports avoid circular dependencies.

Good practice for optional runtime imports.


42-46: Uses new backup type utility functions.

Cleaner than direct enum comparisons.


52-52: Function renamed to indicate private use.

Leading underscore follows Python conventions.

core/src/storage/recovery.py (6)

137-139: LGTM - Clean global state initialization


141-143: LGTM - Simple flag setter


146-148: LGTM - Clean flag getter


150-154: LGTM - Proper error handling


156-159: LGTM - Clean secret setter


161-165: LGTM - Clean state reset

core/src/trezor/lvglui/scrs/fingerprints.py (7)

234-235: LGTM - Consistent animation method


426-426: LGTM - Clean flag initialization


429-429: LGTM - Flag reset logic


442-444: LGTM - Vibration throttling


457-457: LGTM - Success feedback


493-501: LGTM - Improved flow organization


568-569: LGTM - Success feedback in finally

core/src/storage/recovery_shares.py (1)

6-6: LGTM - Clean dictionary initialization

crypto/bip39.c (9)

34-34: LGTM - Required header include


255-257: LGTM - Clean parameter addition


260-262: LGTM - Proper wordlist selection


267-269: LGTM - Consistent wordlist logic


284-285: LGTM - Clean parameter addition


293-293: LGTM - Proper function call


297-301: LGTM - Consistent wordlist selection


327-328: LGTM - Clean parameter addition


333-335: LGTM - Proper wordlist selection

core/src/trezor/lvglui/scrs/recovery_device.py (11)

8-8: LGTM - Updated import


14-14: LGTM - Clean parameter addition


25-25: LGTM - Proper parameter passing


27-27: LGTM - Consistent naming


55-55: LGTM - Consistent naming


59-59: LGTM - Reasonable timing


63-63: LGTM - Clean parameter addition


67-67: LGTM - UI positioning change


101-101: LGTM - Fixed calculation


133-135: LGTM - Scroll behavior config


171-171: LGTM - Fixed button check

core/embed/extmod/modtrezorio/modtrezorio-motor.h (1)

59-166: Code looks good.

core/src/apps/management/recovery_device/recover.py (1)

1-118: Changes look good.

core/src/apps/management/recovery_device/create_mul_shares.py (1)

1-164: New file looks good.

core/embed/trezorhal/motor_patterns.h (1)

1-164: Header file is well-structured.

core/embed/trezorhal/motor.h (1)

21-24: Good typo fix.

Fixed "durration_us" to "duration_us".

core/embed/extmod/modtrezorcrypto/modtrezorcrypto-se-thd89.h (2)

27-28: Constants already defined
USER_PIN_ENTERED and PASSPHRASE_PIN_ENTERED live in core/embed/trezorhal/se_thd89.h. No extra definitions needed.

Likely an incorrect or invalid review comment.


1011-1013: Passphrase validation contradicts error message.

Code raises error for empty passphrase but comment says it "cannot be empty". This is confusing.

- if (passphrase_buf.len == 0) {
-   mp_raise_ValueError("Passphrase cannot be empty");
- }
+ // Allow empty passphrase for standard usage
+ // if (passphrase_buf.len == 0) {
+ //   mp_raise_ValueError("Passphrase cannot be empty");
+ // }

Likely an incorrect or invalid review comment.

core/src/trezor/lvglui/scrs/template.py (12)

86-86: Good refactoring

Using the utility function for address formatting.

Also applies to: 350-350


184-246: Clean consolidation

Unified derivation screen reduces code duplication.


251-252: Better naming

More descriptive constant names.


315-315: Network support expanded

Added Kaspa to supported networks.


402-419: Proper event routing

Network-specific event publishing with error handling.


436-463: Well-structured options

Network-specific derivation paths properly configured.


917-1018: New Safe transaction UI

Well-structured approval hash display component.


1020-1232: Comprehensive Safe transaction display

Good warning for delegate calls and clear operation display.


1435-1435: Proper conditional rendering

Amount component created only when needed.

Also applies to: 1458-1460


1091-1092: Clear operation display

Color-coded operation types for visual clarity.

Also applies to: 1532-1532


3680-3687: Enhanced navigation

More flexible navigation component with customizable styling.


3783-3783: Better haptic feedback

Specific vibration modes for different interactions.

Also applies to: 3792-3792

core/embed/extmod/modtrezorconfig/modtrezorconfig.c (4)

113-120: Function signature change looks correct.

The new pin_use_type parameter and tuple return type align with the enhanced PIN verification system.


119-167: Implementation correctly handles the new PIN type system.

The function properly validates arguments, calls the secure element with the pin type, and returns the expected tuple format.


169-180: Simple delegation to unlock function is appropriate.

Since check_pin now has the same signature and behavior as unlock, this delegation makes sense.


597-642: SLIP39 import function implementation looks solid.

Proper parameter validation, secure element integration, and error handling are all in place.

core/src/trezor/ui/layouts/lvgl/__init__.py (4)

1200-1200: Good addition of min_len parameter.

This enhances passphrase validation capabilities.


1602-1602: Action string update looks appropriate.

The slide-to-continue message aligns with the UI flow.


2639-2674: New Safe approve hash function looks comprehensive.

Properly handles all required parameters and UI integration.


2677-2730: New Safe exec transaction function is well-structured.

Handles complex parameter set appropriately for the UI requirements.

crypto/bip39.h (1)

56-59: Implementations match new is_slip39 signatures.

core/src/apps/debug/load_device.py (1)

9-9: Import path is valid

core/src/trezor/lvglui/scrs/components/slider.py (1)

74-74: Motor vibration enhancements look good.

Proper use of new motor API patterns. Event handling logic correct.

Also applies to: 127-129, 136-136, 156-156

core/src/trezor/ui/layouts/lvgl/recovery.py (1)

63-65: Good SLIP39 support.

Also applies to: 144-144

core/embed/extmod/modtrezorcrypto/modtrezorcrypto-slip39.h (2)

27-57: Clean refactor to string prefixes.


92-92: Good error message updates.

Also applies to: 108-109

core/src/apps/management/reset_device/layout.py (1)

32-40: Smart chunking logic.

core/src/apps/base.py (1)

15-28: Solid attach-to-pin implementation.

Also applies to: 158-161, 251-276, 688-774

core/src/trezor/crypto/slip39.py (2)

70-94: Well-designed extendable backup support.

Also applies to: 124-125, 145-146, 160-161, 506-515


250-311: Good validation in extend_mnemonics.

core/src/trezor/lvglui/scrs/components/keyboard.py (2)

236-260: Good job adding consistent haptic feedback.

The PRESSED event handlers for motor vibration are implemented uniformly across all keyboard types.

Also applies to: 522-522, 745-745, 1124-1124


61-67: SLIP-39 support looks good.

The conditional word completion and mask logic properly handles both BIP39 and SLIP39 mnemonics.

Also applies to: 340-349

core/src/trezor/lvglui/scrs/address.py (1)

411-792: Smart refactoring to use a generator.

The iterator pattern saves memory by yielding chain configs on demand.

core/src/apps/ethereum/layout.py (1)

597-872: Safe transaction support is thorough.

Both legacy and EIP-1559 fee models are properly handled across all new functions.

Comment on lines +180 to +182
# pyright: off
word = slip39.button_sequence_to_word(self.button_sequence)
# pyright: on
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix underlying type issues instead of disabling checks.

Consider addressing the root type problem rather than disabling pyright.

🤖 Prompt for AI Agents
In core/src/trezor/ui/components/tt/keyboard_slip39.py around lines 180 to 182,
the pyright type checking is disabled for the line assigning word from
slip39.button_sequence_to_word(self.button_sequence). Instead of turning off
pyright, investigate the type mismatch causing the error. Adjust the type
annotations or convert the input/output types appropriately so that the call to
button_sequence_to_word matches expected types and passes pyright checks without
disabling them.

Comment on lines +126 to +128
# pyright: off
self.mask = slip39.KEYBOARD_FULL_MASK
# pyright: on
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Fix underlying type issues instead of disabling checks.

Consider addressing the root type problem rather than disabling pyright.

🤖 Prompt for AI Agents
In core/src/trezor/ui/components/tt/keyboard_slip39.py around lines 126 to 128,
the pyright type checking is disabled to avoid type errors with self.mask
assignment. Instead of turning off pyright, investigate the type of
slip39.KEYBOARD_FULL_MASK and ensure it matches the expected type of self.mask.
Adjust type annotations or perform necessary type conversions so that the
assignment is type-safe and pyright checks pass without disabling them.

Comment thread core/src/trezor/pin.py
if _scr_need_create:
if message is not None:
text = ""
if message == "read fp data":
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Unclear abbreviation.

"read fp data" should be "read fingerprint data".

🤖 Prompt for AI Agents
In core/src/trezor/pin.py at line 51, replace the abbreviation "read fp data"
with the full phrase "read fingerprint data" to improve code clarity and
readability.

Comment thread core/src/trezor/pin.py
Comment on lines +41 to +46
if _scr_need_create:
try:
_scr.subtitle
except Exception:
_scr = None
_scr_need_create = True
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix logic error.

The code checks if _scr is None, then tries to access _scr.subtitle. This will always fail.

🧰 Tools
🪛 Ruff (0.12.2)

43-43: Found useless expression. Either assign it to a variable or remove it.

(B018)

🤖 Prompt for AI Agents
In core/src/trezor/pin.py around lines 41 to 46, the code attempts to access
_scr.subtitle even when _scr might be None, causing an error. Fix this by first
checking if _scr is not None before trying to access its subtitle attribute,
ensuring the attribute access only happens on a valid _scr object.

Comment on lines +181 to +182
if __debug__:
print("is_safe_tx", _is_safe_tx)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove debug print.

-        if __debug__:
-            print("is_safe_tx", _is_safe_tx)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if __debug__:
print("is_safe_tx", _is_safe_tx)
🤖 Prompt for AI Agents
In core/src/apps/ethereum/onekey/sign_tx_eip1559.py at lines 181 to 182, remove
the debug print statement that outputs "is_safe_tx" and its value. This print is
only for debugging and should be deleted to clean up the code.

Comment on lines +4931 to +4961
if target == self.attach_to_pin:
global _attach_to_pin_task_running

_attach_to_pin_task_running = True

async def handle_attach_to_pin():
try:
from trezor.ui.layouts.lvgl.attach_to_pin import (
show_attach_to_pin_window,
)

ctx = wire.DUMMY_CONTEXT
result = await show_attach_to_pin_window(ctx)

if result:
if hasattr(self, "prev_scr") and self.prev_scr:
self.load_screen(self)
else:
self.load_screen(self)

return result
except Exception:
if hasattr(self, "prev_scr") and self.prev_scr:
self.load_screen(self)
else:
self.load_screen(self)
return False
finally:
global _attach_to_pin_task_running
_attach_to_pin_task_running = False

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Flag unused
_attach_to_pin_task_running is never read, so it can’t prevent double clicks.

🤖 Prompt for AI Agents
In core/src/trezor/lvglui/scrs/homescreen.py around lines 4931 to 4961, the
variable _attach_to_pin_task_running is set but never read, so it does not
prevent double clicks as intended. To fix this, add a check at the start of the
function to return early if _attach_to_pin_task_running is True, ensuring the
task does not run multiple times concurrently. Keep setting it to True when
starting and False when finishing the task to properly track the running state.

Comment thread core/src/trezor/motor.py
Comment on lines +24 to +47
def vibrate(
style: VIBRATE_STYLE = LIGHT, force: bool = False
) -> VIBRATE_STYLE | None:
if not storage_device.keyboard_haptic_enabled() and not force:
return None
if style == WHISPER:
MOTOR_CTL.play_whisper()
elif style == LIGHT:
MOTOR_CTL.play_light()
elif style == MEDIUM:
MOTOR_CTL.play_medium()
elif style == HEAVY:
MOTOR_CTL.play_heavy()
elif style == SUCCESS:
MOTOR_CTL.play_success()
elif style == WARNING:
MOTOR_CTL.play_warning()
elif style == ERROR:
MOTOR_CTL.play_error()
else:
if __debug__:
print("vibrate strong")
MOTOR_CTL.tick()
print(f"vibrate: unknown style {style}")
pass
return style
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify breaking changes across codebase.

Function signature changed from vibrate(weak: bool) to vibrate(style: VIBRATE_STYLE, force: bool). Check all callers updated.


🏁 Script executed:

#!/bin/bash
# Search for old vibrate function calls that might not be updated
rg -A 3 "vibrate\(" --type py | grep -E "(True|False)" | head -20

Length of output: 896


🏁 Script executed:

#!/bin/bash
rg -n "motor\.vibrate\(weak=True\)" core/src/trezor/uart.py

Length of output: 110


Update leftover vibrate call

  • core/src/trezor/uart.py:147 still uses motor.vibrate(weak=True)
🤖 Prompt for AI Agents
In core/src/trezor/uart.py around line 147, update the call to motor.vibrate by
replacing the deprecated argument weak=True with the current style argument
using the appropriate VIBRATE_STYLE enum value. This ensures compatibility with
the updated vibrate method signature in core/src/trezor/motor.py which no longer
accepts weak but uses style instead.

await button_request(ctx, "word_count", code=ButtonRequestType.MnemonicWordCount)

optional_str = (
_(i18n_keys.OPTION__STR_WRODS).format(12)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo: WRODSWORDS

-        _(i18n_keys.OPTION__STR_WRODS).format(12)
+        _(i18n_keys.OPTION__STR_WORDS).format(12)

Also applies to: 22-22, 24-24, 26-26, 28-28

🤖 Prompt for AI Agents
In core/src/trezor/ui/layouts/lvgl/recovery.py at lines 20, 22, 24, 26, and 28,
there is a typo in the i18n key where "WRODS" should be corrected to "WORDS".
Update all these occurrences by replacing "OPTION__STR_WRODS" with
"OPTION__STR_WORDS" to fix the typo.

backup_type = storage_device.get_backup_type()
if backup_type == BackupType.Bip39:
optional_str = (
_(i18n_keys.OPTION__STR_WRODS).format(12)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix typo: WRODSWORDS

-                _(i18n_keys.OPTION__STR_WRODS).format(12)
+                _(i18n_keys.OPTION__STR_WORDS).format(12)
-                _(i18n_keys.OPTION__STR_WRODS).format(18)
+                _(i18n_keys.OPTION__STR_WORDS).format(18)
-                _(i18n_keys.OPTION__STR_WRODS).format(24)
+                _(i18n_keys.OPTION__STR_WORDS).format(24)
-                _(i18n_keys.OPTION__STR_WRODS).format(20)
+                _(i18n_keys.OPTION__STR_WORDS).format(20)
-                _(i18n_keys.OPTION__STR_WRODS).format(33)
+                _(i18n_keys.OPTION__STR_WORDS).format(33)

Also applies to: 40-40, 42-42, 46-46, 48-48

🤖 Prompt for AI Agents
In core/src/trezor/ui/layouts/lvgl/recovery.py at lines 38, 40, 42, 46, and 48,
there is a typo in the i18n key 'OPTION__STR_WRODS' which should be corrected to
'OPTION__STR_WORDS'. Update all these occurrences to fix the typo.

# else:
# self.item.enable_bg_color(enable=False)
# self.btn_yes.disable()
# endregion
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Remove the orphaned comment.

The # endregion comment has no matching # region comment.

🤖 Prompt for AI Agents
In core/src/trezor/lvglui/scrs/reset_device.py at line 197, remove the orphaned
comment '# endregion' because there is no corresponding '# region' comment to
match it.

@guowei0105 guowei0105 closed this Jul 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants