Skip to content

Support Ledger Flex and Ledger Stax (udev + device detection)#77

Merged
justanwar merged 2 commits intomasterfrom
add_new_hw
Apr 22, 2026
Merged

Support Ledger Flex and Ledger Stax (udev + device detection)#77
justanwar merged 2 commits intomasterfrom
add_new_hw

Conversation

@levoncrypto
Copy link
Copy Markdown

No description provided.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Dec 20, 2025

Summary by CodeRabbit

  • New Features

    • Added support for Ledger Stax and Ledger Flex hardware devices.
    • Enhanced device recognition and initialization.
  • Chores

    • Consolidated device configuration rules for improved system compatibility.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

Updates udev rules to consolidate multiple Ledger hardware device rules into a single pattern, and extends device recognition in the Ledger plugin to support new Stax and Flex device models with corresponding vendor IDs and model identifiers.

Changes

Cohort / File(s) Summary
UDev Rules Consolidation
contrib/udev/20-hw1.rules
Consolidates device-specific udev rule blocks for multiple Ledger models (Blue, Nano S, Aramis, HW.2, Nano X, Nano S Plus, Stax) into unified USB and hidraw rules targeting vendor 2c97; updates header comment and adds descriptive enumeration of consolidated device groups.
Device Recognition Updates
electrum_dash/plugins/ledger/ledger.py
Replaces RFU entries in DEVICE_IDS with "Ledger Stax" (0x2c97/0x0006) and "Ledger Flex" (0x2c97/0x0007); adds corresponding model ID mappings (0x60 and 0x70); extends _recognize_device() logic to return device names for new models.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Udev rule consolidation: Verify that the single consolidated rule covers all previously distinct device product IDs and doesn't inadvertently match unintended devices
  • Device mapping accuracy: Confirm vendor and product IDs (0x2c97) and model codes (0x60, 0x70) are correct for Stax and Flex
  • Recognition logic: Ensure new branches in _recognize_device() are reachable and return expected device name strings

Poem

🐰 A hop through Ledger's garden fair,
New Stax and Flex now everywhere!
Rules consolidated, neat and bright,
Device IDs mapping just right,
Hardware harmony takes flight!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning No description was provided by the author, making it impossible to assess whether the description relates to the changeset. Add a pull request description explaining the purpose of supporting Ledger Flex and Stax, the changes made to udev rules and device detection logic, and any testing or compatibility notes.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding support for two new Ledger hardware wallet models (Flex and Stax) with udev rules and device detection updates.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add_new_hw

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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: 0

🧹 Nitpick comments (1)
contrib/udev/20-hw1.rules (1)

1-8: Approve the udev rule consolidation, but note minor documentation gap.

The consolidation of device-specific rules into a single vendor-level rule is a good simplification. The rule correctly matches all Ledger devices with vendor ID 2c97, including the new Stax and Flex models.

However, the comment on line 4 lists "Stax" but omits "Flex" from the enumeration. Consider adding "Flex" to maintain complete documentation.

📝 Suggested comment update
-# Blue, NanoS, Aramis, HW.2, Nano X, NanoSP, Stax, Ledger Test,
+# Blue, NanoS, Aramis, HW.2, Nano X, NanoSP, Stax, Flex, Ledger Test,
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3f10d72 and 29a04c6.

📒 Files selected for processing (2)
  • contrib/udev/20-hw1.rules (1 hunks)
  • electrum_dash/plugins/ledger/ledger.py (3 hunks)
🔇 Additional comments (3)
electrum_dash/plugins/ledger/ledger.py (3)

678-679: LGTM! Model ID additions align with modern device recognition.

The model IDs 0x60 (Stax) and 0x70 (Flex) are correctly added to support modern firmware where product_id >> 8 extracts the model identifier. This allows recognition of product IDs in ranges 0x6000-0x60FF for Stax and 0x7000-0x70FF for Flex.


721-724: LGTM! Device recognition logic properly extended.

The explicit checks for Stax and Flex product keys are correctly added. These handle the legacy product ID format and work in conjunction with the modern recognition system (lines 727-732) to support both old and new firmware versions.


667-668: Product IDs for Stax and Flex are correct and properly implemented.

Stax device ID (0x2c97, 0x0006) and Flex device ID 0x0007 / 0x7000 are the official Ledger identifiers. The dual system correctly supports both legacy product IDs in DEVICE_IDS and modern model IDs (0x60 for Stax, 0x70 for Flex) via vendor registration, enabling backward and forward compatibility with both old and new firmware versions.

@justanwar
Copy link
Copy Markdown
Member

Tested OK on Ledger Nano S (not the target of this PR, just in case things break)

@justanwar justanwar merged commit ff8c98e into master Apr 22, 2026
5 checks passed
@justanwar justanwar deleted the add_new_hw branch April 22, 2026 06:37
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.

3 participants