-
Notifications
You must be signed in to change notification settings - Fork 4
chore: align trezor dev tooling with ios #1170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -447,7 +447,7 @@ class TrezorViewModel @Inject constructor( | |
| val signedStep = state.sendStep as? SendStep.Signed ?: return@launch | ||
| val rawTx = signedStep.signedTx.serializedTx | ||
| _uiState.update { it.copy(send = it.send.copy(isBroadcasting = true)) } | ||
| trezorRepo.broadcastRawTx(serializedTx = rawTx) | ||
| trezorRepo.broadcastRawTx(serializedTx = rawTx, network = state.selectedNetwork) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When a user changes the network selector after composing and signing a transaction, Knowledge Base Used: UI Screens: Navigation, Screens, and Components |
||
| .onSuccess { txid -> | ||
| TrezorDebugLog.log("BROADCAST", "SUCCESS txid=$txid") | ||
| _uiState.update { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # Trezor Emulator | ||
|
|
||
| The deterministic Trezor User Env from [`synonymdev/bitkit-docker`](https://github.com/synonymdev/bitkit-docker) stands in for a physical Trezor during development. It exposes an emulated T2T1 through Trezor Bridge over HTTP, so the app talks to it with the same wallet protocol it uses over USB. Everything except the USB stack, BLE and the one-time pair code is covered; see `journeys/hardware-wallet/README.md` for the full breakdown of what the Bridge transport does and does not simulate. | ||
|
|
||
| ## Start the Emulator | ||
|
|
||
| Run the stack and the helper from a sibling `bitkit-docker` checkout: | ||
|
|
||
| ```sh | ||
| cd ../bitkit-docker | ||
| docker compose up -d | ||
| ./scripts/trezor-emulator start | ||
| ``` | ||
|
|
||
| The helper wipes and sets up a deterministic device: model `T2T1`, firmware `2-main`, seed `all all all all all all all all all all all all`, no PIN, label `Bitkit Test Trezor`. Bridge listens on `21325` and the User Env dashboard on `9002`. Linux hosts need the host-network service: `docker compose --profile trezor-linux up -d trezor-user-env-linux`. | ||
|
|
||
| Other subcommands: `status` (bridge/emulator state plus a Bridge enumerate), `adb` (reverse the Bridge port for a physical phone), `logs`, `stop`. Helper internals, environment overrides and troubleshooting live in `bitkit-docker/docs/trezor-emulator.md`. | ||
|
|
||
| ## Build Flags | ||
|
|
||
| | Flag | Default | Effect | | ||
| | - | - | - | | ||
| | `TREZOR_BRIDGE` | `false` | Enables the Bridge transport in `TrezorBridgeTransport`. Without it, Bridge devices are never enumerated. | | ||
| | `TREZOR_BRIDGE_URL` | `http://10.0.2.2:21325` | Bridge endpoint. Use `http://127.0.0.1:21325` on a physical phone after `trezor-emulator adb`. | | ||
| | `TREZOR_ELECTRUM_URL` | unset | Electrum server for Trezor and hardware wallet flows only. The rest of the app keeps the server configured under Settings → Advanced → Electrum Server. | | ||
|
|
||
| Each resolves in the same order: environment variable, then `-P` Gradle property, then `local.properties`. Android Studio builds read `local.properties`; CLI and `just` builds read `.env` or inline environment variables. See `.env.example` for the commented template. | ||
|
|
||
| `TREZOR_ELECTRUM_URL` applies only to debug and E2E builds, and only on regtest. It is resolved by `Env.trezorElectrumUrl` and applied in `Env.electrumUrlForNetwork` (the Dev Settings watcher), `TrezorRepo.currentElectrumUrl` (account info, compose, broadcast) and `HwWalletRepo` (the production watchers). | ||
|
|
||
| ## Install | ||
|
|
||
| Android emulator: | ||
|
|
||
| ```sh | ||
| TREZOR_BRIDGE=true TREZOR_BRIDGE_URL=http://10.0.2.2:21325 \ | ||
| TREZOR_ELECTRUM_URL=tcp://10.0.2.2:60001 ./gradlew installDevDebug | ||
| ``` | ||
|
|
||
| Physical phone, after reversing both the Bridge and Electrum ports: | ||
|
|
||
| ```sh | ||
| ../bitkit-docker/scripts/trezor-emulator adb | ||
| adb reverse tcp:60001 tcp:60001 | ||
| TREZOR_BRIDGE=true TREZOR_BRIDGE_URL=http://127.0.0.1:21325 \ | ||
| TREZOR_ELECTRUM_URL=tcp://127.0.0.1:60001 ./gradlew installDevDebug | ||
| ``` | ||
|
|
||
| ## Funding the Emulator Wallet | ||
|
|
||
| Copy an address from Dev Settings → Trezor → Get Address, then send and mine from `bitkit-docker`: | ||
|
|
||
| ```sh | ||
| cd ../bitkit-docker | ||
| ./bitcoin-cli send 0.1 <address> | ||
| ``` | ||
|
|
||
| The balance reaches the hardware wallet tile only when `TREZOR_ELECTRUM_URL` points at the local regtest node. Without it, watchers run against the staging regtest Electrum, which does not know about locally mined coins. `Started watcher '<id>' on '<url>'` in the app log confirms which server is in use. | ||
|
|
||
| ## Smoke Checklist | ||
|
|
||
| Open Settings → Advanced → Dev Settings → Trezor, then verify: | ||
|
|
||
| - Scan lists the Bridge emulator device | ||
| - Connect succeeds and device features are shown | ||
| - Get address and get public key succeed | ||
| - Sign and verify message succeed | ||
| - Send or compose reaches the expected funded or no-funds state | ||
| - Disconnect, reconnect and forget-device cleanup behave correctly |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a dev-regtest build selects Bitcoin or testnet in Trezor Dev Settings,
trezorElectrumUrlOrDefaultrejects the regtest override but returns the app-wide regtest Electrum setting unchanged. Account lookups, composition, and broadcast therefore use an endpoint for the wrong chain, producing unrelated state or failed operations.Knowledge Base Used: Repositories overview (non-core domains)