fix: surface locked Trezor as DeviceBusy via trezor-connect-rs 0.3.4#119
Conversation
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).
There was a problem hiding this comment.
💡 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".
|
Release created for testing as v0.3.9 here. |
|
I'll implement and test on both platforms |
jvsena42
left a comment
There was a problem hiding this comment.
✅ Validated end-to-end from bitkit-ios #614 (Connect Hardware flow) on a physical Trezor Safe 7, regtest.
- Consumed via bitkit-core v0.3.9, which ships this PR's
ThpError::DeviceLocked → TrezorError::DeviceBusymapping (backed bytrezor-connect-rs0.3.4). - bitkit-ios now surfaces the typed
TrezorError.DeviceBusy(andDeviceLocked) as a dedicated "Trezor is busy — unlock and try again" message instead of a generic connection error. - QA retest passed the connect flow end-to-end: stale iOS bond shows an actionable error, connect → pairing code → Paired → Finish works, and re-pair after Remove works. No more locked-device close/reopen churn observed.
Approving from the bitkit-ios side
|
Same from bitkit-android: synonymdev/bitkit-android#1062 |
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 -> retryloop 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-rs0.3.4, which:ThpError::DeviceLockedvariant.DeviceLockedas non-retryable: no more close/reopen churn on a locked device.try_to_unlock=truehandshake 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
trezor-connect-rsfrom 0.3.3 to 0.3.4 (both target-gated dependency entries) and refreshCargo.lock.ThpError::DeviceLockedto the existing typedTrezorError::DeviceBusyinsrc/modules/trezor/errors.rs, so a locked device surfaces as the back-off signal apps already understand rather than a genericConnectionError.DeviceLocked -> DeviceBusymapping../build.sh all.Notes
TrezorError::DeviceBusyalready existed (Swiftcase DeviceBusy/ KotlinTrezorException.DeviceBusy, discriminant 4), so only the compiled binding artifacts were rebuilt. No hand-written binding changes.Package.swiftonly has its xcframework.zip checksum updated. No package version bump was performed (./build.sh allwithout-r); the release/tag bump can happen separately.TrezorFeatures.unlockedandtrezor_refresh_features()already exist for callers that want to poll lock state.Testing
cargo test --lib trezor::errorspasses against the publishedtrezor-connect-rs0.3.4.cargo fmt --checkclean../build.sh allcompleted 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.