Skip to content

fix: surface locked Trezor as DeviceBusy via trezor-connect-rs 0.3.4#119

Open
coreyphillips wants to merge 2 commits into
masterfrom
fix/trezor-device-locked-device-busy
Open

fix: surface locked Trezor as DeviceBusy via trezor-connect-rs 0.3.4#119
coreyphillips wants to merge 2 commits into
masterfrom
fix/trezor-device-locked-device-busy

Conversation

@coreyphillips

Copy link
Copy Markdown
Collaborator

Context

bitkit-ios #613 (Android counterpart bitkit-android #1030) reports that connecting to a locked Trezor keeps the device busy: the transport was churning in a close -> wait 2000ms -> reopen -> retry loop and ultimately failing with a locked-device handshake error, instead of backing off and letting the user unlock.

The upstream fix landed in trezor-connect-rs 0.3.4, which:

  • Adds a typed ThpError::DeviceLocked variant.
  • Classifies DeviceLocked as non-retryable: no more close/reopen churn on a locked device.
  • Makes a single try_to_unlock=true handshake attempt so the device itself prompts the user to unlock, then surfaces the result to the caller.

This PR consumes that release and threads the typed signal through to apps.

Changes

  • Bump trezor-connect-rs from 0.3.3 to 0.3.4 (both target-gated dependency entries) and refresh Cargo.lock.
  • Map the new ThpError::DeviceLocked to the existing typed TrezorError::DeviceBusy in src/modules/trezor/errors.rs, so a locked device surfaces as the back-off signal apps already understand rather than a generic ConnectionError.
  • Add a unit test covering the DeviceLocked -> DeviceBusy mapping.
  • Regenerate iOS, Android, and Python bindings via ./build.sh all.

Notes

  • The UniFFI interface is unchanged: TrezorError::DeviceBusy already existed (Swift case DeviceBusy / Kotlin TrezorException.DeviceBusy, discriminant 4), so only the compiled binding artifacts were rebuilt. No hand-written binding changes.
  • Package.swift only has its xcframework.zip checksum updated. No package version bump was performed (./build.sh all without -r); the release/tag bump can happen separately.
  • TrezorFeatures.unlocked and trezor_refresh_features() already exist for callers that want to poll lock state.

Testing

  • cargo test --lib trezor::errors passes against the published trezor-connect-rs 0.3.4.
  • cargo fmt --check clean.
  • ./build.sh all completed successfully for iOS, Android, and Python.

Follow-up

The app-side back-off / unlock-prompt UX stays owned by bitkit-ios #613 and bitkit-android #1030, which consume this bitkit-core once released.

Bump trezor-connect-rs to 0.3.4 and map the new typed ThpError::DeviceLocked
to TrezorError::DeviceBusy, so a locked Trezor during the THP handshake is
surfaced as the typed back-off signal instead of a generic ConnectionError.
Mobile clients can prompt the user to unlock rather than reconnecting in a loop.

0.3.4 also classifies DeviceLocked as non-retryable upstream: it no longer
churns the transport (close/reopen loop) on a locked device and instead makes a
single try_to_unlock handshake attempt so the device prompts for unlock.

Regenerates the iOS/Android/Python bindings via ./build.sh all (compiled
artifacts only; the UniFFI interface is unchanged since DeviceBusy already
existed).
@coreyphillips coreyphillips requested a review from jvsena42 July 1, 2026 13:06
@coreyphillips coreyphillips self-assigned this Jul 1, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 986000b65b

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread Package.swift Outdated
@coreyphillips

Copy link
Copy Markdown
Collaborator Author

Release created for testing as v0.3.9 here.

@jvsena42

jvsena42 commented Jul 2, 2026

Copy link
Copy Markdown
Member

@piotr-iohk

@jvsena42

jvsena42 commented Jul 2, 2026

Copy link
Copy Markdown
Member

I'll implement and test on both platforms

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.

2 participants