Skip to content

tracking: upgrade Trezor integration to trezor-connect-rs 10.0.0 #161

Open

Description

@coreyphillips

Goal

Upgrade Bitkit Core from trezor-connect-rs 0.4.0 to the published 10.0.0 release and implement the corresponding Rust and UniFFI changes. Address derivation, hardware wallet import, message operations, direct transaction signing, and PSBT signing must keep working on desktop, Android, and iOS.

Upstream references:

This is a dependency and API migration with mobile consumer follow-up, rather than a manifest-only update.

Current integration and concrete migration risks

The reviewed Core source is master at ef91d0c.

  • Both target-specific dependency declarations in Cargo.toml still require 0.4.0. The lockfile also resolves 0.4.0.
  • src/modules/trezor/types.rs directly constructs upstream GetPublicKeyParams without a struct default. Version 10 adds cross_chain, so this conversion must be updated to compile.
  • TrezorPublicKeyResponse currently forwards only xpub and existing node metadata. Version 10 normalizes xpub to legacy xpub/tpub and adds xpub_segwit, descriptor, and displayable_public_key.
  • src/modules/onchain/implementation.rs::detect_account_type treats xpub/tpub as Legacy. Passing a normalized BIP-49 or BIP-84 key without an explicit account type can therefore select the wrong wallet script type. resolve_wallet_setup already supports account_type_override for these prefixes.
  • TrezorVerifyMessageParams currently documents an omitted coin as Bitcoin and forwards None unchanged. Upstream verification now requires a coin, so leaving this conversion unchanged breaks that documented default.
  • The address, public-key, message-signing, and direct transaction conversions preserve an omitted coin. Version 10 uses path inference instead of always defaulting to Bitcoin.

Implementation checklist

1. Dependency and platform configuration

  • Update both target-specific declarations to version = "10.0.0" and refresh Cargo.lock using the registry release.
  • Preserve USB plus Bluetooth on non-iOS targets and default-features = false with Bluetooth on iOS. Keep transport behavior working through the existing mobile callback adapters.
  • Preserve PSBT support. Upstream now includes it unconditionally and retains psbt as a no-op compatibility feature, so removing that flag is optional cleanup.
  • Confirm the intended version is resolved on all targets and no local path override or unrelated dependency changes enter the release.

2. Public-key response and wallet import

  • Expose xpub_segwit: Option<String>, descriptor: Option<String>, and displayable_public_key: String in TrezorPublicKeyResponse, mapping every field from the upstream response.
  • Adopt and document the normalized xpub/tpub contract for the existing xpub field. Consumers must have an explicit migration path before using this changed field semantics.
  • For wallet setup from normalized keys, carry the selected account type from the requested derivation path or account selection into account_type_override. BIP-49 must remain Wrapped SegWit, BIP-84 Native SegWit, and BIP-86 Taproot.
  • Alternatively, existing prefix-based import flows may use the actual SLIP-132 key in xpub_segwit for BIP-49/BIP-84. Treat Taproot separately because upstream xpub_segwit can contain a descriptor, not a Base58 key.
  • Use displayable_public_key for user-facing display where appropriate. Never pass a descriptor string to an API that expects an extended key.
  • Verify existing stored ypub/zpub/upub/vpub keys remain accepted. Changing the representation must not silently rewrite backups, alter wallet identity, create duplicate wallets, or change derived addresses.
  • Keep node metadata and root_fingerprint intact, including the internal get_device_fingerprint flow.

3. Coin inference and explicit path overrides

  • Let omitted coins reach upstream path inference for address derivation, public-key derivation, message signing, and direct transaction signing. Update Core documentation that currently promises an unconditional Bitcoin default.
  • Expose a default-false cross_chain option through the three corresponding UniFFI parameter records and pass it to upstream. Existing callers should receive false through generated defaults where supported.
  • Update all Rust struct literals, internal helpers, generated bindings, and native call sites affected by the new option. The public-key conversion must either provide the field explicitly or use an upstream default.
  • Keep explicit coin/path mismatch rejection as the normal behavior. Enable overrides only when the caller explicitly requests them.
  • Document short-path and BIP-45 compatibility: omitted coin selects Bitcoin, BIP-45's second component is a cosigner index, and callers must specify another network explicitly.
  • Keep Regtest explicit. Coin type 1 infers Testnet. Preserve the existing mapping of TrezorCoinType::Signet to the upstream Testnet firmware network and test it.

