Skip to content

feat: pair the watch with the phone and send it the wallet - #2195

Draft
jvsena42 wants to merge 17 commits into
feat/wear-pending-paymentsfrom
feat/wear-phone-pairing
Draft

jvsena42 wants to merge 17 commits into
feat/wear-pending-paymentsfrom
feat/wear-phone-pairing

Conversation

@jvsena42

@jvsena42 jvsena42 commented Nov 29, 2026 •

Copy link
Copy Markdown
Member

Part of #2105
Source: team, #2105

Warning

Do not publish the Wear app until #2152 ships. The watch runs the same Spark wallet as the phone, and Spark real-time sync is off (realTimeSyncServerUrl = null), so two live instances share no state. Mainnet is also gated off in this build (Env.IS_MAINNET_ENABLED = false), and the phone's Watch row is hidden on mainnet (Env.isWatchLinkEnabled).

Stacked on #2193 (feat/wear-pending-payments). This is part 1 of 3 of phone–watch pairing: the pairing ceremony, setting a watch up from the phone (the phone sends the wallet), and a live settings push. Part 2 shares invoice hashes, QuickPay counts and send records; part 3 adds watch management from the phone.

Description

  • Adds :wearlink, a plain JVM module shared by both apps with the pairing protocol, so both sides run the same code:
    • Key agreement: P-256 ECDH through the platform KeyAgreement, HKDF from BouncyCastle (bcprov-jdk18on 1.86) bound to the whole handshake transcript, and AES-GCM with counters against replay and reflection. No custom primitives.
    • Code check: a 6-digit code shown on both screens; nothing is sent until both users confirm it.
    • Proof of the same wallet: a watch that already holds the phone's wallet pairs by proving it, and no secret is sent.
  • Adds setting a watch up from the phone (the phone sends the recovery phrase) for a watch without a wallet. Each of these is checked before anything is sent:
    • Watch key: the watch makes an agreement-only key in its hardware Keystore and attests it. The phone verifies the chain against Google's pinned roots and the challenge, and checks every certificate against Google's attestation status list (revoked or suspended keys are refused). Release builds refuse the transfer when the key can't be verified or the list can't be read; debug builds off mainnet show "not verified" and go on.
    • User: both users confirm the code, then the phone asks for its PIN or biometric. A phone without a PIN refuses the transfer and asks to set one first.
    • Channel: the phrase is encrypted to the watch's Keystore key, goes only over MessageClient (never the Data Layer's stored items), and is stored through the watch's KeystoreSeedStore. Three unfinished tries lock transfers for 10 minutes.
  • Adds a live settings push from the phone (unit, currency, QuickPay settings) once paired. The watch's PhoneStateSink takes both the push and the VSS backup import: the newer one holds, and the watch stays read-only on VSS. This leaves room for a later VSS-based sync to feed the same store.
  • Adds unpair from either side, and erase from the phone: the watch writes its wipe marker before it acknowledges, so an erase is never reported for a wallet that remains. Wiping the phone's wallet only unpairs the watch.
  • Phone: one bottom sheet for the whole flow (Settings › General › Watch): watch found or install prompt, the code, PIN, transfer progress, done, and the paired watch with Unpair and Erase.
  • Watch: a "From phone" option on onboarding, the Pair screen (code and a "Match" button, swipe to cancel; screenshots blocked), and a Settings row with Unpair.
  • Replaces the watch's last check-icon buttons with text buttons: the "Remove wallet?" and "Unpair phone?" dialogs now use one edge button (swipe cancels), and on Receive the paid ✓ is status only, with a "New invoice" button.
  • Lets debug builds of the watch take screenshots and recordings of the word, passphrase and Pair screens, as the phone's debug builds do; release builds still block them. The screenshot-blocked.xml journey from feat: add wear os app foundation #2177 is retired, because it needs a release build, which is ARM-only and can't run on the emulator; it is now manual test 8 in journeys/wear/README.md › Manual tests on a physical watch.
  • Adds a debug-only socket transport (dev builds, behind a file in the app's files directory) so two emulators can pair without a Google account; release builds have no socket.
  • Adds docs (docs/wear.md › Pairing), journeys and manual tests for physical devices.

Out of Scope

  • wear/app: shared invoice hashes, QuickPay counts and send records between paired devices — pairing part 2.
  • wear/app: watch management from the phone (limits, payment handoff, install prompt), and turning watch QuickPay off until the phone enables it — pairing part 3.
  • wear/app: one paired watch per phone; pairing again replaces the earlier one.
  • wear: if the watch's clock is more than 5 minutes behind the phone's, an older backup can briefly undo a newer push (documented in docs/wear.md › Push against import).
  • wear/app: if the watch dies between writing its wipe marker and acknowledging, it finishes the wipe at the next start but the phone keeps showing "erase waiting" until Stop Waiting; it never shows an erase that didn't happen.
  • wear/app: Bluetooth "nearby" is not used; the Data Layer carries everything.

Design

N/A — no design available. #2105 is a prototype with no Figma; the phone sheet reuses the existing sheet host, SheetTopBar and illustrations.

Preview

Phone Bitkit_Phone_API36 (Android 16) and watch Wear_Large_Round_API37 (Wear OS 7) paired over the debug socket, app commit a371e56f0. At that commit the watch's Pair screen still blocked screenshots in debug builds, so the recording shows it black; the code was read from the layout dump and matched the phone's in every run. The Pair screen below was captured later on a debug build with the screenshot change (96aecac1f plus #2195's follow-up feat/wear-shared-guards at d961f2853, same Pair screen).

Watch: the code and "Match" Phone: the same code
Pair screen with the phone's name, code 512098 and a Match edge button Phone sheet with code 512098
Phone: watch found Phone: the code Phone: PIN Phone: no PIN
Watch sheet with Pair Watch Code 301271 and the warning that the watch will hold the full wallet PIN pad before the wallet is sent Set a PIN in Bitkit first
Phone: wallet sent Watch: settings pushed (EUR) Watch: Unpair dialog Watch: wallet removed by the phone
Watch paired with the full wallet Balance in euros after the push Unpair phone? with one Unpair button Wallet removed after an erase from the phone

Recordings:

  • Setting a watch up from the phone with a PIN, phone side:
pair-receive-wallet-pin.mp4
  • The same run, watch side (the Pair screen shows black):
pair-receive-wallet-pin.mp4
  • Erase from the phone, watch side:
pair-erase-from-phone.mp4

QA Notes

Setup

  • Emulators Bitkit_Phone_API36 and Wear_Large_Round_API37 running together, dev debug builds of this branch on each, paired over the debug socket: journeys/wear/README.md › Phone and watch over the debug socket (adb forward plus the wearlink-socket file on each app; both apps log Using the debug socket link transport). No Google account is needed.
  • Phone: a test wallet on hosted regtest, PIN 1111, biometrics off. Watch: no wallet, or the phone's wallet, as each journey says.
  • Physical tests: a Wear OS watch paired to an Android phone in the Wear OS app, dev builds on both, Wi-Fi debugging as in journeys/wear/README.md › On a physical watch; test 3a and 9 need release-signed builds.

Journeys

  • J1: new watch-no-watch-connected.xml — the phone sheet with no watch says so and starts nothing
  • J2: new pair-receive-wallet-no-pin.xml — a phone without a PIN refuses to send the wallet
  • J3: new pair-receive-wallet-pin.xml — the same code on both, Back on the PIN pad returns to the code, the wallet arrives only after the PIN
  • J4: new pair-receive-wallet.xml — a watch without a wallet is set up from the phone
  • J5: new pair-settings-push.xml — a currency change on the phone reaches the watch
  • J6: new pair-unpair-from-phone.xml — unpair from the phone; the watch keeps its wallet
  • J7: new pair-same-wallet.xml — a watch with the same wallet pairs by proof, with no PIN and nothing sent
  • J8: new pair-different-wallet.xml — a watch with another wallet is refused on both sides
  • J9: new pair-cancel-on-watch.xml — swiping the watch's Pair screen away cancels on both
  • J10: new pair-retry-after-cancel.xml — cancel and Pair again at once on the phone pairs without a 90 s wait
  • J11: new pair-unpair-from-watch.xml — the watch's "Unpair phone?" dialog, swipe cancels, Unpair ends it on both
  • J12: new pair-erase-from-phone.xml — erase from the phone removes the watch's wallet
  • J13: updated remove-wallet-cancel.xml, remove-wallet.xml — one "Remove" edge button, swipe cancels
  • J14: updated receive-paid.xml, receive-paid-ambient.xml — the paid ✓ is status only; "New invoice" makes a new one and hides in ambient

Retired: screenshot-blocked.xml (from #2177) — debug builds no longer block screenshots; replaced by a manual test on a release build.

Manual Tests

Details and sub-cases are in journeys/wear/README.md › Manual tests for pairing.

  • 1. Discovery over the real Data Layer: the phone's sheet finds the watch, or asks to install Bitkit on it, or to keep it nearby
  • 2. Pair two holders of one wallet by proof
  • 3. Set a watch up from the phone with the PIN; 3a: a release build verifies the watch's hardware attestation and sends; 3b–3f: refusals (no PIN, unverified, status list unreachable, lockout)
  • 4. A watch with a different wallet is refused
  • 5. Erase a watch that is away: it erases when it next connects
  • 6. Settings push: QuickPay off on the phone reaches the watch
  • 7. Unpair from each side, and remove the wallet on the watch
  • 8. Wipe the phone's wallet: the watch shows not paired and keeps its wallet
  • 9. A release build ignores the wearlink-socket file

Automated Checks

  • added PairingTest.kt — the ceremony on both sides: nothing sent before both confirm, attestation and status-list refusals, PIN required, replay of earlier messages, a full relay ends with differing codes, lockout, cancel at each step
  • added AttestationVerifierTest.kt, AttestationStatusListTest.kt — chain, roots, challenge, key purpose and origin, a forged record under a genuine key, revoked, suspended and unknown entries, size cap
  • added LinkCryptoTest.kt, LinkChannelTest.kt, LinkEndpointsTest.kt, PairingThrottleTest.kt — encryption, counters, replay and reflection, unpair, erase with redelivery after a crash, settings push
  • added LinkSourcesTest.kt, WatchLinkSourcesTest.kt — the phrase never goes through the Data Layer's stored items or the logs
  • added WatchLinkRepoTest.kt, WatchSheetViewModelTest.kt — the phone's flow: cancel in each step, retry, PIN asked only when the wallet is sent, refresh while no watch, reopen during a transfer
  • added PhoneLinkRepoTest.kt, PairViewModelTest.kt, SettingsPhoneStateSinkTest.kt — the watch's flow: storing the phrase, a kept retry, erase at start after a crash, push against VSS import
  • updated WipeWalletUseCaseTest.kt, WalletRepoTest.kt, SettingsSyncRepoTest.kt, PhoneSettingsParserTest.kt, SettingsViewModelTest.kt, ReceiveQrContentTest.kt, LaunchRequestTest.kt — wipe only unpairs, erase by the phone, the import through the sink, the unpair failure line, the "New invoice" button

Evidence

  • Gate on a371e56f0 (after the screenshot change: just compile and just test on c3be448c9, just lint on 96aecac1f, which only rewraps a comment): just compile, just test (with :wear:testDevDebugUnitTest --rerun), just lint all passed. just deps was run for the new dependencies and gradle/verification-metadata.xml is committed. :wear:minifyDevReleaseWithR8 passed with BouncyCastle and the wearable library.
  • J1–J13 passed on Bitkit_Phone_API36 (Android 16) and Wear_Large_Round_API37 (Wear OS 7) at a371e56f0 over the debug socket; the code matched on both devices in every run. J13 covered remove-wallet-cancel.xml only.
  • Three review rounds on security (Fable) and UI (Opus): the security review's last round and the UI review's third round found only Lows, which are fixed.

Gaps

  • J14 and remove-wallet.xml were not run (J14 needs the local ./spark stack build to receive a payment).
  • Every manual test (1–9) needs physical devices; none were available. The real Data Layer, discovery, hardware attestation (the verified path and the release refusal) and delivery to a closed app are untested.
  • New and shortened translations (phone pairing strings, "Match", "Remove", "Unpair", and the shortened restore__error_insecure in 8 locales) had no native review.
  • No changelog fragment: the phone's Watch row is hidden on mainnet until feat: run one wallet on two devices #2152.

Models used

  • Planning/scoping: claude-opus-5-5 (reasoning: medium)
  • Implementation: claude-fable-5-2 (reasoning: medium), claude-opus-5-5 (reasoning: medium)
  • Review: claude-fable-5-2 (reasoning: medium), claude-opus-5-5 (reasoning: medium)
  • Review rounds: 3
  • Journey runs: claude-sonnet-5-5 (reasoning: medium)

🤖 Generated with Claude Code

jvsena42 and others added 15 commits November 28, 2026 16:19
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 96aecac (run).

Download bitkit-dev-debug universal APK (expires in 30 days).

jvsena42 and others added 2 commits November 29, 2026 05:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant