Skip to content

feat: pay and receive by nfc tap on the watch - #2192

Draft
jvsena42 wants to merge 7 commits into
feat/wear-settings-syncfrom
feat/wear-nfc
Draft

jvsena42 wants to merge 7 commits into
feat/wear-settings-syncfrom
feat/wear-nfc

Conversation

@jvsena42

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).

Stacked on #2188 (feat/wear-settings-sync). This PR adds NFC to the watch: receive by letting a phone tap the watch's receive QR screen, and pay by tapping a payment tag or a phone's Receive, also while Bitkit is in the background. BLE "nearby" is dropped from #2105's plan for simplicity.

Description

  • Adds receive by tap: while the receive QR is on screen, the watch is the same NFC Type 4 NDEF tag as the phone's Receive (AID D2760000850101, one URI record lightning:<invoice>), using copies of the phone's NdefTagService, Type4TagEmulator, NdefCodec and NfcTagEmitter. The tag is offered only while the QR screen is in front and visible (not ambient, resting or paid), the wallet is ready and the invoice is current by the wall clock; every exit takes it down, a payment revokes it at once, and a stale AID left by a killed process is removed at start.
  • Adds an NFC animation below the receive QR while the tag is offered (PR 1's NfcHint), a dimmed and slashed hint with "Open NFC settings" when NFC is off, and none in ambient, while resting or without NFC.
  • Adds pay by tap through the manifest's NDEF_DISCOVERED filter (the watch's payment schemes), so a tap with the screen on reaches Bitkit even when it isn't in front, and opens the existing flow: self-send guard, offline error, Review and hold, and QuickPay with the tap counted as attended. One tap fires once (NfcRepeatGuard, NfcTapFilter), a tap during a send is dropped, and a tag the watch can't pay shows "Not supported".
  • Makes MainActivity singleTask, as on the phone, with a process-wide LaunchGate and SendMonitor, so links, taps and the tile always reach the one running app. This also fixes fix: keep wear payment links in one bitkit task #2187.
  • Declares android.hardware.nfc.hce as not required (as on the phone), adds the NFC permission and the HCE service.
  • Adds docs (docs/wear.md › NFC), a journey, and manual tests in journeys/wear/README.md › NFC.

Out of Scope

  • wear: whether Wear OS watches poll for tags and dispatch NDEF_DISCOVERED at all is unknown; many ship NFC for card emulation only. If a watch doesn't, pay by tap would need reader mode on an app screen (foreground only). Manual test 1 answers it on a real watch.
  • wear: BLE nearby payments are dropped for simplicity.
  • wear/app: LUD-17 lnurlp:// links — fix: pay lud-17 lnurlp links on the phone and the watch #2190.

Design

N/A — no design available. #2105 is a prototype with no Figma; the hint reuses the Balance page's NFC hint.

Preview

Large round emulator (454 px, Wear OS 7), local ./spark stack, app commit 7ac718aad. The emulator has no NFC radio, so the hint on the receive QR does not show; the tap is delivered as an NDEF_DISCOVERED intent.

Tap from the background: Review Refused tag Offline tap
Review of 1 000 sats after a tap intent with Bitkit in the background Not supported with OK Can't pay offline with OK

Recording: a tap intent with Bitkit in the background opens Review; a repeat is dropped; holding pays.

nfc-pay-background.mp4

QA Notes

Setup

  • Watch emulator Wear_Large_Round_API37 with the local-stack build (journeys/wear/README.md › Local ./spark stack). The emulator has no NFC radio: adb can deliver an NDEF_DISCOVERED intent with the link as data, but not the tag or its NDEF message, so real taps are manual tests.
  • Physical tests: a Wear OS watch with NFC and HCE (Galaxy Watch or Pixel Watch), the phone dev build on an Android phone with NFC, the test wallet restored on both, Wi-Fi debugging as in journeys/wear/README.md › On a physical watch.

Journeys

  • J1: new nfc-pay-background.xml — a tap intent delivered while Bitkit is in the background opens Review; a repeat within 3 s is dropped; holding pays
  • J2: updated nfc-required.xml — NFC is required, HCE is declared not required

Manual Tests

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

  • 1. Tap a phone's Receive (NFC) with the watch showing the watch face or another app → Bitkit opens on Review for that amount (1a–1i: lock, repeat taps, one task, a tap during Sending, a link from another app, a refused tag)
  • 2. With QuickPay on and an amount under the limit, tap the phone's Receive → the watch pays without Review or hold
  • 3. With the watch offline, tap a payment tag → "Can't pay offline", nothing paid later
  • 4. On the watch open Receive; on the phone open Send by NFC and tap the watch → the phone reads the watch's invoice and pays it; the watch shows the paid check (4a–4c)
  • 5. With the watch's QR showing, check that leaving, ambient, resting, paying and NFC off each stop the tag (5a–5b)
  • 6. Make the watch read its own receive tag → "Can't pay own invoice"

Automated Checks

  • added NdefCodecTest.kt, NfcPaymentUriTest.kt, Type4TagEmulatorTest.kt, NfcTagEmitterTest.kt — copies of the phone's tests for the tag format, APDUs and NDEF parsing
  • added NfcTagOfferTest.kt, NfcTagEffectTest.kt, ReceiveTagTest.kt — the tag is offered only while it should be and stops on every exit
  • added NfcTapFilterTest.kt, LaunchGateTest.kt, SendMonitorTest.kt — one tap fires once, taps during a send are dropped, process-wide
  • added TagRefusedTest.kt — the "Not supported" screen
  • updated ReceiveViewModelTest.kt, ReceiveQrContentTest.kt — wall-clock expiry, revoke on payment, hint placement at 227 and 192 dp
  • updated LaunchRequestTest.kt, SendViewModelTest.kt, PaymentsRepoTest.kt — tag parsing, tap → Review, QuickPay on a tap, offline tap, own tag, a popped flow never QuickPays

Evidence

  • Gate on 7ac718aad (rebased on feat: import the phone's settings and quickpay on the watch #2188's OK-button change): just compile, just test (with :wear:testDevDebugUnitTest --rerun), just lint all passed.
  • J1 and J2 passed on Wear_Large_Round_API37 (Wear OS 7) at 7ac718aad against the local ./spark stack, and so did these journeys from feat: add wear payments and the self-send guard #2182 re-run under singleTask: send-deeplink-bolt11, send-own-invoice-guard, send-offline-error, receive-qr, receive-paid, tile-balance, restore-background-drops-words. A link, a tap intent and the tile each left one task with one MainActivity (dumpsys activity).
  • An NDEF_DISCOVERED intent for bitcoin:…?req-foo=1 showed "Not supported" (Preview).
  • J1's first run held to pay while the wallet was still reconnecting after the app had been in the background, and got "Wallet not ready"; the second run passed. That is a send-flow bug from feat: add wear payments and the self-send guard #2182 and is fixed in the next stacked PR.
  • Two review rounds (domain and UI each); the last found only Lows, which are fixed.

Gaps

  • Every real-NFC case (manual tests 1–6) needs a physical watch; none was available.
  • The hint's animation never shows on the emulator (no NFC adapter); it is covered by previews and ReceiveQrContentTest.kt.

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: 2
  • Journey runs: claude-sonnet-5-5 (reasoning: medium)

🤖 Generated with Claude Code

@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

Regtest APK

Built from a80c8e4 (run).

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

jvsena42 and others added 7 commits December 4, 2026 13:10
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>
…fixes

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…ow from quickpay

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>

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.

fix: keep wear payment links in one bitkit task

1 participant