feat: connect hardware flow#1033
Conversation
4f59345 to
16e800c
Compare
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
0c6fb90 to
cb5f127
Compare
Handled by returning the flow to Resolved in d35810d |
3b2f3ff to
316bf77
Compare
|
Testing (Samsung S22, Android 16, Trezor Safe 7, fresh install)
Screen_Recording_20260622_111352_Bitkit.Regtest.mp4bitkit_logs_2026-06-22_09-14-36.zip Suggested fix: only USB rescan before connect for /dev/... ids (USB attach); enable BLE enumerate during connect for BLE device ids. |
Fixed by limiting the USB pre-connect rescan to Android USB attach route ids ( Resolved in 7ca386e Also investigating why I didn't encounter this bug during testings, given that I also connected first with USB then tested BLE in same session, while USB connection was known. |
|
Re-tested BLE + USB connect LGTM on latest revision. Two suggestions, non-blocking. Finish flow on Wallet screen Wrong pairing code UX rec2.movThis matches THP retry on the device; Bitkit doesn’t explain the Trezor step or wrong-code state. On code mismatch, If possible, it would be good to show error message + “Confirm on your Trezor and enter the new code” Attaching also logs from the session: |
I think this explains it: my initial pass tested USB through the Android chooser first, then BLE in the same session while the same Trezor was still USB-present/known. The broken Connect step was always doing a USB-only rescan for any Found route, so that setup could silently find/connect the device over USB and mask the BLE bug. The failing repro is the cleaner BLE-only Found → Connect path where no matching USB device is available. BLE discovery succeeds, then the old code disables BLE during the pre-connect enumerate, gets 0 devices, and never advances to pairing/paired. Latest revision should be verified with BLE-only Found → Connect, with the Trezor unplugged from USB before tapping Connect. |
Thanks, agreed on both. Update: the Finish routing is now handled in this PR. Successful Finish saves the label, dismisses the sheet, and routes to Home → Wallet tab so the paired Trezor tile is visible; Cancel / mid-flow dismiss keep current behavior. For the wrong-code/device-prompt UX, I’d still rather defer it to the same device-state/backoff follow-up instead of adding a partial spinner-copy fix here. The robust version should model pairing-code retry, PIN retry, and device-busy states together so Bitkit doesn’t reconnect, refresh features, or reopen transports while the Trezor is waiting for user action. Core already added lock/busy primitives in synonymdev/bitkit-core#104, and I opened synonymdev/bitkit-core#105 to preserve typed Trezor PIN failures like |
Handled the Finish path in this PR now. Successful Paired → Finish saves the label, dismisses the sheet, and routes to Home → Wallet tab via the existing home wallet page request. Cancel, back, and mid-flow dismiss still only dismiss the sheet. Resolved in 6352d03 |
This lgtm functionally, but the animation is a bit awkward. Especially when running the flow from Hardware Wallet Settings (see sec 12-13 of recording). The trezor device image seems to stall for a bit on the screen. Screen.Recording.2026-06-22.at.16.44.23.mov |
b668b21 to
6352d03
Compare
Adjusted the Finish handoff so the hardware sheet owns only the Finish event, while Resolved in 1e49f94 EDIT: nvm the above, it doesn't really work yet, continuing to iterate on this. |
|
Issue is still visible: Screen.Recording.2026-06-22.at.17.36.53.mov |
79fc456 to
10a6327
Compare
Found the actual cause: the visible Trezor image was coming from the Hardware Wallets settings screen behind the sheet, not from the sheet itself. I removed the keyboard/sheet animation experiments and fixed this at the screen boundary by clipping Recording done after the fix: updatedConnect.mp4Resolved in 10a6327 |
|
Re-tested. LGTM. Screen.Recording.2026-06-22.at.21.38.00.mov |
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
Figma Designs:
Preview
Connect via Android OS chooser when USB is attached & using BLE via settings screen:
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
regression:Back gesture or Cancel from Intro / Searching / Found / Paired: dismisses the sheet instead of stepping backward through completed connect screens.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
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.HwWalletRepoTest.kt: cover scan/connect delegation, Label Funds persistence/clearing across transport entries, and wallet-name resolution.TrezorRepoTest.kt,TrezorTransportTest.kt, andAppViewModelSendFlowTest.kt: cover setup gating before scan/connect paths, quiet USB opens, BLE-scan opt-out, USB attach handling, and app-wide pairing-code routing.connect-flow.xml,suggestion-intro-sheet.xml, andusb-reconnect.xmlcover the Settings Add flow, Home suggestion flow, and USB attach reconnect path.just test file HwConnectViewModelTest,just compile,just test,just lint, andgit diff --check.