Skip to content

feat: nfc and bluetooth nearby payments - #1883

Merged
jvsena42 merged 86 commits into
masterfrom
feat/nfc-payments
Nov 25, 2026
Merged

jvsena42 merged 86 commits into
masterfrom
feat/nfc-payments

Conversation

@jvsena42

@jvsena42 jvsena42 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #1740

Twin: synonymdev/bitkit-ios#1302

This PR adds NFC and Bluetooth nearby payments. Payment scanners read requests from NFC tags, payment terminals and nearby Bitkit wallets. The Receive screen offers its request to nearby phones. The protocol is in docs/nearby-payments.md and is shared with iOS.

Platform support

Android iOS
Pay by reading an NFC tag or terminal Yes, picked up automatically while a payment scanner is open Yes, but the user taps the scanner pill or NFC button to start a read
Be tapped over NFC on Receive Yes, the phone acts as a tag No, Apple only allows this for licensed payment providers
Bluetooth nearby, paying side Yes Yes
Bluetooth nearby, receiving side Yes Yes, the only way an iPhone can receive from a nearby phone
"SCAN OR TAP TO PAY" on Receive Yes Shown while Bluetooth is advertising
TapPay (NFC) intro sheet, "Nearby payments" setting, scanner states from Figma Yes Yes

Description

  • NFC read: the Send recipient camera, the main scanner sheet, the Send QR scanner and the USDT send scanner put the phone in NFC reader mode while they are open.
    • A tag's URI, Text or absolute-URI record goes through the same scan pipeline as a QR code, so QuickPay applies as the design asks.
    • Accepted: lightning:, BIP21 bitcoin: (with lightning=), LNURL, and USDT ethereum:.
  • NFC tap to pay (receive): while Receive is in the foreground and the app is unlocked, NdefTagService (host card emulation) serves the current request as a read-only NFC Forum Type 4 tag (category other, device unlock required). It also covers the USDT receive screen.
    • The NDEF tag AID D2760000850101 is registered for the service only while Receive is shown, and the service is the preferred one meanwhile.
    • With nothing published, the service answers the application SELECT with "not found", so readers elsewhere see no tag.
  • Bluetooth (both directions):
    • Receive runs a GATT server and advertises the nearby service UUID only, with no device name.
    • Payment scanners scan for that UUID, connect to the strongest phone at or above -60 dBm, and read the request in 512-byte chunks.
    • Requests that arrive over Bluetooth always open the normal review. QuickPay is suppressed, because Bluetooth range lets a phone that isn't the merchant's answer.
    • Only payment requests are accepted over Bluetooth: bitcoin: with an address (every lightning= part must be a BOLT11 invoice), a lightning: BOLT11 invoice, and USDT ethereum:. Invoices are checked locally (network prefix, amount and bech32 shape) before decoding. LNURL and Lightning addresses are refused before decoding, because decoding contacts their server before the user picked the request. BOLT12 offers are refused because core rc15 does not decode them. Anything else the scanner understands (Pubky auth, LNURL auth/withdraw/channel, wallet connection setups, contact keys) is ignored, and that device is skipped.
    • Both sides stop while the app is locked, and restart when Bluetooth or location is switched on or off.
    • Android 9–11: scanning reports location services off, with a button to the Location settings, since scans return nothing without it. Advertising needs no location permission.
  • Scanner states (Figma):
    • The pill reads "Scanning QR, NFC & Bluetooth", "Scanning QR & NFC", "Scanning QR & Bluetooth" or "Scanning QR", depending on active sources.
    • Bluetooth and NFC buttons appear when a source needs a permission or is off. They request the Nearby devices permission, turn on Bluetooth, or open NFC settings.
    • When the camera is denied, every payment scanner shows "Scan to pay" with camera, Bluetooth and NFC buttons.
  • Receive: "Scan or tap to pay" appears under Edit/Copy/Share while NFC emulation or Bluetooth advertising is active.
  • TapPay (NFC) intro: a one-time timed sheet on devices with NFC.
    • It has the NFC illustration from Figma, a QuickPay toggle, and Settings / Awesome! buttons.
    • Dismissing it also marks the QuickPay intro as seen, since it carries the same toggle.
  • Setting: "Nearby payments" (default on) under Settings > General > Payments turns Bluetooth advertising on Receive on or off.
  • Manifest: NFC, BLUETOOTH_ADVERTISE, optional nfc and nfc.hce features, and the HCE service.
  • Translations: all new strings in the 15 locales.

Device test fixes

Testing on two phones found two problems, both fixed:

  • Repeat reads: after a read, the tag usually stays in range. Android then delivered it again each time it re-activated, which reopened the app chooser or the request. NfcRepeatGuard now holds reader mode, with a callback that ignores tags, until NfcAdapter.ignore reports that the tag has left the field. It then hands reader mode back to a scan screen that is still open. It engages after a scanner read, and when a tag tap launches or resumes the app (a22544e97).
  • Delay after a launch: a Lightning payment waited for the node's channels even when Spark paid it, so a tap that launched the app waited about 8 s for the node to start. The wait is now skipped when Spark covers the amount (2336ef1ca).

