Update trezor to 0.20.1#641
Conversation
Migrate trezorlib usage to the new session-based API: ethereum calls now take a Session instead of a TrezorClient, ClickUI moved to trezorlib.cli.ui, and the client is built with get_default_client + get_default_session. - Wire button/pin/code-entry callbacks and host passphrase entry - Handle DeviceLockedError in the exception translation decorator - Update tests for the session-based API
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: febed5c790
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| pin_callback=ui.get_pin, | ||
| code_entry_callback=get_code_entry_code, | ||
| ) | ||
| return get_default_session(client, passphrase_callback=get_passphrase) |
There was a problem hiding this comment.
Preserve host passphrase prompts for capable devices
For passphrase-enabled devices that advertise PassphraseEntry (for example the Trezor T/Safe family), trezorlib.get_default_session() chooses on-device passphrase entry before it ever calls the supplied passphrase_callback, so this line ignores get_passphrase in exactly the common devices where host entry used to be forced by ClickUI(passphrase_on_host=True). Users who rely on entering the passphrase in the CLI will be pushed to device entry instead; prompt on the host and pass that value to client.get_session() unless the device's passphrase_always_on_device setting requires otherwise.
Useful? React with 👍 / 👎.
What
Update
trezorfrom0.13.10to0.20.1(latest).Why
This is not a plain version bump —
trezorlib0.20.x moved to a session-based API, so the integration had to be migrated:get_address,sign_tx,sign_tx_eip1559,sign_typed_data_hash,sign_message) now take aSessioninstead of aTrezorClient.ClickUImoved fromtrezorlib.uitotrezorlib.cli.uiand no longer takespassphrase_on_host; it now just supplies the button/pin callbacks.get_default_client(app_name, button_callback=..., pin_callback=..., code_entry_callback=...), and the session comes fromget_default_session(client, passphrase_callback=...).Changes
get_trezor_client()→get_trezor_session(): builds the client and opens a session via the library helpers. Passphrase is entered on the host unless the device requires on-device entry (get_default_sessionhandles the on-device vs host choice, which avoids thePassphraseErrorthat a forced host passphrase raises on devices set to "always enter passphrase on device").code_entry_callback=get_code_entry_codeso unpaired THP devices get an interactive prompt instead of an uncaughtTrezorException.DeviceLockedErrorinraise_trezor_exception_as_hw_wallet_exception→HardwareWalletException("Trezor device is locked").get_trezor_session, drop the removedTrezorClient(..., ui=..., _init_device=False)construction).uv.lock(dropsecdsa/six, addsnoiseprotocol).