Skip to content

feat: connect hardware flow#1033

Open
ovitrif wants to merge 38 commits into
masterfrom
feat/hw-wallet-connect
Open

feat: connect hardware flow#1033
ovitrif wants to merge 38 commits into
masterfrom
feat/hw-wallet-connect

Conversation

@ovitrif

@ovitrif ovitrif commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

Closes #1027
Refs #998

This PR adds Bitkit's Connect Hardware flow for pairing a Trezor as a watch-only hardware wallet from the Home hardware suggestion, Hardware Wallets settings, or Android's USB "Open with Bitkit" chooser.

Description

  • Adds the guided in-sheet pairing flow: Intro → Searching → Found → Paired, covering device discovery, connect confirmation, balance display, editable Label Funds, and Finish.
  • Supports USB and BLE discovery from the same flow. USB discovery can run without BLE access; BLE scanning requests the required runtime permissions, prompts to enable Bluetooth when it is off, and shows a Settings recovery dialog if permissions were denied.
  • Handles Android USB attach intents for supported Trezor devices so choosing Bitkit from the OS chooser can open directly on the Found Device step, then refreshes USB discovery before connecting.
  • Shows the one-time THP pairing code step inline when a device asks for it, with the PIN characters collapsing into the submit spinner while pairing completes.
  • Persists the Bitkit-side Label Funds value per hardware wallet and applies it consistently across USB/BLE entries for the same wallet.
  • Keeps compact hardware wallet surfaces resilient by capping/editing long labels so the Home tile and connection indicator remain usable.
  • Keeps the flow sheet-native: cancel/back dismisses the sheet, the Searching step uses the Figma dashed-ring loading animation, and the Paired step follows existing sheet layout/button patterns.
  • Reconnects known devices silently when USB/BLE transport becomes available again and updates connection indicators when transport is lost.

Figma Designs:

Preview

Connect via Android OS chooser when USB is attached & using BLE via settings screen:

Normal Speed 2x Speed
hwconnect.mp4
hwconnect2x.mp4

Connect via suggestion card:

hwviacard.mp4

QA Notes

Figma does not include a dedicated pairing-code screen, so that step follows Bitkit's existing in-sheet patterns.

Manual Tests

  • 1. Home → Hardware suggestion card → Continue: in-sheet nav runs Intro → Searching, shows the dashed-ring loader, then advances to Found when a device is discovered.
  • 2. Settings → General → Payments → Hardware Wallets → Add Hardware Wallet: the same connect flow opens and pairs a Trezor.
  • 3. Android USB chooser → Open with Bitkit for a supported Trezor: Bitkit opens the hardware sheet on Found Device; Connect pairs the device without going through Intro first.
  • 4. BLE permission/Bluetooth unavailable → Continue: USB search still starts; BLE access is requested gracefully, Bluetooth enablement is prompted when needed, and denied permissions can be recovered via Settings.
  • 5. Found → Connect → Paired: shows the device balance and editable Label Funds field; Finish closes the sheet and the Home hardware tile / Settings list show the entered label.
  • 6. Physical first-ever pair → Pair Device: enter the 6-digit code; the code row collapses into the spinner, then the flow advances to Paired.
  • 7. regression: Back gesture or Cancel from Intro / Searching / Found / Paired: dismisses the sheet instead of stepping backward through completed connect screens.
  • 8. regression: Disconnect/reconnect USB or toggle Bluetooth for a known device: the hardware connection indicator turns grey when unavailable and green again after silent reconnect.

Automated Checks

  • Unit tests added/updated in HwConnectViewModelTest.kt: cover Intro→Searching discovery with and without Bluetooth, Found-route USB refresh before connect, Connect→Paired, inline pairing-code navigation, balance updates, label capping, and Finish persistence.
  • Unit tests added/updated in HwWalletRepoTest.kt: cover scan/connect delegation, Label Funds persistence/clearing across transport entries, and wallet-name resolution.
  • Unit tests added/updated in TrezorRepoTest.kt, TrezorTransportTest.kt, and AppViewModelSendFlowTest.kt: cover setup gating before scan/connect paths, quiet USB opens, BLE-scan opt-out, USB attach handling, and app-wide pairing-code routing.
  • Journeys added/updated: connect-flow.xml, suggestion-intro-sheet.xml, and usb-reconnect.xml cover the Settings Add flow, Home suggestion flow, and USB attach reconnect path.
  • Ran locally: just compile, just test, just lint, and git diff --check.
  • GitHub checks: lint/detekt passed for the latest head; CI/E2E jobs were skipped by workflow conditions.

@ovitrif ovitrif added this to the 2.4.0 milestone Jun 18, 2026
@ovitrif ovitrif self-assigned this Jun 18, 2026
@ovitrif ovitrif force-pushed the feat/hw-wallet-connect branch from 4f59345 to 16e800c Compare June 19, 2026 08:19
@piotr-iohk

This comment was marked as resolved.

@ovitrif

This comment was marked as resolved.

@ovitrif ovitrif force-pushed the feat/hw-wallet-connect branch 3 times, most recently from 0c6fb90 to cb5f127 Compare June 19, 2026 16:43
@ovitrif ovitrif force-pushed the feat/hw-wallet-connect branch from cb5f127 to ee99421 Compare June 19, 2026 18:48
@ovitrif ovitrif marked this pull request as ready for review June 19, 2026 19:54
@ovitrif ovitrif requested review from jvsena42 and piotr-iohk June 19, 2026 19:54
@greptile-apps

This comment has been minimized.

greptile-apps[bot]

This comment was marked as resolved.

chatgpt-codex-connector[bot]

This comment was marked as resolved.

@ovitrif

ovitrif commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator Author

Re-enable pairing input after a failed code

When the user enters a wrong pairing code, or the connect attempt fails after the code is submitted, this local submitted state stays true and the number pad remains disabled with the spinner showing.

Handled by returning the flow to Found when connect fails, including failures after the pair-code step, so the stale local submitted/spinner state is discarded and the user can retry Connect. The sheet reset/cancel path now also cancels any pending pairing-code request. Added coverage in HwConnectViewModelTest.

Resolved in d35810d

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Connect Hardware flow

2 participants