Review round (from bitkit-ios#1302)

  • A bitcoin:?… URI with a required (req-) parameter is no longer rewritten to lightning:<invoice>, since the rewrite dropped that parameter. The scanner then refuses it. Test: NfcPaymentUriTest "request with a required parameter is kept"; it fails without the fix (4d5af8435).

  • Wrapped login requests over Bluetooth: a request read over Bluetooth is now rewritten before the payment-only filter. bitcoin:?lightning=<LNURL-auth> therefore can no longer reach the login sheet (82f44a4d8). Tests are in NearbyRequestFilterTest; the wrapped-request test fails without the fix.

  • Stale request on Receive: Receive offers a request over NFC and Bluetooth only while its QR shows one. While the invoice updates, or after an update fails, nothing is offered, so the previous invoice can't be paid (d88da7fad). Test: ReceiveInvoiceUtilsTest "nearby offers only the request the QR shows"; it fails without the fix.

  • No Bluetooth advertising: a phone that can't advertise over Bluetooth counts as having no Bluetooth for Receive, so it no longer claims "Scan or tap to pay" when NFC is off (b373d5ba0). An advertising start that fails at run time now drops the label too, until the request or the Bluetooth state changes (baeab2d1f). A late failure from an advertiser that already stopped is ignored (965ff980c). Not driven on a device.

  • Button labels: the camera, Bluetooth and NFC source buttons have localized TalkBack labels (49538ae06).

  • Blocked permission: after the nearby-devices permission is denied for good, the Bluetooth button opens the app's settings (c37460c77).

  • Device check on the Pixel 11: the Bluetooth button reads "Enable Bluetooth". The first tap showed the permission dialog, which I denied; the second showed it again, which I denied for good. The third tap opened App info.

    nearby-permission-settings-trimmed.mp4
  • Empty required parameters: a req- key with an empty or no value (&req-foo=, &req-foo) also keeps the URI unrewritten (c06c3b7e1). The NfcPaymentUriTest cases fail without the fix.

  • Send E2E regression: the channel wait is skipped only while the node is not running yet and Spark covers the amount (943e052ec). Skipping it with a running node also skipped publishing current channels. After a payment, the send limit then stayed too high, and the send E2E's amount-exceeded check failed. The launch case still skips the wait. Test: "lightning scan waits for a running node even when spark covers the amount"; it fails without the fix.

  • No 15 s wait when Spark pays: when Spark covers a Lightning payment, a running node now only publishes its current channels and doesn't wait for a usable one (71680fc61). Before, it could wait up to 15 s when channels existed but none were usable.

  • Enter Manually: a nearby request still decoding on the recipient screen is cancelled when the user taps Enter Manually, so it can't route over the address being typed (f67cde893, ported from an iOS finding). The test fails without the fix.

  • NFC launch: a tag that launches Bitkit gets the same bitcoin:?lightning= rewrite as a scanner read, so the shipped core no longer rejects Numo's form (34f255940).

  • Closed Receive: the tag emulator stops serving a selected request once Receive stops offering it, instead of serving it until the reader disconnects (4f16c11ce).

  • Duplicate Bluetooth read: a second delivery of the same request no longer drops the handle of the read still decoding, so Enter Manually still cancels it (a88e203cd).

  • Contacts: opening Contacts from the Send recipient screen drops a nearby read that is still decoding, as Enter Manually does (869b45f3a).

  • NFC after leaving the scanner: a tag read that finishes after the scanner screen closed is dropped instead of opening a payment (5ca051cfb).

  • Master merge (d9c4ede2c): master now asks for the payment PIN before QuickPay settings are raised (QuickPaySettingsViewModel). The TapPay (NFC) intro sheet's QuickPay toggle now goes through that view model and shows the same PIN check, instead of writing the setting directly. Not driven on a device.

  • NFC read after pause: each NFC reader activation now has a number, and pausing the reader ends that activation. A tag read that started before the scanner paused is dropped, even if it finishes after a later resume. Before this fix, it could still open a payment over Contacts during the 300 ms exit transition (24180fd39). Each activation also registers its own callback, so a callback Android calls after reader mode was disabled carries a closed activation and is dropped (79e9f719f). Tests: NfcReadDispatcherTest "drops a read from a reader that paused or closed" and "drops a read from an earlier activation after the reader resumed"; they fail without the fix. Not driven on a device.

  • Rejected Bluetooth request: a phone whose request was rejected without leaving the scanner (an expired invoice, or a non-USDT request on the USDT scanner) is read again after 10 s, as on iOS. Before, it was ignored until the scanner closed (a3496bf06). Not driven on a device.

  • Translated button labels: other__bluetooth_enable and other__nfc_enable are in all 15 locales (483562df5).

  • NFC read on Enter Manually: an NFC read on the Send recipient screen that is still decoding is dropped when the user taps Enter Manually, as a Bluetooth read already was (3a21060c6).

  • Merged master again (9e09c6bea): the conflicts were translated strings, and both sides were kept.

  • Merged master again (4f8552895). The only conflict was SettingsScreen.kt, where master removed the contact and public payments rows; this branch now adds only the nearby payments row there.

Review round (QA review of 965ff98)

  • Send closed while an NFC read prepares: closing Send cancels a nearby read still preparing, so it can't reopen Send or reach QuickPay afterwards (0ccac8562).
  • Bluetooth over a chosen request: a Bluetooth read no longer replaces a QR, paste or NFC request the user chose while it is still preparing (4098e7803).
  • Nearby payments at cold start: the setting reads as off until the saved value loads, so an opted-out wallet never advertises (adbcb2bc8).
  • USDT deposits: only the native Arbitrum request is offered nearby; Tron, Solana and other EVM deposit addresses are not (ba4d982e4).
  • BOLT12 offers: refused over Bluetooth and no longer rewritten from lno= (fe7e30a96).
  • LNURL inside a unified URI: bitcoin:<address>?lightning=LNURL1… is refused over Bluetooth before decoding, which would fetch it (32e1fb55b).
  • Malformed BIP 321: an addressless URI that repeats any parameter, or whose amount the invoice does not carry, is no longer unwrapped, so the scanner rejects it (933f9ae3b, 7263458b0, 2431c1b68).
  • Settings scanners: the RGS, Electrum, external node, probing and contact scanners no longer read nearby payments (84a88d0b9).
  • GATT registration: advertising starts only after the service registers; a failure drops the tap label (5d8e5e88a).
  • NFC tag registration: a failed registerAidsForService clears the published request and drops NFC from the tap label (35fef0d1e).
  • Repeat guard: reader mode is taken over only for the open NFC reader activation (7d2391f6d).
  • Connection issues screen: NFC and Bluetooth reading and advertising pause while it covers Send or Receive (88ff9a895).
  • Each fix has a unit test that fails without it (.ai/validate-r19.sh). None was driven on a device.

Review round (QA review of 2431c1b)

  • Send's own scanner: a read from the scanner inside Send that is still preparing is cancelled when Send closes (abc4ca5ff).
  • Wallet locks during a scan: a scan still preparing when the wallet locks can't use QuickPay after unlocking; it opens the normal review (cb0d92dfb).
  • Two receivers: the first Bluetooth read keeps its review while it prepares; a QR, paste or NFC request still replaces it (3efaa561b).
  • Bluetooth invoices: every lightning= value must be BOLT11-shaped (30fb75ce2), and the check is a local shape check, so lnsb@example.com is refused before decoding (f14fb29e8).
  • BIP 321 parameters: only a repeated amount, label, message or pop is rejected; unknown optional keys may repeat again (f949c6fef). A repeated lightning is valid BIP 321 but is not unwrapped. amount must match the BIP grammar as a whole (fdd56de0c). Core gets the same amount checks in fix: check bip 321 amounts against the bip bitkit-core#225.
  • Preferred NFC service refused: the AID is released and NFC is dropped from the tap label (973f81db1).
  • Offline scanner pill: paused sources no longer show in the pill (be7306340).
  • Declined: tying the Receive tap label to the advertising start callback. The reason is in the thread.
  • Greptile follow-up: a scan that closes Send itself (LNURL auth, withdraw, Pubky auth, node, channel) is no longer cancelled by that close (a7298dff6), and the lock check runs again right before QuickPay starts (a9e2d7ebc).
  • Background lock (ovi): the real background lock and the PIN reset now advance the lock count the QuickPay check reads; before, only the setter did (b646b95d5). A test covers a contact scanned from Send's scanner (6832a63de).
  • Required parameters over NFC and Bluetooth: a bitcoin: request with any req- key is refused before decoding over Bluetooth, and gets "Unable To Read NFC" over NFC, including a tap that opens Bitkit (b9af9cd77). Ported from bitkit-ios#1302.
  • QuickPay start (ovi): QuickPay checks the lock again right before it pays, and falls back to the swipe review if the wallet locked since the scan (70e40e8d3). The req- refusal applies only to bitcoin: URIs, so an LNURL-pay HTTPS URL with its own req- query still decodes (233f7f3f1).
  • Inner bitkit:// (piotr): bitkit-core deletes every bitkit:// in a deep link, so …&bitkit://req-pop=x or …&rebitkit://q-pop=x turned into a req-pop key after the check. The req- check now deletes every bitkit:// first (3915f555e). It deletes bitkit:// only while the text starts with it, as the decoder does, so a payable bitcoin: URI with bitkit:// inside a key is not refused (535efc4ec, 2a4511728).
  • QuickPay at submission (ovi): the lock check also runs right before the payment is first submitted, so a lock while the invoice is prepared sends the payer to review and releases the reserve (13f995124, cfead7f57). The review it falls back to now has its amount validated, so Swipe to Pay works for a fixed invoice (3084ff39a; the same dead end exists on master after a cap rejection).
  • NEL before the scheme (independent review): the req- check trims like the decoder, which also removes U+0085 (70bd2a709).
  • QuickPay on the LDK queue (ovi): the lock is checked again on the node's queue right before the native send, after any wait behind a wallet sync; a stop releases the reservation and opens the review (592203d9d). The fallback review marks a fixed amount valid like the fixed LNURL-pay path, so it works before the spending limit is published (f0a9f3f19).
  • Mixed-case bitkit:// (ovi): deleted only in lowercase, like the decoder, so payable requests are not refused (cafc812e1).
  • Merged master (d8a0dae8d).
  • Bluetooth filter (piotr, ovi): a nearby bitcoin: URI must name a valid address for this wallet's network, validated like the decoder (92d42f93c, 7dcc9470c, dcabb9d04), and nearby BOLT11 invoices must pass the bech32 checksum (23ec7a17d).
  • Stopped node send record (piotr): kept, like any pre-submission failure; removing it could erase a real send's record (tried and reverted in fa0ebe8ca).
  • Empty amount (pwltr on iOS): an empty amount= on an addressless request keeps the URI instead of unwrapping it (c7e0f5dea).
  • Bluetooth recipient: choosing or confirming the receiver is tracked in Let the payer choose or confirm the recipient of a Bluetooth request #2005.
  • Each fix has a unit test that fails without it (.ai/validate-r20.sh, .ai/validate-r20b.sh, .ai/validate-r21.sh, .ai/validate-r23.sh, .ai/validate-r24.sh, .ai/validate-r25.sh, .ai/validate-r26.sh, .ai/validate-r27.sh). The full unit suite (6,248 tests), detekt and lint pass. None was driven on a device.

POS request formats

  • Square Register (2nd gen) serves lightning:<uppercase BOLT11> as one long-format NDEF URI record (header 0xC1, identifier code 0x00). Bitkit decodes it as is. Tests cover it with a real 447-character signet invoice, a 465-byte message laid out like Square's.
  • Numo, and Square in a later release, serve BIP 321 without an address: bitcoin:?lightning=<BOLT11>. bitkit-core v0.8.0-rc15 rejects that form, so requests read over NFC or Bluetooth are rewritten to lightning:<invoice> before decoding. feat: decode BIP 321 URIs without an address bitkit-core#218 fixes this on core master, but no release includes it yet. The rewrite goes with the core bump: Remove the BIP 321 rewrite after the bitkit-core bump #1935.

Out of Scope

Design

NFC compatibility (research, Nov 2026):

Terminal / wallet Direction Supported here
Square Register (2nd gen) Buyer taps the Register; payload unpublished, inferred to be a lightning: Type 4 tag Read path; unverified against a real Register
Numo, ZEUS tap-to-pay, static lightning:/bitcoin:/LNURL tags Phone reads the tag Yes
Another Bitkit (Android) on Receive Phone reads the emulated tag Yes
Bolt Card terminals (Blink, BTCPay, LNbits, Swiss Bitcoin Pay, WoS merchant) Terminal reads an lnurlw card No, see Out of Scope
Bitfinex Pay Web checkout, no NFC N/A

Preview

Screenshots are from an emulator, which has no NFC hardware. For these captures only, the NFC availability checks were forced on in a local build. That override is not in this branch. The Bluetooth states are real.

TapPay intro Scan to pay (camera denied) Bluetooth not allowed
TapPay intro Scan to pay Bluetooth button
Scanning QR, NFC & Bluetooth Receive: scan or tap to pay Nearby payments setting
Scanning Receive Setting

QA Notes

Setup

  • Regtest dev build (devDebug) from this branch on two NFC-capable Android phones, a third phone or a tag writer for static tags, and an iPhone running feat: nfc and bluetooth nearby payments bitkit-ios#1302 for the cross-platform cases.
  • Fund the paying wallet's spending balance through the Blocktank regtest API, so QuickPay cases can pay.
  • NFC on in system settings; Bluetooth on.

Testing with bitkit-core master

The branch ships with bitkit-core v0.8.0-rc15. To test against core master (51276ae, which includes synonymdev/bitkit-core#218), build core locally. Its API is unchanged since rc15, so the app builds without code changes.

  1. In a bitkit-core checkout at master: ./build_android.sh && cd bindings/android && ./gradlew publishToMavenLocal -Pversion=0.8.0-master-51276ae.
  2. In this branch, set the bitkit-core version in gradle/libs.versions.toml to 0.8.0-master-51276ae. Don't commit it.
  3. Build with ./gradlew assembleDevDebug -PuseMavenLocal=bitkit-core.

What changes with core master:

  • QR codes in the Numo form, bitcoin:?lightning=<BOLT11> in any case, open the Lightning send flow. On rc15 they show an invalid-address error.
  • NFC and Bluetooth requests in that form already work on rc15, through the app's rewrite.
  • bitcoin: URIs with any req- parameter, req-pop included, are rejected.

Journeys

  • J1: new nearby-payments-toggle.xml — Settings shows Nearby payments on by default, and the choice persists
  • J2: new scanner-nearby-states.xml — the Send scanner shows Scan to pay when the camera is denied, a Bluetooth button and "Scanning QR" without the Nearby devices permission, then "Scanning QR & Bluetooth"

NFC and Bluetooth between devices are not in the Capabilities table; see Manual Tests.

Manual Tests

  • 1. Phone A on Receive (Spending tab), phone B opens Send and holds near A → B opens the review for A's invoice — NFC between devices
    • 1a. Same with QuickPay on and an amount under the threshold → B pays without review — NFC between devices
    • 1b. Same with an amount above the threshold → B shows the review — NFC between devices
  • 2. Phone B taps a written lightning: tag, a bitcoin:?lightning= tag and an LNURL-pay tag from the main scanner → each opens the matching send flow — NFC tags
  • 3. Phone A on Receive with USDT enabled (USDT tab), phone B on the USDT send scanner taps A → B fills A's USDT address — NFC between devices
  • 4. Phone B taps a tag with no records, or an unreadable tag → toast "Unable To Read NFC". A tag with a readable non-payment value gets the scanner's decoding error — NFC tags
  • 5. Phone A on Receive, phone B opens Send within about 30 cm → B opens the review for A's request. QuickPay does not pay automatically, even under the threshold — Bluetooth between devices
  • 6. Phone A turns off Settings > Nearby payments → B no longer picks A up over Bluetooth, and A's Receive hides "Scan or tap to pay" when NFC is also off — Bluetooth between devices
  • 7. Android Receive → iPhone pays over Bluetooth, and iPhone Receive → Android pays over Bluetooth — Bluetooth across platforms
  • 8. iPhone (bitkit-ios#1302) taps Android Receive over NFC → iPhone opens the review — NFC across platforms
  • 9. Fresh install on an NFC phone → TapPay intro appears once on Home. The QuickPay toggle changes the QuickPay setting, Settings opens QuickPay settings, and the QuickPay intro does not show afterwards — timed sheet on device with NFC
  • 10. Send scanner with Nearby devices denied and NFC off → Bluetooth and NFC buttons show, and each enables its source and updates the pill — device permissions
  • 11. Square Register (2nd gen) in bitcoin tender → tapping phone B opens the review for the Register's invoice — Square hardware
  • 12. A device serving a non-payment request over the nearby service (e.g. a pubkyauth:// URI from a test build) → B's scanner ignores it and opens nothing — Bluetooth between devices
  • 13. Phone A leaves the app with Receive open, then returns to the PIN screen → while locked, B reads nothing from A over NFC or Bluetooth; after unlocking, B reads A's request — NFC and Bluetooth between devices
  • 15. Phone A on Receive, phone B on its home screen with Bitkit in the background → the tap opens Bitkit once and QuickPay pays; holding the phones together does not open the app chooser or the request again — NFC between devices
  • 14. Android 9–11 phone with location services off → the Send scanner shows the Bluetooth button, which opens Location settings; after turning location on, the pill includes Bluetooth — Android 9–11 device

Automated Checks

  • added NdefCodecTest.kt — URI/Text/absolute-URI records, prefix codes, long records, malformed input, and single-request selection
  • added Type4TagEmulatorTest.kt — the Type 4 APDU read sequence, chunked reads, no tag while nothing is published, read-only, and errors
  • added NfcPaymentUriTest.kt — schemes added to bare invoices and addresses
  • added NearbyProtocolTest.kt — UUIDs, meta encoding, chunking and reassembly, offset reads, and limits
  • added NfcTimedSheetTest.kt — shows once and only with NFC, and marks both intros seen
  • added NearbyRequestFilterTest.kt — Bluetooth accepts bitcoin, BOLT11 lightning and ethereum requests, and refuses offers, auth, LNURL (also inside a unified URI), setup and contact payloads
  • added NfcTagEmitterTest.kt — an older publisher cannot clear a newer request
  • updated AppViewModelSendFlowTest.kt — new timed sheet dependency, and a Lightning scan skips the channel wait when Spark covers the amount but waits otherwise
  • updated AppViewModelSendFlowTest.kt — Enter Manually and Contacts drop an NFC or Bluetooth read still decoding, including after a duplicate Bluetooth delivery
  • added NfcReadDispatcherTest.kt — duplicate reads within 3 s are dropped, and a read from a paused, closed or earlier reader activation is ignored

Evidence

On bca0fa0ba (PR head), physical phones, 2026-11-25. Regtest devDebug built from the branch as is (bitkit-core v0.8.0-rc15), installed over the existing Spark-funded wallets on a Pixel 11 (Android 17) and a Xiaomi 22031116BG (Android 13, UI in Portuguese). The Xiaomi pays or reads, the Pixel receives. The Xiaomi is on the left in each video, the Pixel on the right. Tags were written with NFC Tools on the Xiaomi. For the NFC cases the Xiaomi's Bluetooth was off, so only NFC could deliver the request (with it on, the Bluetooth read wins; see case 5). Times are from Bitkit's log on the Xiaomi.

  • Case 1, QuickPay off: the tap read the Pixel's ₿ 1,000 invoice at 09:53:11.9 and opened the review. Not paid.

    case1-nfc-review.mp4
  • Case 1a, QuickPay on, under the $5 threshold: read at 09:49:12.6, Using QuickPay for '1000' sats at 13.5, Spark payment COMPLETED at 17.8. No review.

    case1a-nfc-quickpay.mp4
  • Case 1b, over the threshold: a ₿ 10,000 ($5.89) invoice opened the review. The log has no QuickPay line. Not paid.

    case1b-nfc-over-threshold.mp4
  • Case 2, tags from the main scanner (Starting scan from 'scanner sheet'):

    • lightning:<invoice> (415 bytes) opened the review for the ₿ 1,000 invoice.

      case2-tag-lightning.mp4
    • bitcoin:?lightning=<invoice> decoded as Lightning(...) with the same invoice and opened the review.

      case2-tag-bitcoin-lightning.mp4
    • lightning:LNURL1…, served by a local LNURL-pay test server on the LAN: Bitkit fetched it and opened the LNURL-pay amount screen with the server's limits. The server can't issue invoices, so no payment was attempted.

      case2-tag-lnurl-pay.mp4
  • Case 3, USDT: with USDT turned on for both wallets, the Xiaomi's USDT send scanner tapped the Pixel's USDT Receive. It moved to the amount step, and the recipient field holds the Pixel's address 0x9D63AC78F2735B1966aBFBd8208be6C3647b4F9a (Arbitrum One). Neither wallet holds USDT, so the send was not completed.

    case3-usdt-nfc.mp4
  • Case 4, tags without a payment request:

    • Erased tag: toast "Incapaz de Ler o NFC / Esta tag não contém uma solicitação de pagamento que a Bitkit possa usar." (the Portuguese "Unable To Read NFC"). The scanner stays open. Bitkit logs nothing for this path.

      case4-tag-empty.mp4
    • https://example.com: Failed to decode scan data: 'https://example.com' and the scanner's decoding toast "Incapaz de Ler o QR / A Bitkit não consegue ler este código QR." The toast says "QR" even though the value came from an NFC tag.

      case4-tag-non-payment.mp4
  • Case 5, Bluetooth: the Xiaomi's Send screen read the Pixel's ₿ 1,000 request about 2 s after opening (Read nearby request at 09:46:46.4), without a tap. Skipping QuickPay for '1000' sats: suppressed for this scan (... read from a nearby device), so the review opened. Swipe to pay completed and the Pixel showed Received Instant Bitcoin.

    case5-bluetooth.mp4
  • Bitkit in the background (case 15 and a tag): the Xiaomi was on its home screen with Bitkit in the background and QuickPay on. Both taps showed Android's app chooser once (Bitkit Regtest and Blink). After Bitkit was picked, it got one Starting scan from 'deeplink' and QuickPay paid.

    • Tap on the Pixel's Receive: request at 10:11:54.5, QuickPay at 10:12:04.0, COMPLETED at 10:12:10.9.

      bg1-nfc-tap-background.mp4
    • Tap on a lightning: tag (the Pixel only supplied the invoice, so its side is a still): request at 10:15:39.2, QuickPay at 10:15:49.1, COMPLETED at 10:15:56.9.

      bg2-tag-background.mp4
    • QuickPay started about 10 s after Bitkit got the request, not the 1.9 s recorded below on 2336ef1ca. The LDK node had stopped in the background. AppViewModel.kt:6776 (if (!open && isQuickPayOn && channelsAreSettling()) waitForUsableChannels(walletGeneration)) calls the channel wait without an amount. channelsAreSettling() is true while the node is not running, so QuickPay waits for the node to start (Waiting for node to load channels before sending payment), even when Spark covers the amount. The comment there says this is on purpose, to know whether the payment needs the Spark update. Follow-up: QuickPay waits ~10 s for the LDK node when opened from the background, even when Spark covers the amount #2028.

Earlier builds:

On two physical phones, a Pixel 11 (Android 17) and a Xiaomi 22031116BG (Android 13), running regtest devDebug built against bitkit-core master (51276ae). Both wallets were funded on Spark through Lightspark's regtest faucet. The Xiaomi is on the left in each video, the Pixel on the right.

  • Case 1a, NFC with QuickPay: the Pixel offers a ₿ 1,000 request and the Xiaomi's scanner reads it. QuickPay pays in about 9 s from the tap.

    nfc-quickpay-side-by-side.mp4
  • Case 5, Bluetooth: the Xiaomi finds the Pixel's ₿ 1,000 request about 8 s after the nearby-devices permission is granted. It opens the review, because QuickPay is suppressed for requests read over Bluetooth. Swipe to pay completes in 4.4 s.

    bluetooth-side-by-side.mp4
  • Case 15 and the repeat guard, on 2336ef1ca: the video shows three taps:

    1. A background tap that fails because the phones are out of range. Neither phone logged an NFC field.
    2. A tap with the payment sheet open. The guard drops 4 repeat detections; there is no chooser, and QuickPay pays.
    3. A background tap. Android's chooser appears once, Bitkit gets the request once, and QuickPay starts 1.9 s after Bitkit opens it, down from 10 s.
    nfc-repeat-guard-side-by-side.mp4
  • Case 1, with review: run with the Pixel paying, with its camera denied (see the Pixel 11 note). The tap opened the review for ₿ 25, and the payment completed.

On bca0fa0ba (after the latest master merge):

  • The full unit suite passes (6,594 tests), detekt passes, and androidTest compiles. Android Lint was last run on 28639c4e7.
  • Cases 1, 1a, 1b, 2–5 and the background taps were run on this head on 2026-11-25 (see above).
  • Two-emulator Bluetooth check repeated after the review fixes: B read A's request (Read nearby request, then Handling decoded scan data).

On 40b2a250b:

  • Two Android 16 emulators (medium_phone and Pixel_9) running regtest devDebug:
    • Bluetooth: emulator A on Receive advertised the service UUID, connectable and with no name, per dumpsys bluetooth_manager.
    • Emulator B's Send recipient screen connected to it and read the unified request (about 450 bytes, two chunks). The log shows Read nearby request and then Handling decoded scan data: OnChain(... lightning=lnbcrt1...). That covers case 5's transport, but not a completed payment, because B had no funds.
  • The screenshots above match the linked frames.

Pixel 11: NFC reading stops while the camera is open

On a Pixel 11 (Android 17, build CD1A.261005.003), the system switches NFC polling off while the camera is in use. The scan screen shows the camera, so on this phone it cannot read an NFC payment request.

  • What the logs show: Bitkit enables reader mode (setReaderMode ... to.bitkit.dev, flags: 15, tech_mask = 0f). About 0.1 s after the QR camera opens, the system sets reader mode again (uid=1000, packageName: android, flags: 4096, tech_mask = 00), which disables polling. Polling comes back only when Bitkit leaves the scan screen. Reproduced three times.
  • Control: with camera permission denied, polling stays on (tech_mask = 0f) and a tap reads the request and opens the payment.
  • Not affected: a Xiaomi 22031116BG on Android 13 keeps polling with the camera open. On the Pixel, Bluetooth requests, NFC taps that open Bitkit from the background, and the Pixel as the receiving side all work.
  • Not documented: I found no Android documentation of this. Samsung developers report the same behaviour on the Galaxy S23 and S24.
  • Not decided: how the scan screen should handle it; tracked in Scanner: NFC reading on phones that stop polling while the camera is open #2000.

Gaps

  • Cases 1–5 and 15 were run on two physical Android phones. Cases 6 and 9–10 were not run.
  • Case 2: the LNURL-pay tag reached the amount screen, but no LNURL payment was completed (the test server issues no invoices). Case 3: no USDT was sent (no USDT balance).
  • iOS and cross-platform: not tested. bitkit-ios#1302 was not run on a physical iPhone, and no Android ↔ iPhone payment was tried over NFC or Bluetooth, so cases 7 and 8 are unverified.
  • Case 11: Square's NFC payload is unpublished, so the Register path is unverified.
  • J1 and J2 have not been driven yet.
  • Cases 12–14 were not run (no second device serving a crafted payload, no Android 9–11 device).
  • The dynamic AID registration was checked on the Xiaomi: the NDEF AID is registered to Bitkit, and Bitkit is the preferred service, only while Receive is shown.
  • An independent review ran on 3e377fbf9, and its findings were addressed in 28639c4e7. One finding was not taken: it flagged that showsTapToPay comes after modifier in ReceiveQrView, but AGENTS.md requires modifier to be the first optional parameter.
  • Nearby payments stays on by default, matching iOS and the shared spec.

Models used

  • Planning/scoping: claude-opus-5-5 (reasoning: Not exposed)
  • Implementation: claude-opus-5-5 (reasoning: Not exposed)
  • Review: claude-opus-5-5 (reasoning: Not exposed)
  • Review rounds: 1

Metadata note: the session exposes the model ID but not the reasoning setting.

🤖 Generated with Claude Code

Payment scanners read requests from NFC tags (reader mode) and from nearby
Bitkit wallets over Bluetooth LE. The Receive screen offers its request as an
emulated NFC Forum Type 4 tag and over a BLE GATT service while it is on
screen. Adds the TapPay (NFC) intro sheet, the scanner source states from
Figma and a Nearby payments setting. Protocol in docs/nearby-payments.md.

Refs #1740

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42 jvsena42 self-assigned this Nov 12, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Regtest APK

Built from 7ebf6ef (run).

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

- Accept only bitcoin:, lightning: invoice/offer and ethereum: requests over
  Bluetooth; skip the device otherwise.
- Stop offering and listening while the app is locked.
- Show the Scan to pay panel on every payment scanner when the camera is denied.
- Android 9-11: report location services off for scanning, and advertise
  without the location permission.
- Recreate the scanner/advertiser when Bluetooth or location is switched.
- Keep scanning after a delivered request, retry failed scans, and ignore
  callbacks from stale read sessions.
- Register the NDEF tag AID only while Receive is shown and present no tag
  when nothing is published; owner tokens for the emitter and reader mode.
- Translations, journeys, and repo conventions (nowMillis, Duration,
  Context.bluetoothManager, narrow lint suppressions, log wording).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Square Register serves lightning:<uppercase BOLT11> as a long-format NDEF
URI record; Numo serves BIP 321 without an address. Add a real 447-char
signet fixture and tests for record decoding, byte-exact encoding,
chunked tag reads and the Bluetooth allowlist.

bitkit-core rejects bitcoin:?lightning=<invoice> (synonymdev/bitkit-core#212),
so requests read over NFC or Bluetooth are rewritten to lightning:<invoice>.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
jvsena42 and others added 3 commits November 16, 2026 11:29
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review November 16, 2026 17:12
@jvsena42
jvsena42 requested review from a team, ben-kaufman and ovitrif and removed request for a team November 16, 2026 17:12
# Conflicts:
#	app/src/main/java/to/bitkit/ui/settings/SettingsScreen.kt
@jvsena42
jvsena42 marked this pull request as draft November 16, 2026 17:16
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no new blocking issue was established.

Summary

Adds NFC and Bluetooth payment reads, nearby requests on Receive, scanner controls, and a one-time NFC introduction.

  • Payment scanners read NFC tags and nearby phones, while Receive offers its current request through NFC and Bluetooth.
  • Settings lets people control nearby Bluetooth offers and introduces NFC payments once.
  • QuickPay checks the wallet again before sending and avoids waiting for channels it will not use.

No new actionable issue was established. This review did not run builds, tests, or device checks.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    Receive[Visible Receive request] --> NFC[NFC tag service]
    Receive --> BLE[Bluetooth advertiser]
    NFC --> NfcCheck[Rewrite and reject required parameters]
    BLE --> BleCheck[Rewrite and check payment-only request]
    NfcCheck --> Scan[Shared scan flow]
    BleCheck --> Review[Payment review]
    Scan --> Eligible{QuickPay allowed?}
    Eligible -->|No| Review
    Eligible -->|Yes| Lock[Check wallet lock before sending]
    Lock -->|Allowed| Pay[Submit payment]
    Lock -->|Stopped| Review
Loading

Reviews (26) · Last reviewed commit: "docs: list the requests bluetooth accept..." · Reviewed by Greptile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review November 16, 2026 17:34
@jvsena42
jvsena42 marked this pull request as draft November 16, 2026 17:42

@talosmachina talosmachina left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 finding (1 P1). Adds NFC reading on the payment scanners, HCE Type 4 tag emulation on Receive, and a BLE GATT request exchange between Bitkit phones. Reviewed 4d5af8435, oversized tier (65 files, about 3,000 lines): I read the security-relevant paths in full (the NFC and Bluetooth transport, the request filter and rewrite, the QuickPay suppression plumbing into AppViewModel, the manifest and HCE service) and did not review the UI, sheet, string and resource changes.

  • P1: the Bluetooth payment-only filter is applied before the bitcoin:?lightning= rewrite, so LNURL auth, withdraw and channel requests from any nearby advertiser reach their sheets.

Build: not built here. This review answers in public, where no packages token is available for the Gradle build, so CI is the gate. At the time of review build reported failure because its upstream jobs were cancelled (BUILD_RESULT: cancelled), and build-and-test, compose-ui / ui-tests and lint were still pending, so CI says nothing yet either way.

What I checked, and 6 candidates I ruled out

Read in full: NearbyScanner.kt, NearbyAdvertiser.kt, NearbyProtocol.kt, NearbyRequestFilter.kt, NfcPaymentUri.kt, NdefCodec.kt, Type4TagEmulator.kt, NfcTagEmitter.kt, NfcRepeatGuard.kt, NdefTagService.kt, NfcEffects.kt, NearbyEffects.kt, NearbyScanSources.kt, the AppViewModel diff and the launchScan/handleScan/handleDecodedScan path, MainActivity diff, manifest and ndef_tag_service.xml.

Ruled out

  • HCE serving while locked or off-screen: requireDeviceUnlock="true", the AID is registered only while Receive is resumed, offerPaymentNearby drops the URI while LocalIsAppLocked, and the emulator answers SELECT with 6A82 when nothing is published.
  • Stale publisher clearing a newer request: NfcTagEmitter.clear is token-checked with compare-and-set; NfcTagEmitterTest covers it.
  • NDEF parser out-of-bounds on a hostile tag: every read is inside runCatching in decodeTexts, and a negative long length is rejected.
  • BLE read overflow or wrong reassembly: length capped at 4,096 bytes by requestLength, decode rejects a size mismatch, each session has an 8 s timeout.
  • QuickPay on a Bluetooth read: isNearby reaches suppressQuickPay on all three scanner routes (SendRecipientScreen, QrScanningSheet, SendSheet QR route); the USDT scanner goes to its own recipient path, which has no QuickPay.
  • Channel-wait skip paying through the wrong rail: waitForUsableChannels now skips only when canSendWithSpark(amount) is true, and the following canSend check is unchanged.
  • Cold reader: the P1 stood (traced the same chain to onScanLnurlAuth).

Merge confidence: 3/5, the oversized tier caps it there, and the open P1 on the Bluetooth filter would hold it at 3 on its own.

Reviewer model: claude-opus-5-5, xiaomi/mimo-v2.6-pro (cold reader)
Reasoning effort: Not exposed (the run metadata carries no effort setting for either)

jvsena42 and others added 3 commits November 16, 2026 15:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42

Copy link
Copy Markdown
Member Author

@piotr-iohk Resolved in d8a0dae (merge of master).

  • QuickPayRepo: keeps both master's LNURL admission and send-time policy recheck, and this PR's lock check at first submission. A lock lapse falls back to review through fallBackBeforeDispatch; a policy rejection goes through reject.
  • AppViewModel: keeps master's canSendLightning with this PR's Spark-aware waitForUsableChannels(walletGeneration, amount).
  • strings.xml: master removed the receive onboarding strings, and only wallet__receive_scan_or_tap is kept.

After the merge, the full unit suite passes (6,566 tests), detekt is clean, and androidTest compiles.

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: ⛔️ Request changes. QuickPay authorization can expire while an LDK send is still queued.

The PR moved to d8a0dae after this run; these results are for 70bd2a7.

Findings:

  • HIGH QuickPayRepo.kt:405. The new guard runs before LDK queues the native send. Wallet sync shares that serial queue and can block it, so the wallet can lock before the queued send begins. Check authorization at the native submission boundary and unwind the unsent operation and its reservation if authorization expired. Keep tracking already submitted payments.
  • MEDIUM AppViewModel.kt:8357. The fallback validates the amount once from a cached spending limit. QuickPay can reach this screen before LDK publishes the limit, including when Spark already covers the payment. The one-time false stays in Confirm after sync and keeps Swipe to Pay disabled. This also overwrites the true flag that fixed LNURL-pay already set. Use the normal manual preparation path or update validation when the payment's spending limit changes.
  • LOW NfcPaymentUri.kt:92. The guard removes mixed-case occurrences of the Bitkit scheme when peeling a wrapper. The shipped decoder's replacement is case-sensitive. An optional query key can therefore be mistaken for a required key and a payable NFC request rejected. Mirror the decoder's case handling when normalizing Bitkit wrappers.

QA for 70bd2a7:

Check: Check QuickPay and nearby request regressions ✅ The pinned build passed the NFC, nearby-request, QuickPay repository, QuickPay view-model and Send unit suites.
Handle an addressless Lightning request from an NFC launch ✅ A valid NFC launch intent opened Bitcoin Amount. Adding an empty amount showed Decoding Error and left Home visible.

The launched Android activity received a synthetic NFC intent.

Review a fixed Lightning invoice after the wallet locks ⏭️ The PR advanced before the recorded lock and unlock case. The pinned unit tests covered authorization and the funded fallback.
Review an under-limit Lightning request received over Bluetooth ⏭️ The PR advanced during wallet setup. The payer channel was funded, and the earlier review records this Bluetooth flow.

Physical NFC tag reads, TapPay on NFC hardware, Square Register and Android–iPhone transport require devices with the corresponding hardware.

Earlier on-device evidence

Reviewed the six-commit delta and the earlier QuickPay and NFC findings. The LDK queue, cold-balance fallback and mixed-case NFC findings come from source review. 535efc4..70bd2a7

The iOS twin carries the same wrapper, empty-amount and QuickPay preparation fixes. The LDK queue finding is specific to Android. synonymdev/bitkit-ios#1302

Inline notes:

  • app/src/main/java/to/bitkit/repositories/QuickPayRepo.kt:405: HIGH — Keep QuickPay authorization current while the LDK send is queued

The new guard runs before LDK queues the native send. Wallet sync shares that serial queue and can block it, so the wallet can lock before the queued send begins. Check authorization at the native submission boundary and unwind the unsent operation and its reservation if authorization expired. Keep tracking already submitted payments.

  • app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:8357: MEDIUM — Revalidate the QuickPay fallback when spendable balance becomes available

The fallback validates the amount once from a cached spending limit. QuickPay can reach this screen before LDK publishes the limit, including when Spark already covers the payment. The one-time false stays in Confirm after sync and keeps Swipe to Pay disabled. This also overwrites the true flag that fixed LNURL-pay already set. Use the normal manual preparation path or update validation when the payment's spending limit changes.


Reviewed by gpt-6.2-sol-high

jvsena42 and others added 3 commits November 24, 2026 09:04
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA review

Scope: full PR at cafc812e1, re-reviewed after the comparison base changed from 5fa540e to 2c70a74 and target-branch changes touch reviewed files.

4 actionable findings — resolve or provide an evidence-backed rebuttal.

A tag tap while Bitkit is already open does not hold NFC, so a later discovery of that tag starts another scan. The Bluetooth filter also accepts bitcoin: with no address and a BOLT11-shaped value that fails a checksum, and both go through the scan path that resets send state and closes the sheet. A QuickPay lock abort on the node queue records an LDK send hash before the payment is refused, which blocks a later Spark payment of that invoice until the node can list payments.

Compared with bitkit-ios#1302 at 0a0d2eb8, scanner acceptance only. iOS checks a BOLT11 checksum; this filter checks bech32 shape. iOS also accepts a bitcoin: URI with an empty query. iOS NFC reads are user-started, so the foreground intent path was not compared as the same flow. This is not a review of the iOS PR.

Device testing: not performed in this review. Unit tests were read and not run. A focused issue search on synonymdev/bitkit-android returned no matching issue.

Suggested additional test cases

  • Android, wallet already unlocked on the home screen: tap a payment tag and keep the phones together through a brief field drop. Expected: one payment flow, and the sheet does not open again.
  • Android, Send scanner open: a nearby device advertises bitcoin: and lightning: plus a BOLT11-shaped string with a bad checksum. Expected: the scanner stays open and the current send is unchanged.
  • Android, QuickPay on, channels can pay, lock the wallet while the node send is still queued, background the app so the node is not runnable, then unlock and swipe the same invoice while Spark can pay. Expected: the swipe is not refused as an earlier node send.

Earlier findings reconciled at this revision: 1 still present, 4 verified fixed, 2 tracked separately outside this PR.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base 2c70a74 and head cafc812, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt are the same blobs. No changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The Receive code this PR adds only selects the existing invoice for a nearby offer and never writes an amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), tracked by the same open issue #1971. Between merge base 2c70a74 and head cafc812, the files that reset the Receive amount are unchanged. The PR's Receive changes only read the existing invoice for nearby offering. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Findings

  • [MEDIUM] Hold NFC after a tag tap while the app is already open — inline at app/src/main/java/to/bitkit/ui/MainActivity.kt:326.
  • [MEDIUM] Refuse a bitcoin URI that has no address over Bluetooth — inline at app/src/main/java/to/bitkit/nearby/NearbyRequestFilter.kt:31.
  • [MEDIUM] Reject a nearby BOLT11 value whose checksum fails — inline at app/src/main/java/to/bitkit/nearby/NearbyRequestFilter.kt:11.
  • [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — inline at app/src/main/java/to/bitkit/repositories/LightningRepo.kt:1797.

Existing concerns

  • [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — The discussion #1883 (comment) is marked resolved. Its latest reply, #1883 (comment), moves the design choice to open issue #2000 and keeps the current scanner behavior in this PR. At cafc812 an enabled adapter still counts as active NFC, except while nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled and stops polling while the camera is open would still show an NFC status and would still have no in-scanner tap action. The Pixel 11 observation remains the author's. This PR still introduces the status claim relative to 2c70a74, so the concern stays open and is tracked by #2000. There is no material new defect evidence. This check is source inspection.

Reviewer model: grok-4.7
Reasoning effort: xhigh

jvsena42 and others added 5 commits November 24, 2026 10:10
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 💬 Comment. Two earlier findings remain open at 6a97430. Device QA carries forward to the new head.

The PR moved to fa0ebe8 after this run; these results are for 6a97430.

Findings:

  • MEDIUM LightningRepo.kt:1835. At 6a97430, a stopped QuickPay attempt can leave a new LDK hash when an earlier attempt's persisted hash is already gone but its in-memory generation remains. The new hash can block a manual Spark retry while LDK cannot list payments. Cleanup can also briefly remove a concurrent LDK send's persisted hash because removal and restoration are separate writes. The author reverted this cleanup in fa0ebe8, which leaves the original retry refusal. Existing LDK thread · Revert explanation
  • MEDIUM NearbyRequestFilter.kt:43. A nonempty address with an invalid checksum passes the filter when it consists of letters and digits. The decoder then rejects it after the scan has reset Send. Validate the Bitcoin address locally before handing the request to the scanner. Existing Bluetooth address thread

QA for 6a97430:

Check: Verify nearby parsing, QuickPay authorization and LDK send records ✅ The regtest APK built and the focused NFC, nearby, Lightning, QuickPay and Send unit suites passed.
Open a payment with mixed-case NFC metadata ⏭️ The head advanced before the foreground NFC-intent check.
Review a fixed Lightning invoice after the wallet locks ⏭️ The head advanced before the queued LDK send and manual fallback could be driven.
Review an under-limit Bluetooth Lightning request ⏭️ The head advanced before the Bluetooth payment could be rerun through the new filter.
Ignore nonpayment Bluetooth requests ⏭️ The head advanced before the Bluetooth filter could be checked on a device.

Physical NFC reads, the TapPay introduction and NFC setting on an NFC-capable phone, Square Register and Android–iPhone transport require hardware. Earlier Android results cover the unchanged Nearby payments setting, scanner permission UI and Android 11 Location settings. Earlier physical cross-platform checks are partial. Android settings and Bluetooth · Scanner permissions · Physical Android and iPhone tests

Reviewed d8a0dae..6a97430 and prior open threads. Source review confirmed the LDK submission guard, fixed-invoice amount handling, NFC wrapper handling and Bluetooth BOLT11 checksum check. Delta

The twin uses the same nearby wire format and BOLT11 checksum rule. The Android delta adds its submission check at the LDK boundary. synonymdev/bitkit-ios#1302


Reviewed by gpt-6.2-sol-high

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

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: 💬 Comment. The address check at 7dcc947 dropped valid uppercase SegWit requests. The next commit addresses the casing issue in code. Device QA carries forward to dcabb9d.

The PR moved to dcabb9d after this run; these results are for 7dcc947.

Findings:

  • MEDIUM NearbyRequestFilter.kt:47. The new Bluetooth filter passes the original address to bitkit-core 0.8.0-rc15, whose address validator recognizes lowercase SegWit prefixes only. The payment decoder normalizes those prefixes and their addresses before validation. As a result, a valid uppercase SegWit URI is dropped before Send opens. The unit test for 7dcc947 mocks uppercase validation as successful. The invalid-checksum rejection holds, and dcabb9d applies the decoder's normalization while preserving Base58 case. Pinned decoder test · Follow-up

The earlier LDK retry concern remains. A QuickPay attempt stopped before native submission keeps its send hash. A manual Spark retry can be refused until LDK can list its payments. The author retained the hash to protect payment deduplication and tracked the shared bookkeeping in #2011. Existing LDK thread

QA for 7dcc947:

Check: Nearby parsing, NFC and QuickPay regressions ✅ The regtest APK built and the focused NFC, nearby, Lightning, QuickPay and Send unit suites passed.
Open valid Bluetooth Bitcoin requests and ignore invalid addresses ⏭️ The PR advanced before the lowercase, uppercase and bad-checksum device controls ran.
Review an under-limit Bluetooth Lightning request ⏭️ The PR advanced before the funded Bluetooth review ran.
Ignore nonpayment Bluetooth requests ⏭️ The PR advanced before the Bluetooth rejection case ran.
Open a payment with mixed-case NFC metadata ⏭️ The PR advanced before the simulated NFC intent ran.
Review a fixed Lightning invoice after the wallet locks ⏭️ The PR advanced before the queued LDK send and manual fallback ran.

Physical tag reads, NFC card emulation, the NFC intro and setting, Square Register and cross-platform transport require hardware. Previous reports cover the unchanged Nearby payments setting and scanner permission UI, including Android 11 Location settings. Prior Android QA · Scanner permissions · Partial hardware results

Reviewed the contiguous delta from fa0ebe8 to 7dcc947 and the prior open review thread. Address validation was checked in source against the pinned native library. Delta

The twin shares the Bluetooth wire format and delegates Bitcoin address parsing to the decoder. The added preflight at 7dcc947 is Android-specific. synonymdev/bitkit-ios#1302


Reviewed by gpt-6.2-sol-high

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA review

Scope: changes since cafc812, including affected code paths, at dcabb9d. Baseline: previous review. The merge base is unchanged and the previous head is an ancestor of this one. The current PR diff was re-inventoried. Coverage of files unchanged since the baseline is inherited, not freshly re-read.

No new actionable code findings.

The update tightens the Bluetooth request filter. It replaces the BOLT11 regex with a bech32 checksum check, and it requires a bitcoin: URI to carry an address that bitkit-core validates for this wallet's network. Bech32 addresses are normalized to lowercase and base58 addresses keep their case. It also moves isStoppedAtSubmission into Errors.kt with no change in behaviour and adds a LightningRepo test showing that a send stopped at submission keeps an earlier send's hash. The commits that changed LightningRepo itself were reverted, so it matches the baseline.

Validation:

  • Checksum probe: a kotlinc script ran the PR's isBolt11Invoice against the real signet fixture invoice, a mainnet BOLT11 spec vector and its uppercase form. All were accepted, and a corrupted vector was rejected. This is a focused probe, not the unit suite or an app build.
  • Decoder comparison: bitkit-core v0.8.0-rc15, the version the app pins, was checked. Its scanner normalizes bech32 and base58 addresses the same way and validates them with the same validate_address. The app scanner applies the same validateBitcoinAddress and NetworkValidationHelper check. So the filter refuses no address that the scanner would accept, and a regtest wallet still accepts testnet-prefix addresses.
  • Address-less URIs: a bitcoin: URI without an address is still rewritten to lightning: or refused, as at the baseline.

Parity: the iOS twin #1302 at 8e4659c checks BOLT11 values but does not validate the on-chain address in its nearby filter. iOS shows an unsupported-request error for a refused request, while Android ignores it and keeps scanning, so this is a deliberate platform difference and not a defect on this PR.

Limitations: for this head, the unit and Compose UI CI jobs were still pending. The failed build check came from a cancelled run that a newer run superseded, so it is not evidence about this code. Unit tests were not run locally.

Device testing: not performed in this review.

Suggested additional test cases:

  • Android, regtest build, Bluetooth nearby on: on a second device, advertise a bitcoin: URI with a mainnet address. Expected: the scanner ignores it, Send is not reset, and scanning continues.
  • Android: advertise BITCOIN:<UPPERCASE BCRT1 ADDRESS>?LIGHTNING=<UPPERCASE BOLT11>. Expected: the normal review opens with the Lightning request.
  • Android: advertise lightning: with a BOLT11 invoice whose last character is changed. Expected: it is ignored and scanning continues.

Earlier findings reconciled at this revision: 2 still present, 5 verified fixed, 1 not substantiated, 2 tracked separately outside this PR.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base 2c70a74 and head dcabb9d, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt have no diff, and no changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The PR's Receive code only selects the existing invoice for a nearby offer and writes no amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), and the same open issue #1971 tracks it. Between merge base 2c70a74 and head dcabb9d, the files that reset the Receive amount are unchanged. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Existing concerns

  • [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — Mechanism still present at dcabb9d. An enabled adapter still counts as active NFC reading unless nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled but stops polling while the camera is open (the author's Pixel 11 observation) would still show an NFC status and has no in-scanner way to release the camera for a tap. Thread #1883 (comment) is marked resolved; its latest reply (#1883 (comment)) moves the design decision to open issue #2000 and keeps the current scanner behaviour in this PR. Because this PR introduces the status claim, the concern stays open and is tracked by #2000. No scanner or NfcEffects file changed since the previously reviewed head cafc812, so there is no material new evidence; reference it as an existing concern rather than re-publishing inline. Source inspection only; the hardware observation is the author's.
  • [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — Mechanism still present at dcabb9d. The author's cleanup attempts (3ae50d7, 6a97430) were reverted in fa0ebe8, and LightningRepo.kt is unchanged since cafc812. A QuickPay node send stopped at submission on the LDK queue keeps its persisted LDK send hash. A later Spark payment of the same invoice is refused with NodeNotStarted while the node cannot list payments, and works again once a listing clears the hash. No funds move twice; the consequence is a refused retry with a workable recovery, so MEDIUM is kept. Thread #1883 (comment) is unresolved. The author declined the change: removing the record can erase a real earlier or concurrent node send of the same invoice, because admitSend lets repeat node sends through and ldkSendsInFlight is shared, so Spark could pay twice. The author tracks that shared bookkeeping gap in open issue #2011. ovi-reviewer acknowledged the revert and that the original retry refusal remains. The finding's original 'expected' remedy (unconditionally remove the hash) is therefore not safe as written; a correct fix needs per-attempt ownership of the record, which depends on #2011. The new LightningRepoTest case guards the double-payment side, not this refusal. There is no material new defect evidence; reference the existing thread rather than re-publishing inline.

Reviewer model: claude-opus-5-5
Reasoning effort: high

@piotr-iohk

Copy link
Copy Markdown
Collaborator

@jvsena42 please resolve conflicts.

# Conflicts:
#	app/src/main/java/to/bitkit/repositories/LightningRepo.kt
@jvsena42

Copy link
Copy Markdown
Member Author

@piotr-iohk Resolved in bca0fa0 (merge of master). The only conflict was in LightningRepo.payInvoiceWithLdk. It keeps master's per-invoice count of node sends in flight (cfebd44, which closes #2011) together with this PR's QuickPay submission check on the LDK queue. A send stopped at submission releases its count once, like any other failed send.

After the merge, the full unit suite passes (6,594 tests), detekt is clean, and androidTest compiles.

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: ⚠️ Not verified

The PR moved to bca0fa0 after this run; these results are for dcabb9d.

Findings:

No new findings. The Bluetooth preflight now accepts uppercase SegWit and refuses addresses for an incompatible network before changing the Send screen. Address-validation thread

The earlier manual Spark retry can still be refused while LDK cannot list its payments. The shared send bookkeeping is tracked in #2011. Existing LDK thread

QA for dcabb9d:

Tested with the pinned bitkit-core on regtest Android 15 emulators. A debug-only peer supplied the Bluetooth payload controls.

Check: Nearby parsing, NFC and QuickPay regressions ✅ The pinned regtest APK built and the focused NFC, Bluetooth, Lightning and QuickPay suites passed.
Open valid Bluetooth Bitcoin requests and ignore invalid addresses ✅ Lowercase and uppercase SegWit requests opened Bitcoin Amount. The Bluetooth scanner logged and ignored the bad checksum and wrong-network requests while Send stayed open.

Review an under-limit Bluetooth Lightning request ✅ With QuickPay enabled at $5, the 1,000-sat standalone and uppercase unified Bluetooth requests opened Swipe To Pay. The scanner logged and ignored the bad invoice checksum.

Ignore nonpayment Bluetooth requests ✅ The Bluetooth scanner logged and ignored plain text without leaving Send. A valid Bitcoin request then opened Bitcoin Amount.

Open a payment with mixed-case NFC metadata ✅ A simulated NFC launch with mixed-case optional metadata opened Bitcoin Amount. An unsupported required parameter showed Unable To Read NFC and left Home visible.

Review a fixed Lightning invoice after the wallet locks ⏭️ The PR advanced before the held LDK send and manual fallback could be exercised.

Physical tag reads, card emulation, the TapPay intro, Square Register, and the remaining Android–iPhone transport cases need compatible hardware. The existing reports cover the unchanged settings and scanner-permission journeys, Android 11 Location settings, and Bluetooth advertising when disabled or locked. Android QA · Scanner permissions · Physical-device results

Reviewed 7dcc947..dcabb9d and the open LDK thread. Base58 case preservation was checked in the pinned decoder and filter source. Independent QA review

The iOS twin shares the Bluetooth wire format and validates Bitcoin addresses during decoding. Android checks address validity before handing the request to Send. synonymdev/bitkit-ios#1302


Reviewed by gpt-6.2-sol-high

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA review

Scope: full PR at bca0fa0, re-reviewed after the comparison base changed (2c70a74 → ddd0718) and target-branch edits touched LightningRepo, LightningService, Errors, and LightningRepoTest.

No new actionable code findings.

At this revision an NFC read uses the same scan path as a QR code, including QuickPay. A Bluetooth read is limited to a payable bitcoin URI, a BOLT11 invoice, or an ethereum URI, and it opens review. A scan that crosses the lock opens review. The node send checks the lock again on the LDK queue before submission. Receive offers the request on screen and stops while the app is locked or offline.

Compared the shared nearby contract with bitkit-ios#1302 at 6eafe92. This is not a review of that PR. The service UUID, 512-byte chunks, addressless bitcoin:?lightning= rewrite, req- refusal, and Bluetooth QuickPay suppression match. Android's Bluetooth filter also requires a bitcoin address on the wallet's network; iOS leaves the address to the scanner. Android closes and replaces the GATT server when the offered URI changes; iOS keeps the server and snapshots the request when the payer reads meta. A payer does not receive a mix of two requests on either side.

Device testing was not performed in this review. The author reports just compile, just test, and just lint on 28639c4e7, and device runs on earlier builds (case 15 on 2336ef1ca, against bitkit-core master). Those results are not this head. This review read the unit tests and did not run them.

Recommended before device testing: Repeat cases 1, 1a, 5, and 15 on this head. Their recorded results are from earlier builds, and this revision merges newer master changes into the Lightning send and channel-wait path.

Ready for device testing of the remaining PR cases: 1b, 2–4, 6–14, J1, and J2. Cross-platform Bluetooth and NFC (7, 8) and Square Register (11) are still unchecked.

Suggested additional test cases

  • Android, QuickPay on, spending balance covers the invoice. Tap an NFC request so QuickPay starts, then lock the app before it finishes. The payment stays in the wallet and the swipe review opens.
  • Android, wallet locked on the PIN screen. Tap a nearby Receive phone or a lightning tag, then unlock. The request opens the review and QuickPay does not pay it.

Earlier findings reconciled at this revision: 2 still present, 2 tracked separately outside this PR.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base ddd0718 and head bca0fa0, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt are the same blobs. No changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The PR's Receive code only selects the existing invoice for a nearby offer and writes no amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), and the same open issue #1971 tracks it. Between merge base ddd0718 and head bca0fa0, the files that reset the Receive amount are unchanged. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Existing concerns

  • [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply moves the design choice to open issue #2000 and keeps the current scanner behavior in this PR. At bca0fa0 an enabled adapter still counts as active NFC, except while nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled and stops polling while the camera is open would still show an NFC status and would still have no in-scanner tap action. The Pixel 11 observation remains the author's. The scanner and NfcEffects files are unchanged since dcabb9d, so there is no material new defect evidence. This stays an existing open concern of this PR, tracked by #2000. This check is source inspection.
  • [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply, #1883 (comment), says the revert in fa0ebe8 leaves the original retry refusal while the node cannot list payments. At bca0fa0 a QuickPay node send still writes the LDK send hash before lightningService.send. A false isAuthorizedAtSubmission throws PaymentStoppedAtSubmission on the LDK queue before bolt11Payment().send. The failure path releases that attempt's in-flight count and does not remove the hash. QuickPay falls back to review with isMarkedDispatched true and leaves the cache hash in place. A later Spark payment of the same invoice throws NodeNotStarted while the node cannot list payments, until a listing that shows no send removes the hash. The master merge in this head changes ldkSendsInFlight from a set to a per-key count, which closed #2011. That count is released when the stopped send returns. The persisted hash is still one record per invoice and is still kept. Issue #2011 covers the in-flight count, a different mechanism, and its closure does not remove this hash. The author's decline of unconditional removal still matches LightningRepoTest, which expects an earlier send's hash to stay. No funds move twice. The consequence remains a refused Spark retry with a workable recovery, so MEDIUM stays. There is no material new defect evidence, so reference the existing discussion rather than re-publishing it inline. This check is source inspection.

Reviewer model: grok-4.7
Reasoning effort: xhigh

@jvsena42

Copy link
Copy Markdown
Member Author

Device run on bca0fa0ba (PR head), Pixel 11 (Android 17) receiving and Xiaomi 22031116BG (Android 13) paying, regtest devDebug with Spark-funded wallets. Side-by-side videos and log times are under Evidence in the description.

Case Result
1. NFC, QuickPay off Pass: review for ₿ 1,000
1a. NFC, QuickPay on, under threshold Pass: paid without review, 5.2 s from read to COMPLETED
1b. NFC, over threshold (₿ 10,000, $5.89) Pass: review, no QuickPay
2. lightning:, bitcoin:?lightning= and LNURL-pay tags from the main scanner Pass: review, review, LNURL-pay amount screen. No LNURL payment completed (local test server)
3. USDT Receive → USDT send scanner over NFC Pass: recipient filled with the Pixel's address. No USDT sent (no balance)
4. Erased tag / https://example.com tag Pass: "Unable To Read NFC" toast / scanner decoding toast
5. Bluetooth Pass: read 2 s after Send opened, QuickPay suppressed, swipe to pay completed
15 and a tag, Bitkit in the background Pass: chooser once, one deeplink, QuickPay paid

Findings:

  • With Bitkit in the background, QuickPay starts about 10 s after Bitkit gets the request, not 1.9 s. The LDK node has stopped, and the QuickPay check at AppViewModel.kt:6776 waits for it to start (channelsAreSettling() is true while the node is not running), even when Spark covers the amount. The comment there says this is intended; flagging it because the earlier 1.9 s figure no longer holds for a cold background start.
  • The decoding toast for a non-payment NFC tag reads "Unable to read QR" ("Incapaz de Ler o QR"), though the value came from NFC.
  • With Bluetooth on, the payer's Send screen picks up a Receive phone nearby over Bluetooth before any tap, so NFC-only checks need Bluetooth off on the paying phone.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@piotr-iohk piotr-iohk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QA review

Scope: changes since bca0fa0, including the new Bluetooth acceptance paragraph and the filter path it describes, at 7ebf6ef. Baseline: previous QA review. Unchanged nearby-payment behavior remains covered by that baseline.

No new actionable code findings.

The added paragraph in docs/nearby-payments.md matches nearbyPaymentRequest: a payable bitcoin: URI is passed on only when every lightning parameter is a BOLT11 invoice, a lightning: value is passed on only when it is a BOLT11 invoice, and an ethereum: URI is passed on. LNURL, Lightning addresses, and BOLT12 offers are not handed to the scanner. NearbyRequestFilterTest already asserts those accept and refuse cases. git diff --check on the documentation delta passed. Unit tests were not run.

Compared with bitkit-ios#1302 at 3c26e983: Docs/nearby-payments.md has the same paragraph, and ScannerManager.isNearbyPaymentRequest uses the same category rules. That check covered this acceptance contract only, not the rest of the iOS pull request.

Device testing: not performed in this review.

Suggested additional test cases

  • Android, Send scanner open, with a nearby peer advertising an LNURL-pay request, a Lightning address, or a BOLT12 offer on the nearby service. The scanner should stay on the scan screen. Manual case 2 expects an LNURL NFC tag to open Send, and manual case 12 covers a pubkyauth:// advertisement.

Earlier findings reconciled at this revision: 2 still present, 2 tracked separately outside this PR.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base ddd0718 and head 7ebf6ef, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt are the same blobs. No changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The PR's Receive code only selects the existing invoice for a nearby offer and writes no amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), and the same open issue #1971 tracks it. Between merge base ddd0718 and head 7ebf6ef, the files that reset the Receive amount are unchanged. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.

Existing concerns

  • [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply, #1883 (comment), moves the design choice to open issue #2000 and keeps the current scanner behavior in this PR. At 7ebf6ef an enabled adapter still counts as active NFC, except while nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled and stops polling while the camera is open would still show an NFC status and would still have no in-scanner tap action. The Pixel 11 observation remains the author's. NearbyScanSources.kt and NfcEffects.kt are the same blobs as at bca0fa0, and the only commit since that head is docs/nearby-payments.md, so there is no material new defect evidence. This stays an existing open concern of this PR, tracked by #2000. This check is source inspection.
  • [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply, #1883 (comment), says the revert in fa0ebe8 leaves the original retry refusal while the node cannot list payments. At 7ebf6ef a QuickPay node send still writes the LDK send hash before lightningService.send. A false isAuthorizedAtSubmission throws PaymentStoppedAtSubmission on the LDK queue before bolt11Payment().send. The failure path releases that attempt's in-flight count and leaves the hash in place. QuickPay falls back to review with isMarkedDispatched true and leaves the cache hash in place. A later Spark payment of the same invoice throws NodeNotStarted while the node cannot list payments, until a listing that shows no send removes the hash. Issue #2011, closed on 2026-11-24, covers the in-flight count, a different mechanism, and its closure does not remove this hash. The author's decline of unconditional removal still matches LightningRepoTest, which expects an earlier send's hash to stay. No funds move twice. The consequence remains a refused Spark retry with a workable recovery, so MEDIUM stays. LightningRepo.kt, QuickPayRepo.kt and LightningService.kt are unchanged since bca0fa0, so there is no material new defect evidence. Reference the existing discussion rather than re-publishing it inline. This check is source inspection.

Reviewer model: grok-4.7
Reasoning effort: xhigh

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict: ✅ Approve

Findings: None new in the reviewed delta.

QA for 7ebf6ef:

Built with the pinned dependencies and tested on regtest Android 15 emulators. The locked launch used the unchanged APK; the queued-send and crafted Bluetooth checks used the debug-only hooks below.

Check: Lightning retry and nearby payment regressions ✅ The APK built and the focused Spark, Lightning, Send, QuickPay, nearby and NFC suites passed.
Review a payment received while the wallet is locked ✅ An NFC launch intent received on the PIN screen stayed unpaid after unlock opened review, then settled after the swipe and PIN.

This injects Android's NFC launch intent; it does not exercise a physical tag. The receiver confirmed the 1,000-sat invoice was unpaid until manual confirmation.

Review a fixed Lightning invoice after the wallet locks ✅ Locking while QuickPay waited on the LDK queue stopped submission; the original invoice settled after manual confirmation.

A debug hook held the real send immediately before its authorization check. After the lock, the check refused submission, unlocking opened Swipe To Pay, and the receiver confirmed settlement only after the swipe and PIN.

Test hook, not pushed
diff --git a/app/src/main/java/to/bitkit/services/LightningService.kt b/app/src/main/java/to/bitkit/services/LightningService.kt
index aff3b3246..4cc96c0e7 100644
--- a/app/src/main/java/to/bitkit/services/LightningService.kt
+++ b/app/src/main/java/to/bitkit/services/LightningService.kt
@@ -1195,6 +1195,15 @@ class LightningService internal constructor(
         return ServiceQueue.LDK.background(ldkQueue) {
             keychain.requireWalletRestoreComplete()
             ensurePaymentDeadline(paymentDeadlineAt)
+            if (to.bitkit.BuildConfig.DEBUG) { // test hook
+                val hold = java.io.File(Env.logDir.parentFile, "review-hold-ldk") // test hook
+                if (hold.isFile) { // test hook
+                    Logger.info("QA LDK queued payment waiting before authorization", context = TAG) // test hook
+                    kotlinx.coroutines.withTimeout(120_000) { // test hook
+                        while (hold.isFile) kotlinx.coroutines.delay(100) // test hook
+                    } // test hook
+                } // test hook
+            } // test hook
             if (!isAuthorizedAtSubmission()) throw ServiceError.PaymentStoppedAtSubmission()
             runCatching {
                 val routeParameters = maxTotalRoutingFeeMsat?.let(::routeParametersWithFeeCap)
Keep scanning after unsupported Bluetooth requests ✅ LNURL-pay, a Lightning address and BOLT12 offers left Send scanning; a valid Bitcoin request then opened Amount.

Tested bare and lightning:-wrapped LNURL-pay and BOLT12 payloads. App logs confirmed each exact payload arrived over GATT and was rejected by the payment filter. The peer's debug hook supplied the crafted payload; its visible QR still shows its native Bitcoin request. Left: peer; right: payer.

LNURL-pay variants and Lightning address:

BOLT12 variants and Bitcoin control:

Test hooks, not pushed

The peer overrides only the advertised URI. The payer logs receipt immediately before the unchanged filter. The earlier LDK hold is present but inactive in these builds.

diff --git a/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt b/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt
index f30277257..a9fbd56ba 100644
--- a/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt
+++ b/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt
@@ -224,6 +224,12 @@ fun offerPaymentNearby(request: String?): Boolean {
     val canAdvertise = isNearbyEnabled && bluetoothState == BluetoothState.ON && !advertiseFailed
 
     NfcEmitterEffect(uri = uri.takeIf { emitsNfc }, onFailed = { emitFailed = true })
-    NearbyAdvertiseEffect(uri = uri.takeIf { canAdvertise }, onFailed = { advertiseFailed = true })
+    val reviewUri = if (to.bitkit.BuildConfig.DEBUG) { // test hook
+        val context = LocalContext.current // test hook
+        remember(uri) { // test hook
+            java.io.File(context.filesDir, "review-nearby-uri").takeIf { it.isFile }?.readText() // test hook
+        } // test hook
+    } else null // test hook
+    NearbyAdvertiseEffect(uri = (reviewUri ?: uri).takeIf { canAdvertise && uri != null }, onFailed = { advertiseFailed = true })
     return uri != null && (emitsNfc || canAdvertise)
 }

diff --git a/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt b/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt
index d7abee300..0c3dca456 100644
--- a/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt
+++ b/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt
@@ -121,6 +121,7 @@ class NearbyScanner(
         if (session !== finished) return
         session?.close()
         session = null
+        if (to.bitkit.BuildConfig.DEBUG) Logger.info("QA nearby received: $request", context = TAG) // test hook
         val payment = request?.let(::nearbyPaymentRequest)
         if (request != null && payment == null) {
             Logger.warn("Ignored nearby request that is not a payment", context = TAG)

Carried evidence from unchanged code:

Not driven here: physical NFC and fresh NFC-device eligibility, Square Register, and the remaining Android–iPhone radio cases require compatible hardware.

Reviewed dcabb9d..7ebf6ef, including the master merge and prior open feedback. Spark restart/storage races and VSS recovery were checked by source and regression tests rather than these device cases.

Twin: synonymdev/bitkit-ios#1302. The nearby protocol documents match at 62b07d3; physical cross-platform interoperability was not retested.


Reviewed by gpt-6.1-sol-high

@ovitrif ovitrif left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utAck

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.

feat: nfc and bluetooth payments

4 participants