Skip to content

feat(trezor): return typed PassphraseResponse#91

Open
coreyphillips wants to merge 1 commit into
masterfrom
feat/trezor-passphrase-response
Open

feat(trezor): return typed PassphraseResponse#91
coreyphillips wants to merge 1 commit into
masterfrom
feat/trezor-passphrase-response

Conversation

@coreyphillips
Copy link
Copy Markdown
Collaborator

Migrates Trezor passphrase handling from a String to the typed PassphraseResponse enum (Cancel / Standard / Hidden { value }) introduced in trezor-connect-rs 0.3.0

Description

Bumps trezor-connect-rs 0.2.8 → 0.3.0 and adopts its new typed passphrase
callback, replacing the old stringly-typed API.

Why: the previous on_passphrase_request(...) -> String encoding used
"" to mean cancel and any non-empty string to mean hidden wallet. This
left no way to express the standard wallet case (Some("") on the device —
an empty passphrase that selects the standard wallet rather than a hidden one).
A user selecting the standard wallet would send "", which was interpreted as
cancel. The new Standard variant closes that gap.

Changes:

  • on_passphrase_request now returns PassphraseResponse (Cancel /
    Standard / Hidden { value }) instead of String.
  • Exposes the upstream PassphraseResponse to UniFFI bindings via
    #[uniffi::remote(Enum)] rather than forking the type (trezor-connect-rs
    intentionally has no uniffi dependency). The variant list is kept in sync
    with upstream and guarded by tests.
  • Simplifies UiCallbackAdapter::on_passphrase_request to a pass-through (both
    traits now return the same upstream type). PIN keeps the legacy
    String → Option encoding (no upstream enum exists for it).
  • Adds TrezorError::PassphraseCancelled, mapped from the new upstream
    TcDeviceError::PassphraseCancelled.
  • Adds 6 adapter tests covering PIN and passphrase mapping, including the
    critical Standard-must-not-become-Cancel case and on_device forwarding.
  • Bumps version 0.1.60 → 0.1.61 (Cargo.toml, Package.swift + checksum,
    gradle.properties) and regenerates Swift / Kotlin / Python bindings.

⚠️ Breaking FFI change. Consumers implementing TrezorUiCallback must
update onPassphraseRequest to return a PassphraseResponse instead of a
String. Requires a coordinated change in the bitkit iOS/Android apps.

Preview

N/A — Rust FFI library change, no UI surface.

QA Notes

Automated:

  • cargo test modules::trezor — all pass, including the new
    test_passphrase_adapter_* / test_pin_adapter_* cases.
  • cargo clippy — no new warnings introduced by this change.

Manual (on-device, against the updated app binding):

  • Standard wallet: select standard / empty passphrase → wallet derives and
    the operation proceeds (previously this was treated as cancel).
  • Hidden wallet: enter a passphrase → hidden wallet derives correctly.
  • Cancel: dismiss the passphrase prompt → operation aborts with
    PassphraseCancelled.
  • On-device entry: enter passphrase on the Trezor itself → on_device path
    acknowledges and proceeds.

 - Migrates Trezor passphrase handling from a `String` to the typed `PassphraseResponse` enum (`Cancel` / `Standard` / `Hidden { value }`) introduced in trezor-connect-rs 0.3.0
@coreyphillips coreyphillips self-assigned this May 25, 2026
@coreyphillips
Copy link
Copy Markdown
Collaborator Author

Release for testing here.

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.

1 participant