Skip to content

Comments

feat(trezor): add Trezor hardware wallet integration via trezor-connect-rs#71

Open
coreyphillips wants to merge 3 commits intomasterfrom
feat/trezor-module-rewrite
Open

feat(trezor): add Trezor hardware wallet integration via trezor-connect-rs#71
coreyphillips wants to merge 3 commits intomasterfrom
feat/trezor-module-rewrite

Conversation

@coreyphillips
Copy link
Collaborator

This PR:

  • Rewrites the trezor module (src/modules/trezor/) with trezor-connect-rs, enabling device discovery, connection, and Bitcoin operations over USB and Bluetooth

Supported Operations

Operation Description
trezor_scan Discover USB + BLE devices
trezor_connect / trezor_disconnect Device connection lifecycle
trezor_get_address Derive Bitcoin address (P2PKH, P2SH-P2WPKH, P2WPKH, P2TR)
trezor_get_public_key Get xpub at BIP32 path
trezor_sign_message / trezor_verify_message Message signing and verification
trezor_sign_tx Full Bitcoin transaction signing with RBF support

Testing

  • PR's will be created for both iOS & Android versions of Bitkit containing a Trezor dev dashboard that will only be accessible in dev mode at the following location: Settings->Advanced->Trezor
  • iOS
    • Only supports bluetooth.
    • No USB is available.
    • Trezor Safe 7 is the only device that supports bluetooth at the time of this writing.
  • Android
    • Will support both bluetooth and USB.
    • Should support most if not all Trezor devices.

…ct-rs

Rewrite the Trezor hardware wallet module to use trezor-connect-rs. Includes the following functionality:
 - get address
 - get xpub
 - sign/verify messages
 - sign transaction
@coreyphillips coreyphillips self-assigned this Feb 18, 2026
@coreyphillips coreyphillips added the enhancement New feature or request label Feb 18, 2026
… P2PKH support

- Add trezor_sign_tx_from_psbt() for PSBT-based transaction signing
- Add trezor_get_device_fingerprint() for output descriptor construction
- Wire TrezorUiCallback into ConnectedDevice for PIN/passphrase prompts
- Remove on_button_request from TrezorUiCallback (handled internally)
- Remove dead trezor_init_ble() export
- Add TrezorPrevTx types and enable P2PKH (legacy) input signing
- Add orig_hash/orig_index fields for RBF replacement transactions
- Add structural validation for TrezorTxOutput (exclusive mode check)
- Fix transport type detection to use cached enum instead of string heuristic
- Fix panic at FFI boundary by converting JoinError to TrezorError::IoError
}

// Check if it's hardened (ends with ')
let num_str = if component.ends_with('\'') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hardened path may also use h innsteaad of '

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated as of this commit.


/// Script types for address derivation.
#[derive(Debug, Clone, Copy, PartialEq, Eq, uniffi::Enum)]
pub enum TrezorScriptType {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Might want to add P2SH and P2WSH for future compatibility.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is meant to mirror Trezor's InputScriptType variants where there are no dedicated P2SH or P2WSH types here: https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/messages.json#L3-L12

/// BIP32 path (e.g., "m/84'/0'/0'/0/0")
pub path: String,
/// Coin name (default: "Bitcoin")
pub coin: Option<String>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

We only ever want this to be Bitcoin (or BitcoinTestnet / Regtest if those are options), so I'd suggest to either remove or if testnet and/or regtest are different option make an enum for these.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated as of this commit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants