Repository navigation
Description
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.tomlstill require0.4.0. The lockfile also resolves0.4.0. src/modules/trezor/types.rsdirectly constructs upstreamGetPublicKeyParamswithout a struct default. Version 10 addscross_chain, so this conversion must be updated to compile.TrezorPublicKeyResponsecurrently forwards onlyxpuband existing node metadata. Version 10 normalizesxpubto legacyxpub/tpuband addsxpub_segwit,descriptor, anddisplayable_public_key.src/modules/onchain/implementation.rs::detect_account_typetreatsxpub/tpubas 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_setupalready supportsaccount_type_overridefor these prefixes.TrezorVerifyMessageParamscurrently documents an omitted coin as Bitcoin and forwardsNoneunchanged. 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 refreshCargo.lockusing the registry release. - Preserve USB plus Bluetooth on non-iOS targets and
default-features = falsewith Bluetooth on iOS. Keep transport behavior working through the existing mobile callback adapters. - Preserve PSBT support. Upstream now includes it unconditionally and retains
psbtas 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>, anddisplayable_public_key: StringinTrezorPublicKeyResponse, mapping every field from the upstream response. - Adopt and document the normalized
xpub/tpubcontract for the existingxpubfield. 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_segwitfor BIP-49/BIP-84. Treat Taproot separately because upstreamxpub_segwitcan contain a descriptor, not a Base58 key. - Use
displayable_public_keyfor user-facing display where appropriate. Never pass a descriptor string to an API that expects an extended key. - Verify existing stored
ypub/zpub/upub/vpubkeys 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_fingerprintintact, including the internalget_device_fingerprintflow.
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_chainoption 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
1infers Testnet. Preserve the existing mapping ofTrezorCoinType::Signetto 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 upstreamNetwork::Bitcoin. Pass explicitly selected Testnet, Signet, and Regtest through the existing conversion. - Cover upstream
UnknownCoinandInvalidParametererrors in Core's error conversion with useful diagnostics. Preserve existing cancellation, PIN, passphrase, and transport error behavior. - Retain the UniFFI-facing
TrezorCoinTypeenum. The upstream serde representation now uses case-insensitivebtc,test, andregtestshortcuts, while protobuf firmware names remainBitcoin,Testnet, andRegtest. Do not rename firmware coin-name helpers to shortcuts. - Audit any actual use of serialized upstream
Networkvalues 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
txidhandling. 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
PassphraseResponseenum 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, andbindings/android/gradle.propertiesthroughbuild.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, andvpub, 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, focusedcargo 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