4. Message verification, errors, and serialization

  • Preserve Core's documented Bitcoin default for TrezorVerifyMessageParams.coin: convert an omitted coin into an explicit upstream Network::Bitcoin. Pass explicitly selected Testnet, Signet, and Regtest through the existing conversion.
  • Cover upstream UnknownCoin and InvalidParameter errors in Core's error conversion with useful diagnostics. Preserve existing cancellation, PIN, passphrase, and transport error behavior.
  • Retain the UniFFI-facing TrezorCoinType enum. The upstream serde representation now uses case-insensitive btc, test, and regtest shortcuts, while protobuf firmware names remain Bitcoin, Testnet, and Regtest. Do not rename firmware coin-name helpers to shortcuts.
  • Audit any actual use of serialized upstream Network values and document migration if found. Do not introduce a speculative data migration for the UniFFI enum.

5. Direct signing and PSBT signing

  • Preserve the upstream fix that resolves one network for external-output validation, change-key derivation, and signing. Core must not introduce another Bitcoin fallback into that flow.
  • Verify direct signing with an omitted coin and a Testnet input path succeeds for valid Testnet outputs and rejects mainnet outputs before signing.
  • Verify change-key requests and signing requests use the same inferred or explicit network, including Regtest.
  • Keep PSBT conversion's explicit network selection, including its current Bitcoin default when the wrapper network argument is omitted.
  • Preserve serialization, local transaction verification, signature data, and optional txid handling. Broadcasting stays a separate Core operation.
  • Preserve existing Core restrictions on unsupported multisig and external inputs. This upgrade does not add support for those input modes.

6. Documentation, bindings, and release

  • Update the Trezor module README, exported API documentation, examples, and stale upstream-version references in the passphrase callback scaffolding.
  • Check that the remote PassphraseResponse enum still matches upstream and retain the existing adapter tests.
  • Regenerate Swift, Kotlin, and Python bindings using repository scripts. Inspect generated API shape and compile consumers instead of hand-editing generated files.
  • Keep Android JNI libraries untracked and use the normal Android build/publish workflow. Run platform builds sequentially because the Android build script temporarily modifies source/build configuration.
  • Choose a Core release increment appropriate for the public API changes, synchronize Cargo.toml, Package.swift, and bindings/android/gradle.properties through build.sh -r, and publish the corresponding Core artifacts.

Regression and validation checklist

  • Conversion tests for all affected request records, false-by-default path overrides, explicit overrides, and every new response field.
  • Public-key response tests for all six prefixes: xpub, ypub, zpub, tpub, upub, and vpub, plus Taproot descriptor selection and absent optional fields.
  • Wallet setup tests proving a normalized BIP-49/BIP-84/BIP-86 key plus explicit account type produces the same descriptors and addresses as the corresponding existing import flow.
  • Mainnet/Testnet path inference, unknown coin paths, mismatch rejection, short paths, BIP-45 cosigners, and explicit Regtest coverage.
  • Message verification with omitted coin preserves Core's Bitcoin default, and explicitly selected networks reach upstream unchanged.
  • Direct signing and PSBT regressions for external outputs, change outputs, wrong-network rejection, and explicit Regtest/Signet handling. Inspect decoded device request coin names where mocks are used.
  • cargo fmt --check, cargo clippy, focused cargo test modules::trezor, affected onchain tests, and the repository's normal broader test suite pass. Record any unrelated environment or baseline failures explicitly.
  • Desktop and supported Android/iOS target builds pass, with the iOS Bluetooth-only dependency configuration verified.
  • Swift/Kotlin/Python smoke tests construct the updated records and consume the new public-key fields.
  • Hardware smoke tests cover address display/confirmation, public-key export, message signing/verification, direct signing or PSBT signing, and change outputs over the supported transports. Record device/firmware/transport and use test funds.

Completion and consumer follow-up

This tracker is complete when Core resolves the published 10.0.0 dependency, the wrapper migration and regression checks are complete, updated platform artifacts are released, and Android/iOS consumer follow-ups are linked with their dependency versions and account-type migration covered.

Native apps should update their Core dependency, use the new public-key display fields, preserve the selected account type when importing normalized keys, and update constructors for any changed parameter records. Confirm reattaching an existing hardware wallet retains its identity and addresses.

Upstream account-info and precompose changes do not require adding new Core APIs here: the current Trezor wrapper does not expose those upstream methods, and Core's onchain account-info path is separate. Suite-hosted account selection and non-Bitcoin coin support remain outside this upgrade.

Related independent work:

Coordinate overlapping Trezor files with those issues while keeping their additional behavior changes separately tracked.

Activity

  1. added
    enhancement
    on Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions