Skip to content

feat: nfc and bluetooth nearby payments - #1302

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

jvsena42 merged 76 commits into
masterfrom
feat/nfc-payments

Conversation

@jvsena42

@jvsena42 jvsena42 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Closes #1178

Twin: synonymdev/bitkit-android#1883

This PR adds nearby payments to the iOS app. Over NFC the iPhone reads payment requests from terminals and other phones. Over Bluetooth LE it can also be the receiving side: the Receive screen offers its request to nearby phones. Both use the shared format in Docs/nearby-payments.md, which is identical to the Android copy.

Description

  • Adds a Core NFC reader started from the payment scanners ("Tap payment terminal or phone"). It reads one NDEF tag: URI records with prefix codes, UTF-8/UTF-16 Text records, or absolute URIs. The request goes through the same handling as a scanned QR code, so Lightning, BIP-21, LNURL and USDT ethereum: requests reach their usual flows and QuickPay applies.
    • A tag without a readable payment request is refused on the system NFC sheet itself, with the reason shown.
    • A transport failure shows "Bitkit could not read this tag", not "no payment request".
  • Adds Bluetooth LE nearby payments v1:
    • The Receive screen runs a GATT server while it is in the foreground, the setting is on, and Bluetooth is already allowed. It advertises the service UUID only, with no device name.
    • Receive never asks for Bluetooth permission. The permission is requested from a payment scanner's Bluetooth button, as on Android. Neither side shows the system "Turn On Bluetooth" alert.
    • It serves the request as a bitcoin:/lightning: URI through a meta characteristic plus 512-byte chunks, and honours the ATT read offset. USDT Receive offers its Arbitrum EIP-681 request.
    • Each reading phone gets the request it started with, even if Receive changes the request mid-read.
    • Advertising resumes when Receive is shown again, for example after Edit.
    • Payment scanners scan for the service and pick the strongest advertiser at or above -60 dBm. They read meta and chunks, disconnect, and hand the request to the scanner.
    • The same phone is not retried for 10 s. Scanning pauses while a request is handled or while the scanner is covered. It resumes when a request was refused or not taken, and when the scanner is shown again.
  • Accepts only payment requests over Bluetooth: bitcoin: (every lightning= part must be a BOLT11 invoice), lightning: BOLT11 invoices and ethereum: (USDT). Invoices are checked locally (network prefix, amount and bech32 checksum) before decoding. LNURL and Lightning addresses are refused before decoding, since decoding contacts their server before the user picked the request, and BOLT12 offers are refused because the decoder does not read them. The decoded request must be on-chain or Lightning. Sign-in, setup, LNURL-withdraw/auth/channel, node and contact links get the usual unreadable-code toast. NFC stays unrestricted.
  • Opens Bluetooth requests in the normal review with QuickPay suppressed, since Bluetooth range lets a device that is not the merchant's answer.
  • Updates the scanner status pill to list the active sources: "Scanning QR, NFC & Bluetooth", "Scanning QR & NFC", "Scanning QR & Bluetooth" or "Scanning QR".
    • When Bluetooth is not allowed, Bluetooth and NFC buttons sit above the pill. The Bluetooth button asks for permission, or opens Settings after a denial. The NFC button, or the pill itself, starts an NFC read.
    • With the camera denied, payment scanners show "Scan to pay" with camera, Bluetooth and NFC buttons.
  • Shows "Scan or tap to pay" under Edit/Copy/Share on Receive, only while the request is being advertised.
  • Translates every new string into all 14 app languages.
  • Adds a "Nearby payments" toggle (default on) under Security > Privacy that turns Receive advertising off. It is included in settings backup and mapped to Android's isNearbyPaymentsEnabled.
  • Adds the one-time "TapPay (NFC)" intro sheet, which has a QuickPay toggle and a Settings shortcut. It shows only on NFC-capable iPhones with a wallet.
  • Adds the NFC Tag Reading entitlement (TAG format only, which covers NDEF sessions and avoids App Store error ITMS-90778), NFCReaderUsageDescription, and the Type 4 tag AID D2760000850101 so Android-emulated tags are detected. It reuses the existing Bluetooth usage description, with its wording widened to cover nearby payments. No background modes are added.

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

Protocol compatibility

Counterpart Direction Supported
Bitkit Android (twin PR) NFC: iPhone reads Android's emulated tag. Bluetooth: both directions Yes
Bitkit iOS ↔ Bitkit iOS Bluetooth only (iOS cannot emulate an NFC tag) Yes
Square Register (2nd gen) Protocol unpublished; inferred Type 4 tag with lightning:<bolt11> Expected, unverified
Numo, ZEUS (PR #4053, unmerged), static lightning:/bitcoin:/LNURL tags iPhone reads the tag Yes
Bolt Card terminals (Blink, BTCPay, LNbits TPoS, Swiss Bitcoin Pay, WoS merchant) Terminal reads an lnurlw card No
USDT over NFC No terminal found on any chain Reading an ethereum: tag works

Review round

  • Required parameters: a bitcoin:?… URI with a required (req-) parameter is no longer rewritten to lightning:<invoice>, which dropped that parameter. The scanner refuses it instead (0eeb163f2, testRequestWithRequiredParameterIsKept).
  • Bluetooth after leaving: a Bluetooth request that finishes decoding after the user leaves the scanner or Send sheet no longer opens a payment (34cd05baf, testNearbyRequestCannotRouteAfterItsScannerCloses).
  • VoiceOver labels: the scanner's camera, Bluetooth and NFC buttons have VoiceOver labels, ported from an Android finding (ebcfe41d1).
  • Refused requests: a Bluetooth request that opens nothing on the main scanner, such as an expired invoice, no longer stops further Bluetooth reads (6d1327632, testRefusedNearbyRequestOnMainScannerIsNotTaken).
  • Empty required parameters: a req- key with an empty or no value also keeps the URI unrewritten (6f45cef19, ported from an Android finding).
  • Send sheet moves on: a Bluetooth request still decoding when the user opens Enter Manually or another Send route now routes nothing (e8cb89ae9). SendOptionsView passes the check on its own navigation path, which wasn't verified on a device.
  • QR or NFC during a Bluetooth decode: a QR code or NFC read the user starts takes the scan lock from a Bluetooth request that is still decoding. The Bluetooth request then routes nothing and reports not taken, and its QuickPay suppression ends so QuickPay applies to the user's read (0c1486abd, 6451b2820, testUserScanTakesOverFromADecodingNearbyRequest, testMainScannerQrTakesOverFromADecodingNearbyRequest). Not verified on a device.
  • Translated button labels: other__bluetooth_enable and other__nfc_read_button are in all 14 non-English locales, ported from an Android finding (d1d638977).
  • Master merge (23f0c20e1): master now asks for the payment PIN before QuickPay settings are raised (fix: require payment pin for quickpay changes #1326). The TapPay (NFC) intro sheet's QuickPay toggle now goes through changeQuickpaySetting and shows the same PIN check, instead of writing the setting directly. Not driven on a device.
  • NFC holds the scan lock: an NFC read takes the scan lock when its sheet opens, so a Bluetooth request can't route behind the NFC sheet and then be covered by the NFC result (ac7649a33, testBluetoothRequestCannotRouteWhileAnNfcReadIsOpen, testFailedNfcReadReleasesTheScanLock). Not driven on a device.
  • Settings restore: restoring a settings backup now updates the nearby payments setting in the same session, and a backup without the key restores the default on (346f7e0, testNearbyPaymentsFollowARestoredBackup).
  • NFC after leaving Options: an NFC request still decoding no longer routes once the Send sheet moves to Enter Manually or closes (d9a0b2a, testNfcReadCannotRouteAfterItsSendSheetCloses, testNfcReadCannotRouteAfterTheSendSheetMovesOn). Not driven on a device.
  • Leaving and returning: a scan started on a scanner visit no longer routes after the user leaves and comes back (Enter Manually → Back, or a full-screen scanner left and reopened). Send counts its own visits; other scanners compare a navigation path generation instead of path equality (594cbab, testNfcReadCannotRouteAfterLeavingAndReturningToTheScanner). Not driven on a device.
  • Declined: checking a plain-text tag's value before closing the NFC sheet. The reasons are in the thread.
  • Tests: ScannedPaymentRequestTests and ScannerManagerTests pass, 36 tests. Each new test fails without its fix.

Review round (QA review of 594cbab)

  • Repeated parameters: an addressless request that repeats any parameter (e.g. amount=0.01&AMOUNT=0.02) is left as is, so the scanner rejects it instead of paying the bare invoice (023fd6550).
  • Amount the invoice lacks: an addressless request whose amount differs from the invoice amount, or whose invoice has no amount, is rejected; a matching amount still unwraps (f4856ecde, ported from Android).
  • LNURL over Bluetooth: LNURL, Lightning addresses, lnurlp:, LNURL inside a unified URI and BOLT12 offers are refused before decoding, so discovery alone contacts no server (d10feb1bc).
  • Scanner stops mid-delivery: stopping the Bluetooth scanner (scene inactive, pause, disappear) revokes a request still decoding (f63fde7f1).
  • Connection issues screen: Send Options pauses Bluetooth while the screen covers it, and ends the scanner visit (506d240a6).
  • Receive: offers nothing while its QR waits for the first refresh or is covered by the connection issues screen (218ec0acc).
  • Each fix has a unit test that fails without it; 237 tests across 19 classes pass (.ai/validate-r19.sh). None was driven on a device.

Review round (QA review of 218ec0a)

  • Bluetooth invoices: checked locally before decoding, so a Lightning address that starts like an invoice (lnsb@example.com) is refused (b0dfab34a).
  • BIP 321 parameters: only a repeated amount, label, message or pop keeps the URI; unknown optional keys may repeat again. A repeated lightning is valid BIP 321 but is kept as unsupported (1121e28c8).
  • Amount syntax: amount must match the BIP grammar as a whole before it is compared with the invoice (56dc8da2e). Core gets the same checks in fix: check bip 321 amounts against the bip bitkit-core#225.
  • USDT Receive: stops advertising behind the connection issues screen (ef5754ff0).
  • Revoked Bluetooth delivery: a request revoked before its callback runs shows no error (f4ee7e400).
  • App locks during a scan: a scan still decoding when the app locks routes nothing (06b18de2a, ported from Android).
  • Each fix has a unit test that fails without it (.ai/validate-r20.sh); 242 tests across 19 classes pass. None was driven on a device.

Review round (QA review of 06b18de)

  • Route after the app locks: a main-scanner route still waiting for the scanner sheet to close (USDT, payment or review sheet) is cancelled when the app locks (0e6b02caf).
  • Repeated offers: a URI with one BOLT11 invoice and repeated BOLT12 offers unwraps to the invoice; a second lightning value still keeps the URI (1121e28c8 rule refined in fda8a0a64).
  • Both fixes have a unit test that fails without them (.ai/validate-r22.sh); 277 of 278 tests across 16 classes pass. ShopPaymentRequestTests.testSignupScannerRoutesRequireApproval fails the same way without these commits, at its precondition that no Pubky identity is stored, which points at the local simulator keychain. None was driven on a device.

Review round (QA review of 7edd6c6)

  • Lock and other sheets: a lock cancels only the route the scan itself opened, recorded around its synchronous route call, so a received-payment sheet that replaced the scanner during a decode still opens (dcf446d81).
  • Required parameters over NFC and Bluetooth: a bitcoin: request with any req- key is refused before decoding (Bluetooth) or as an unreadable tag (NFC); QR scans wait for the core bump (c2ac1bf0c).
  • SwiftFormat on Linux crashed on two constructs in round 22; 7edd6c6d4 rewrites them.
  • Both fixes have a unit test that fails without them (.ai/validate-r23.sh); 279 of 280 tests across 16 classes pass, with the same keychain-dependent ShopPaymentRequestTests failure as before. None was driven on a device.

Review round (ported from bitkit-android#1883)

  • QuickPay after a lock: QuickPay starts when its screen appears, and the Send sheet can hold that screen behind the node-sync screen. A lock and unlock in that window let it start without the payer. The app now counts locks; if one happened since QuickPay was chosen, the screen opens the normal review instead. A payment already started reattaches as before (75b782155). This also covers camera QR scans.
  • QuickPay recovery (ovi): a rescan of an invoice whose QuickPay payment is still open keeps replaying its status after a lock; the lock check applies only to new submissions (39499de10). A start allowed only for recovery never sends; if the payment's record is gone by the time it runs, the normal review opens (d563538e3, from Greptile). The req- check removes every wrapper the app or decoder strips (bitkit://, Lightning schemes, repeated) before looking for a bitcoin: request (6f925e7ca, from piotr on bitkit-android#1883). Since bitkit-core deletes every bitkit:// in a deep link, not only a leading one, the check now does the same, so …&bitkit://req-pop=x is refused (752726a81, from piotr on bitkit-android#1883). Master is merged in (dfcc91211). Two new tests are updated to master's QuickPay API (reserveBound(enabled:), onConfirm(SendRoute)), since CI's merge build could not compile them (ba88a7b1a, from piotr).

Review round (pwltr on ba88a7b)

  • Photo priority: a picked photo blocks nearby requests until it is handled (d2dabd5ab).
  • Node setup scanner: NFC and Bluetooth reads are off when the scanner is opened from manual channel setup (727343d1d).
  • Nested bitkit://: the req- check repeats the deletion until nothing changes (661559d58, from piotr on bitkit-android#1883).
  • Out of scope: the scan lock outliving a scanner visit during an LNURL fetch is the same on master for camera and paste scans: Scan lock outlives the scanner visit while an LNURL request is pending #1400.
  • Removed a duplicate UUID assertion (cc9933ac8).

Review round (ovi, pwltr, piotr on cc9933a)

  • Photo ownership: a picked photo takes over a Bluetooth request still decoding, holds off new ones only during its scanner visit (b4fb84402), and Bluetooth stops while the photo picker is open (d8497d69b).
  • bitkit:// scope: the req- check deletes bitkit:// only while the text starts with it, as bitkit-core does (32f2086de, from piotr on bitkit-android#1883).
  • Empty amount: an empty amount= keeps an addressless URI instead of unwrapping it (0c639f7d1).
  • QuickPay lock during preparation: a lock during the LNURL invoice fetch opens the review instead of sending (f30fe8390, ported from ovi on bitkit-android#1883).
  • Removed NDEF tests that repeated the zero-prefix case (b38dbf16e). Flattened nested test closures that crashed SwiftFormat on Linux.
  • Bluetooth recipient (pwltr): choosing or confirming the receiver is tracked in Let the payer choose or confirm the recipient of a Bluetooth request #1401.
  • Known unrelated failure: InitializingWalletViewTests.testSlowRetryWaitsForRunningNodeBeforeCompleting (from master) failed once in CI.
  • Each fix has a test that fails without it (.ai/validate-r30.sh). Nothing was run on a device.

Review round (ovi, pwltr on b38dbf1)

  • Photo scanner visit: a picked photo uses one visit check for holding off nearby requests and for routing, including Send Options' own visit and a reopened full-screen route (488067711).
  • QuickPay lock at submission: the lock is checked again in LightningService.send(beforeSubmission:) on both rails, after their waits; a refused payment releases its reservation and opens the review (14033b42b).
  • Nearby payments default: kept on. Figma (Handoff v62/v63) shows the Receive indicator with no opt-in step.
  • Several photos (piotr): Bluetooth waits until every picked photo of the current visit finishes (116e838af).
  • Wrapped stop (Greptile): the stop thrown on the LDK queue arrives wrapped in AppError and is matched there too (6f31acaf8).
  • Flattened the new closures that Linux SwiftFormat crashed on (332874c0c).
  • Scans outlasting a PIN lock (pwltr): camera, paste, scanner manual entry, photo and Send > Enter Manually drop a lookup that returns after a lock, so it cannot route or choose QuickPay after the unlock (c2d6456c2, 08fedc7ae, 8e4659c9e). Added tests for QuickPay suppression and NFC error toasts (fd1e78296).
  • NFC error after leaving the scanner (pwltr): a read that ends after its visit ends quietly (6eafe921d).
  • Mixed-case bitkit:// (ported from ovi on bitkit-android#1883): deleted only in lowercase, like the decoder (0a0d2eb8b).
  • Stopped QuickPay after a rescan (independent review): a rescan that attaches to the waiting payment gets the review (04fe5fb56).
  • Stopped QuickPay routing (ovi): the review opens on the QuickPay screen attached now, and only while the same send owns the send state (45f719ff6).
  • Each fix has a test that fails without it (.ai/validate-r31.sh). Nothing was run on a device. Each fix has a test that fails without it (.ai/validate-r29.sh, .ai/validate-r29b.sh). Nothing was run on a device. A lightning:-wrapped bitcoin: request with a req- key is refused over NFC like an unwrapped one (059f1cb41, from Greptile on bitkit-android#1883).
  • testQuickpayChosenBeforeALockWaitsForReview fails without the fix; 298 of 298 tests across 16 classes pass (.ai/validate-r24.sh). Not driven on a device.

Master merge (7e9881e, 54d7c2f)

  • Merged master to clear the conflict. In QuickPayPaymentCoordinator.init, both changes stay: the branch's submit with its check right before submission, and master's needsUpdateToSend recheck.
  • Master removed the Spending onboarding screen. The nearby request now checks that the selected Receive tab is shown, in place of showingSpendingOnboarding.
  • Master now refuses a Spark send while Spark can't list its payments. So the test of a stopped send while Spark can't list now retries on the node (testASendStoppedBeforeSubmissionIsNotHeldWhileSparkCannotList; it fails when the stop leaves a Spark record). A Spark retry with a readable list is covered by testASendStoppedBeforeSubmissionLeavesNoHold.
  • QuickPayPaymentCoordinator, ChannelFreeRail, ScannerManager, PaymentNavigationHelper, SparkPaymentSafety, ReceiveNearbyOffer and ReceiveTabs tests pass (287 tests). An independent review of the merge found no defects.

Review round (pwltr, Greptile on 54d7c2f)

  • Nearby and NFC request checks split the query on Unicode scalars, as bitkit-core does. A combining mark after ? or & no longer hides a nested Lightning address or a req- key from them (6e2de6c).
  • Receive advertises over Bluetooth only while its QR is on screen. It stops while Edit is pushed or the passphrase or pairing sheet is open, and restarts after a swipe back (62b07d3, 3c26e98). Not yet driven on a device.
  • Tests: testDelimiterFollowedByACombiningMarkStillSplitsTheQuery, new inputs in testNearbyAllowlistAcceptsPaymentSchemesOnly and testNearbyRequestWithARequiredParameterIsRefused, and testRequestIsNotOfferedWhileEditCoversTheQr. ScannerManager, ScannedPaymentRequest, ReceiveNearbyOffer and ReceiveTabs tests pass (70 tests).

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 #1344.

Out of Scope

Design

Preview

These are simulator captures. The simulator has no NFC or Bluetooth, so the build used for them had an uncommitted change: it forced NFC to report as available, and an env var simulated an active Bluetooth scan or advertisement for 1b and 3.

Scanner (QR & NFC) Scanner (all sources, simulated) TapPay intro
Scanner, QR and NFC Scanner, QR, NFC and Bluetooth TapPay intro
Receive, advertising (simulated) Receive, not advertising Nearby payments setting
Receive with Scan or tap to pay Receive without label Nearby payments setting

QA Notes

Setup

  • Physical iPhone 7 or later. The simulator has neither NFC nor Bluetooth.
  • Before a device build:
    • Enable the NFC Tag Reading capability on the to.bitkit* App IDs in the Apple Developer portal.
    • Regenerate the provisioning profiles.
    • Signing fails without these steps.
  • A regtest wallet with a Lightning channel (for QuickPay) and on-chain funds.
  • For the Android cases, an Android phone running the twin Android branch. Its Receive screen emulates an NFC tag and advertises over Bluetooth.
  • An NTAG213/215 sticker written with NFC Tools, for the tag cases.
  • To see the TapPay intro again, wipe the app.

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_ios.sh. It writes dist/ios/BitkitCore.xcframework.
  2. Drag the core checkout folder into the Bitkit project in Xcode. A local package overrides the remote bitkit-core package with the same name.
  3. Quit Xcode and open it with BITKIT_CORE_LOCAL=1 open -a Xcode Bitkit.xcodeproj. Core's Package.swift then uses the local xcframework instead of the rc15 release binary. Without the variable, Xcode builds the master Swift bindings against the rc15 binary.
  4. Remove the local package before committing.

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

N/A — not drivable; see Manual Tests. NFC and Bluetooth are not in the Capabilities table.

Manual Tests

  • 1. Scanner → tap the NFC button or pill → hold near a lightning:<bolt11> tag (above the QuickPay threshold) → Send confirm opens with the invoice — NFC not in Capabilities
  • 2. Same with a bitcoin:<address>?amount=…&lightning=<bolt11> tag → unified request opens as a QR scan would — NFC not in Capabilities
  • 3. LNURL-pay tag (LNURL1… or lightning:LNURL1…) → LNURL pay amount screen. A LUD-17 lnurlp://… tag fails the same way its QR code does on master (fix: Error decoding some Lightning and LNURL schemes bitkit-core#70) — NFC not in Capabilities
  • 4. USDT request tag ethereum:<address>@42161 (USDT enabled) → USDT send flow — NFC not in Capabilities
  • 5a. NFC with QuickPay on, invoice below threshold → pays without confirmation — NFC not in Capabilities
  • 5b. NFC with QuickPay on, invoice above threshold → confirmation screen — NFC not in Capabilities
  • 6. Send sheet scanner → NFC read → continues inside the Send sheet — NFC not in Capabilities
  • 7. Cancel the system NFC sheet, or let it time out → no toast, scanner stays open — NFC not in Capabilities
  • 8. Tag with two different requests, or with no readable value → "NFC Read Failed" toast. A tag with one plain-text value goes to the scanner and shows its usual unreadable-code error — NFC not in Capabilities
  • 9. First home screen after update on an NFC iPhone with a wallet → TapPay sheet once. The toggle changes the QuickPay setting and Settings opens QuickPay. The sheet does not reappear after relaunch — NFC not in Capabilities
  • 10. iPad or simulator → no NFC button or intro sheet — NFC availability not in Capabilities
  • 11. With Bluetooth allowed, iPhone Receive (Savings, Spending, Unified) → "Scan or tap to pay" appears. Android scanner near the iPhone → Android opens the request for review — Bluetooth not in Capabilities
  • 12. Android Receive → iPhone scanner pill reads "Scanning QR, NFC & Bluetooth" → iPhone opens the request for review — Bluetooth not in Capabilities
  • 13. iPhone Receive ↔ second iPhone scanner → the request opens for review — Bluetooth not in Capabilities
  • 14. Bluetooth request below the QuickPay threshold with QuickPay on → review screen, no automatic payment — Bluetooth not in Capabilities
  • 15. Settings > Security > Nearby payments off → the iPhone Receive label disappears and other phones no longer find it. Turned on again → it reappears — Bluetooth not in Capabilities
  • 16a. Fresh install, open the scanner → Bluetooth and NFC buttons above a "Scanning QR" pill, no permission prompt. Tap Bluetooth → system prompt. Allow → pill gains "Bluetooth" — Bluetooth permission not in Capabilities
  • 16b. Bluetooth denied → the Bluetooth button opens iOS Settings. Receive shows no label — Bluetooth permission not in Capabilities
  • 17. Camera denied → payment scanner shows "Scan to pay" with camera, Bluetooth and NFC buttons. NFC and Bluetooth still work — Bluetooth/NFC not in Capabilities
  • 18. Two Bitkit phones advertising, one close and one across the room (below -60 dBm) → the close one is read — Bluetooth not in Capabilities
  • 19. Receive → background the app → other phones no longer find it. Foreground → found again — Bluetooth not in Capabilities
  • 20. A nearby phone advertising a non-payment request (for example pubkyauth://… or an LNURL-withdraw) → the iPhone scanner shows the unreadable-code toast, opens nothing, and keeps scanning — Bluetooth not in Capabilities
  • 21. Fresh install, open Receive before ever allowing Bluetooth → no Bluetooth permission prompt and no "Scan or tap to pay" label — Bluetooth permission not in Capabilities
  • 22. With Bluetooth allowed, USDT Receive (Arbitrum) → "Scan or tap to pay" appears. An Android or iPhone scanner nearby opens the USDT send flow for review — Bluetooth not in Capabilities
  • 23. Receive → Edit → back → "Scan or tap to pay" is shown again, and a nearby scanner reads the edited request — Bluetooth not in Capabilities
  • 24. Bluetooth turned off in Control Center, open Receive and a scanner → no system "Turn On Bluetooth" alert — Bluetooth not in Capabilities
  • 25. NFC tag with two different requests or an empty payload → the system NFC sheet shows the refusal reason before closing — NFC not in Capabilities
  • 26. Bluetooth request opens review → cancel the review → back on the scanner, scanning resumes (pill lists Bluetooth) and the same phone is read again after 10 s — Bluetooth not in Capabilities

Automated Checks

  • added NdefPayloadParserTests.swift: URI prefix codes, UTF-8/UTF-16 Text records, absolute URIs, ignored records, duplicates, and conflicting or empty tags
  • added NearbyProtocolTests.swift: UUIDs and constants match the spec, meta encoding, 512-byte chunking up to 4096 bytes, ATT offset reads, round trip, the URI scheme helper, RSSI threshold, 10 s debounce, and pill text by source
  • updated ScannerManagerTests.swift:
    • an NFC read routes like a scanned QR code
    • failed reads end without a route
    • a Bluetooth request routes with QuickPay suppressed
    • the Bluetooth allowlist accepts only payment schemes
    • non-payment payloads and decoded non-payment types (a gift code behind lightning:) are refused and reported as not taken
    • a QR code or NFC read takes over from a Bluetooth request that is still decoding
    • a routed request is reported as taken
    • NFC error messages, including the read-failed message
  • updated NearbyProtocolTests.swift: the advertiser serves each reading phone the request it started with, clears snapshots on stop, and never starts without Bluetooth permission

Evidence

  • Build and unit tests on 11599905d: iPhone 17 simulator (iOS 26), Xcode 26.
    • CI unit selection: xcodebuild test -scheme Bitkit with the CI skip list. Result: 3254 unit tests, 1 skipped, 0 failures. One UI test, HomeHeaderUITests.testHeaderRowTapsOpenHeaderButtonsAndBalanceStillToggles, timed out waiting for the fiat symbol. It passed when re-run alone, and it passed in both earlier full runs, so it looks flaky and unrelated to this change.
    • Targeted tests (NDEF parser, nearby protocol, scanner manager including the allowlist tests, component sizing, USDT receive sharing, shop payment requests): 72 tests, 0 failures.
  • Review rounds after 11599905d: each fix was checked with the targeted classes on the iPhone 17 simulator, and each new test fails without its fix. At d9a0b2a80, ScannerManagerTests and ScannedPaymentRequestTests pass (36 tests), as do AddressTypeSettingsTests and QuickpaySettingsTests (37 tests). The full suite for the current head runs in CI (Run Tests).
  • SwiftFormat lint on the changed Swift files: clean. node scripts/validate-translations.js --warnings: no missing translations for the new keys; the remaining warnings are for keys that already lacked translations on master.
  • Earlier result on 5b510e670: CI unit selection 3247 tests, 1 skipped, 0 failures.
  • Simulator screenshots above were taken before the review fixes, on 5b510e670. They show layout only; no NFC or Bluetooth exchange ran. The review fixes change no layout.

Gaps

  • Not tested on a physical iPhone. Cases 1–26 have not been run. The simulator has neither NFC nor Bluetooth, and no iPhone was available.

  • No cross-platform testing. No payment between an iPhone and an Android phone was tried, over NFC or Bluetooth. The Android twin (feat: nfc and bluetooth nearby payments bitkit-android#1883) was tested only between two Android phones.

  • Android device findings not yet checked here:

    • On Android, a tag that stays in range after a read was delivered again. That needed a fix there.
    • A Lightning payment waited for the node even when Spark could pay it.

    iOS reads tags through a different system flow, so neither may apply, but neither has been checked.

  • The Square Register NFC payload and direction are unpublished and unverified. A capture at a real Register is needed before claiming Square support.

  • Device builds need the NFC Tag Reading capability on the App IDs (see Setup).

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 a reasoning-effort setting.

🤖 Generated with Claude Code

jvsena42 and others added 4 commits November 12, 2026 06:48
Adds a Core NFC NDEF reader with a pure, tested NDEF parser and routes the
tapped request through the normal scanner handling, so QuickPay and the send
flows apply unchanged. Adds the scanner NFC pill, the one-time TapPay intro
sheet, and the NFC entitlement and Info.plist keys.

Part of #1178

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Implements nearby payments v1 from Docs/nearby-payments.md: Receive serves
its request from a GATT server while in the foreground, and the payment
scanners read the closest Bitkit phone at or above -60 dBm. Requests read
over Bluetooth always open the normal review. Adds the scanner source pill
and buttons, the camera-denied scan-to-pay panel, the "Scan or tap to pay"
label and the Nearby payments privacy setting.

Closes #1178

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>
- Accept only payment requests over Bluetooth (bitcoin:, lightning:,
  ethereum:, lnurlp:) and decode them under the payment-requests scope,
  so sign-in, setup, withdraw and contact links are refused.
- Never prompt for Bluetooth from Receive; advertise only when already
  allowed. Suppress the system power alert on both managers.
- Offer the USDT (Arbitrum EIP-681) request on USDT Receive and show the
  label there; resume advertising when Receive reappears.
- Snapshot the request per central, guard against adding the service
  twice, resume scanning when a Bluetooth request was not taken and
  pause it while the scanner is covered.
- Keep the NFC session open to refuse a tag on the system sheet; show a
  read-failed message for transport errors.
- Use @observable for the Bluetooth advertiser and scanner.
- Declare only the TAG NFC reader format (ITMS-90778).
- Translate all new strings.

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 parsing 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>
# Conflicts:
#	Bitkit/ViewModels/AppViewModel.swift
@jvsena42
jvsena42 marked this pull request as ready for review November 16, 2026 17:06
@jvsena42
jvsena42 requested review from a team, ben-kaufman and ovitrif and removed request for a team November 16, 2026 17:06
@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The reviewed changes appear safe to merge; the hidden-Receive advertising issue is fixed.

Summary

Adds NFC payment reads and Bluetooth nearby payments, with scanner controls, Receive advertising, settings backup support, and QuickPay safeguards.

  • Payment scanners can read requests from NFC tags.
  • Nearby phones can exchange payment requests over Bluetooth.
  • Scans stop routing when their payment screen or app lock changes.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    NFC[User starts NFC read] --> Scanner[Shared scanner]
    BLE[Bluetooth request] --> Checks[Payment-only checks]
    Checks --> Review[Normal payment review]
    Scanner --> Payment[Usual payment flow]
    Receive[Visible Receive page] --> Gate{Active and uncovered?}
    Gate -->|Yes| Advertise[Advertise request]
    Gate -->|No| Stop[Stop advertising]
Loading

Reviews (32) · Last reviewed commit: "fix: stop receive advertising under its ..." · Reviewed by Greptile

Comment thread Bitkit/Services/NfcReader.swift Resolved
@jvsena42
jvsena42 marked this pull request as draft November 16, 2026 17:16

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

No findings. Adds NFC tag reading from the payment scanners and Bluetooth LE nearby payments (Receive as GATT server, scanners as central), with QuickPay suppressed for Bluetooth requests. Reviewed 7bcf5b7, full tier, static only: iOS does not build here, so the Swift is reasoned from the code and CI is the gate (Run Tests, Run Integration Tests, SwiftFormat were still pending when I read them).

What I checked, and 4 candidates I ruled out

Read in full: NearbyProtocol.swift, NdefPayloadParser.swift, ScannedPaymentRequest.swift, NearbyPaymentScanner.swift, NearbyPaymentAdvertiser.swift, NfcReader.swift, the ScannerManager.swift diff, Scanner.swift diff, ReceiveQr.swift / UsdtReceiveView.swift diffs, SettingsBackupConfig.swift, Docs/nearby-payments.md
Call sites traced: shouldUseQuickpay (both openPaymentSheet and appropriateSendRoute reach it, so withQuickPaySuppressed covers the main and send paths), handleScannedData with scope .paymentRequests (rejects SamRock, pubky auth, and anything ShopPaymentRequest.isSupported does not accept), processSendScan

Ruled out

  • QuickPay bypass over Bluetooth: every route to .quickpay goes through shouldUseQuickpay, which now checks isQuickPaySuppressed; the counter is held for the whole awaited routing.
  • Mixed chunks when Receive changes mid-read: servedRequest(for:) snapshots per central on the meta read, and the scanner checks the decoded byte count against the announced length.
  • Non-payment URIs over Bluetooth: the scheme allowlist plus the decoded-type check under .paymentRequests refuse withdraw, auth, channel, node and contact payloads before any state is set.
  • Main scanner treats a silently refused Bluetooth request as taken (cold reader: stands, rated P2): when handleScannedData toasts and returns without setting didRejectScannedPayment (expired bolt11, network mismatch, lnurlp: with the node not running), didOpenScanFlow is true, deliver clears onRequest, and Bluetooth stays off until the scanner is reopened. Argued down to P2: no payment state, only a re-scan cost, so not posted.

Merge confidence: 4/5, no findings, but not built here, CI was still pending, and the BLE and NFC paths need a device.

Reviewer model: claude-opus-5-5
Reasoning effort: Not exposed (the runtime does not report it to the reviewer)

@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 — required payment conditions are discarded, and a rejected Bluetooth invoice can stop further reads.

Findings:

  • HIGH — Required conditions disappear. Bitkit/Utilities/ScannedPaymentRequest.swift:24: a reviewer-added regression confirms bitcoin:?lightning=<invoice>&req-foo=bar becomes lightning:<invoice>. The decoder cannot reject the required condition after it has been stripped; NFC can then use the ordinary QuickPay path. This adds evidence to the existing finding. Reject unsupported required parameters before rewriting.
  • MEDIUM — Rejected invoices stop Bluetooth scanning. Bitkit/Managers/ScannerManager.swift:148: an expired Lightning invoice leaves the scanner open with no retained invoice, but handleNearbyRequest returns true. NearbyPaymentScanner.deliver then clears its request handler, so later nearby requests are ignored until the scanner is reopened. The Send-sheet handler correctly returns false for the same input. This reproduces the candidate noted in the static review. Report whether a flow actually opened.

QA for 7bcf5b7:

Tested on an iPhone 17 Pro simulator running iOS 27.0. The main QA used unmodified application source; the two regression checks added XCTest assertions using the existing decoder seam. The TapPay intro check used the debug-only NFC availability hook shown below. No NFC or Bluetooth exchange was simulated or exercised.

Read a Lightning tag ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 1.

Read a unified Bitcoin tag ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 2.

Read an LNURL-pay tag ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 3.

Read a USDT tag ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 4.

Pay a small NFC invoice with QuickPay ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 5a.

Review a large NFC invoice ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 5b.

Read NFC inside Send ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 6.

Cancel or time out an NFC read ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 7.

Reject empty or conflicting NFC tags ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 8.

Show TapPay introduction once ⏭️ Not run: physical NFC eligibility remains unverified; the intro controls and persistence passed with the hook below.

Case 9.

Hide NFC on a simulator ✅ On the simulator, Home showed no TapPay introduction and the scanner showed Scanning QR without an NFC control.

Case 10.

case10-2x.2x.mp4

Receive Bitcoin over Bluetooth from Android ⏭️ Not run: needs a signed test iPhone and an Android phone for the cross-platform Bluetooth exchange.

Case 11.

Read Android Receive over Bluetooth ⏭️ Not run: needs a signed test iPhone and an Android phone for the cross-platform Bluetooth exchange.

Case 12.

Exchange Bluetooth requests between iPhones ⏭️ Not run: needs two physical iPhones.

Case 13.

Review Bluetooth requests with QuickPay enabled ⏭️ Not run: needs a physical Bluetooth peer serving the requested payload.

Case 14.

Turn nearby advertising off and on ⏭️ Not run: The persisted switch value passed separately; stopping and restarting advertising needs physical Bluetooth hardware.

Case 15.

Allow Bluetooth from a fresh scanner ⏭️ Not run: Bluetooth permission prompting and scan activation need a physical iPhone.

Case 16a.

Open Settings after Bluetooth denial ⏭️ Not run: The denied-Bluetooth Settings route needs a physical iPhone.

Case 16b.

Use nearby payment controls without camera permission ⏭️ Not run: The camera-denied layout passed separately; NFC and Bluetooth operation need physical hardware.

Case 17.

Choose the strongest nearby phone ⏭️ Not run: Strongest-device selection needs multiple physical advertisers and controlled distance.

Case 18.

Pause advertising in the background ⏭️ Not run: Background advertising and resumption need physical Bluetooth hardware.

Case 19.

Reject non-payment Bluetooth requests ⏭️ Not run: needs a physical Bluetooth peer serving the requested payload.

Case 20.

Open Receive before Bluetooth permission ⏭️ Not run: Receive before Bluetooth permission needs a physical iPhone with an undetermined Bluetooth permission state.

Case 21.

Receive Arbitrum USDT over Bluetooth ⏭️ Not run: USDT request exchange needs a physical iPhone and a second Bluetooth-capable phone.

Case 22.

Advertise an edited Receive request ⏭️ Not run: Reading the edited advertised request needs physical Bluetooth hardware.

Case 23.

Avoid Bluetooth power alerts ⏭️ Not run: The powered-off Bluetooth alert case needs physical radio state.

Case 24.

Refuse plain text on the NFC sheet ⏭️ Not run: needs a signed NFC-capable test iPhone and a physical tag or emulated tag.

Case 25.

Resume Bluetooth after cancelling review ⏭️ Not run: Bluetooth scanning resumption and the ten-second retry need a physical peer.

Case 26.

Keep the nearby setting after relaunch ✅ Nearby payments was on by default, switched off, and remained off after terminating and relaunching the app.

Simulator subset of case 15.

case15ui-2x.2x.mp4

Show payment scanner controls with the camera denied ✅ With camera access revoked, the main scanner and Send scanner showed Scan to pay and Enable Camera; NFC was hidden on the simulator.

Simulator subset of case 17.

case17ui-2x.2x.mp4

Check: Run nearby parser and scanner unit checks ✅ Pinned-head build and selected NDEF parser, nearby protocol, normalization, ScannerManager and payment navigation XCTest suites passed.
Check: Resume after rejecting an expired Bluetooth invoice ❌ Reviewer-only XCTest injected an expired Lightning invoice: main scanner reported taken although the scanner sheet remained and no invoice was retained. The Send-sheet control correctly reported not taken.
Check: Preserve required NFC payment conditions ❌ Reviewer-only XCTest showed the addressless BIP321 normalization discards req-foo=bar and returns only lightning:, confirming the existing thread.
Use the TapPay introduction once ✅ With NFC availability forced by a debug hook, TapPay enabled QuickPay, Settings led to QuickPay, and TapPay stayed dismissed after relaunch.

Simulator subset of case 9. The Settings action first showed the existing QuickPay introduction; Continue opened settings with QuickPay enabled. The device preferences retained hasSeenNfcIntro and enableQuickpay after relaunch. This does not test physical NFC availability or reading.

case9ui-2x.2x.mp4

Hook used for this case only; not pushed:

diff --git a/Bitkit/Services/NfcReader.swift b/Bitkit/Services/NfcReader.swift
index 3056b256..7d5277cb 100644
--- a/Bitkit/Services/NfcReader.swift
+++ b/Bitkit/Services/NfcReader.swift
@@ -43,7 +43,10 @@ final class NfcReader: NSObject, NfcPaymentReading {
     private var continuation: CheckedContinuation<String, Error>?
 
     var isAvailable: Bool {
-        NFCNDEFReaderSession.readingAvailable
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVIEW_NFC_AVAILABLE"] == "1" { return true } // test hook
+        #endif // test hook
+        return NFCNDEFReaderSession.readingAvailable
     }
 
     func readPaymentRequest(alertMessage: String) async throws -> String {

Physical NFC/Bluetooth exchanges, hardware permission states, and the Figma comparison remain unverified. The simulator checks do not establish physical-device compatibility.

Full review of 79da545…7bcf5b7, all 51 changed files. The existing late-routing finding and plain-text NFC finding remain open.

Pair PR: synonymdev/bitkit-android#1883. Its nearby wire protocol constants and shared document match at 2336ef1; Android ↔ iOS exchange remains unverified. The Android-only physical results in that PR do not validate the iOS paths.



Reviewed by gpt-6.1-sol-high

Comment thread Bitkit/Managers/ScannerManager.swift Resolved
jvsena42 and others added 3 commits November 16, 2026 15: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>
@jvsena42
jvsena42 marked this pull request as ready for review November 16, 2026 18:12
@jvsena42
jvsena42 requested a review from a team November 16, 2026 18:12
@jvsena42
jvsena42 marked this pull request as draft November 16, 2026 18:18
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review November 16, 2026 18:21

@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 0a0d2eb8b, including affected code paths, at 8e4659c9e. Baseline: previous QA review.

No new actionable code findings.

A camera, paste, scanner manual-entry, photo-payload, or Send Enter Manually lookup that is still in flight when the app locks behind the PIN does not route and does not choose QuickPay. The lock generation is captured before the decode await and checked again before a route; Enter Manually also skips the error toast. ScannerManagerTests covers the camera and Send-scanner cases. Enter Manually routing and toast suppression are not driven by a test. Device testing: not performed in this review.

Compared only the lock-during-lookup contract with bitkit-android#1883 at fa0ebe8, not that PR as a whole. Android opens the request for review with QuickPay suppressed. This iOS change drops the route, matching its own comments.

Suggested additional test cases:

  • iOS with PIN on. From the scanner, scan or paste an LNURL or Lightning address. Background the app while it is still resolving, then unlock. Send and QuickPay stay closed, and no error toast appears.
  • iOS with PIN on. Send, Enter Manually, enter an LNURL or Lightning address, and tap Continue. Background the app during the lookup, then unlock. The manual-entry screen remains, with the typed value, no new route, and no error toast.

Earlier findings reconciled at this revision: 2 still present, 12 verified fixed, 2 not substantiated.

Existing concerns

  • [LOW] End NFC scan ownership when its scanner visit ends — Still present. Leaving the scanner makes originCheck fail, so the finished NFC result is not routed, but isHandlingScan stays set until the system NFC session and any in-flight decode return. A new QR, paste, or NFC read then reaches beginUserScan with nearbyScanID nil and is refused. invalidateScansForAppLock bumps lockGeneration without clearing the lock, and Scanner onDisappear stops only Bluetooth. The commits since 0a0d2eb do not change handleNfcRead or handleSendNfcRead. Issue #1400 is open. The report is the review body #1302 (review); the author scoped it out of this PR in #1302 (comment). No material new evidence.
  • [MEDIUM] Confirm the Bluetooth recipient before paying — Still present. connectToStrongest picks the highest-RSSI eligible advertiser, with no recipient choice or confirmation, and hands its invoice to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes. That review does not identify the intended receiver. Docs/nearby-payments.md specifies strongest-advertiser selection. NearbyPaymentScanner.swift is unchanged since 0a0d2eb. Issue #1401 is open and links the Android twin synonymdev/bitkit-android#2005. The report is #1302 (review); the author moved it to that issue in #1302 (comment). No material new evidence.

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:

No new findings in the delta. The physical iPhone check required by the PR remains open.

QA for 8e4659c:

Check: Scanner, NFC and QuickPay regressions ✅ All 408 selected XCTest cases passed on the unmodified build.

The selection included both scanner lock guards, NFC parsing and toast presentation, Bluetooth QuickPay suppression, and opening review on the Send screen attached by a same-invoice rescan.

Discard a pasted payment request from before a PIN lock ✅ The Home and Send scanners stayed open after unlock, and a fresh paste reached Send in both.

A debug hold paused a regtest Bitcoin request at the shared decoder boundary used by LNURL and Lightning-address lookups. The routing log showed the stale result was discarded and confirmed the fresh recipient.

scanner-lock2x.2x.mp4

Discard a manual payment lookup from before a PIN lock ✅ Enter Manually stayed open after a held success and a held connection error, and a fresh Continue reached Send.

The state log showed no stale recipient or toast. Debug controls held the lookup and supplied the connection error.

manual-lock2x.2x.mp4

Open a payment from the native Photos picker ✅ Selecting the verified QR opened Send for its regtest recipient using CPU-only Vision.

The unmodified iOS 26.5 simulator build selected the same image and Apple Vision reported that it could not create its inference context. The replay used Vision revision 1 on the CPU, and the routing log confirmed the recipient.

native-photo-import2x.2x.mp4

Keep photo priority within its scanner visit ✅ Leaving and reopening a scanner discarded its old photo, and nearby delivery waited for a photo still pending on the current visit.

Replayed Send Options after Enter Manually and Back, a reopened full-screen scanner, and two overlapping photo decodes. Debug controls held the decodes and supplied nearby requests. The routing logs confirmed which recipients opened.

send-options-photo-ownership2x.2x.mp4

reopen-full-scanner-photo2x.2x.mp4

concurrent-photo-ownership2x.2x.mp4

Require a swipe after QuickPay is interrupted by a PIN lock ✅ Confirm opened after unlock, and the manual swipe paid 1,000 sats once over LDK on regtest.

A debug hold paused QuickPay just before submission. The app log confirmed the reservation was released. The Lightning receiver reported the invoice open and unpaid after unlock, then settled for 1,000 sats after the swipe.

quickpay-background-swipe2x.2x.mp4

quickpay-swipe2x.2x.mp4

Manual cases 1–9 and 11–26 still need a provisioned NFC or Bluetooth iPhone and the relevant tags, terminals or peers for complete coverage. Prior hardware runs covered portions of cross-platform BTC payments, NFC cancellation and retry, edited Receive amounts, Bluetooth lifecycle, and USDT discovery. Physical QA at d9a0b2a · Physical QA at 594cbab

The no-NFC simulator behavior in manual case 10 was previously verified and its availability check is unchanged. Simulator QA at b38dbf1

Reviewed all seven delta files and rechecked the stopped QuickPay rescan. XCTest and source inspection covered the NFC wrapper and toast changes. The simulator replay settled over LDK. Spark's pre-submission checks ran in XCTest. 04fe5fb to 8e4659c · QuickPay rescan thread · Current-head QA review

Twin synonymdev/bitkit-android#1883 matches the nearby wire format and lowercase-only wrapper handling. Android opens review for a request that finishes after a PIN lock with QuickPay suppressed. iOS discards that result. Android twin


Reviewed by gpt-6.2-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

@pwltr pwltr 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.

Consider separating scanner input handling from presentation so QR, NFC and Bluetooth share one check for whether the originating screen is still active.

Reviewed 8e4659c against f17214e.

Low: An addressed Bitcoin request with a literal lightning: in its label or message fails over NFC and Bluetooth. Bitkit/Utilities/ScannedPaymentRequest.swift:33 passes the URI through, and the checks at Bitkit/Managers/ScannerManager.swift:368 and Bitkit/Managers/ScannerManager.swift:473 allow it. BitkitCore 045c7ff then treats the whole URI as a BOLT11 invoice, so the payer never reaches review. Add this case to the existing decoder coverage and match the payment scheme at the start of the request.

Low candidate: An NFC read may display its error after the user has left the scanner or the app has locked. Bitkit/Managers/ScannerManager.swift:479 and Bitkit/Managers/ScannerManager.swift:483 post errors before the originating-visit checks at Bitkit/Managers/ScannerManager.swift:324 and Bitkit/Managers/ScannerManager.swift:343. Apply the same visit check to error feedback. A non-silent Core NFC result needs to arrive after the visit ends for the stale toast to appear.

Low: Remove the direct RSSI and size assertions at BitkitTests/NearbyProtocolTests.swift:13 and BitkitTests/NearbyProtocolTests.swift:14. The existing tests already check both sides of those boundaries through scanner eligibility and request encoding.

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Cross-project review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: high

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

Copy link
Copy Markdown
Member Author

@pwltr Thanks for the approval. Your review of 8e4659c, at 6eafe92:

  1. Low, lightning: in a label or message: out of scope, tracked in Scanner decodes a bitcoin: URI as Lightning when a value contains lightning: bitkit-core#227. bitkit-core's Scanner::decode takes the Lightning branch when the text contains lightning:. That is on core master too, and QR and paste scans fail the same way today. NFC and Bluetooth only pass the request through, so the fix belongs in the decoder: match the scheme at the start.
  2. Low candidate, NFC error after the visit ends: confirmed and fixed in 6eafe92. readNfcPaymentRequest now shows its error, NfcReadError or other, only while the caller's visit check (isStillCurrent: visit, presentation, path generation, lock) still holds. testNfcReadErrorAfterTheScannerVisitEndsShowsNoToast failed before the fix: the stale toast appeared. testFailedNfcReadCompletesWithoutRoute still checks the toast on a current visit. The Core NFC sheet only makes the app inactive, so it doesn't end the visit by itself.
  3. Low, RSSI and size assertions: kept. They pin the shared nearby spec values (-60 dBm, 4096 bytes) next to the UUIDs, which Android must match. The behaviour tests check what follows from those values, not the values themselves. The UUID line I removed earlier was a literal duplicate of the array check.

Tests: 80/80 in ScannerManager and PaymentNavigationHelper tests. Nothing was run on a device.

@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:

No new findings. Both NFC entry points now suppress app error toasts from an earlier scanner visit or PIN-lock generation. Original review · Author follow-up

QA for 6eafe92:

Check: Show NFC errors only while the originating scanner is active ✅ All 90 selected XCTest cases passed on the unmodified iOS 27.0 simulator build.

The selection covered a late Send NFC failure, active-visit error feedback, quiet cancel and timeout, and scanner routing and ownership.

Check: Discard a held NFC error after the scanner closes or the app locks ✅ Home and Send suppressed late app toasts while an active scanner still showed the expected error.

Three temporary XCTest cases held the reader result across a Home scanner close and reopen or a Send scanner lock. They used an injected NFC reader with the app source at 6eafe92.

Manual cases 1–9 and 11–26 need physical NFC or Bluetooth hardware, with the relevant tags, terminals or peers. Earlier iPhone and Galaxy runs covered parts of those cases, including BTC payments, NFC cancellation and retry, edited amounts, Bluetooth lifecycle and USDT discovery. Physical QA at d9a0b2a · Physical QA at 594cbab

Case 10's NFC availability check carries forward from the earlier simulator run. The previous simulator report also covers paste, manual entry, Photos and QuickPay. Case 10 at b38dbf1 · Simulator QA at 8e4659c

Reviewed both files in the 8e4659c to 6eafe92 delta. XCTest exercised the app toast path. Error presentation on the system NFC sheet still needs hardware.

The Android twin matches the shared NFC and Bluetooth wire formats. The app toast guard here is specific to the iOS reader session. synonymdev/bitkit-android#1883


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 8e4659c, including affected code paths, at 6eafe92. Baseline: previous review. Base and merge base are unchanged (f17214e), and the previous head is an ancestor of the current head. The update is one commit that changes ScannerManager.swift and ScannerManagerTests.swift. Coverage of the rest of the PR is inherited from the baseline.

No new actionable code findings.

What changed: readNfcPaymentRequest now takes the caller's visit check. handleNfcRead and handleSendNfcRead pass isStillCurrent, which is the caller's check plus originCheck. originCheck covers task cancellation, the active sheet's presentation, navigation path generation and lock generation. An NFC failure toast, or a generic error toast, now shows only while that check holds. A read that ends after the payer left the scanner, the sheet was replaced, or the app locked is logged and nothing is shown. Routing behavior is unchanged: a failed read still completes with nil on Send.

Why in-visit errors still show: the PIN lock (invalidateScansForAppLock) runs only when the app goes to the background (AppScene.swift). The iOS NFC system sheet only makes the app inactive, and the NFC read runs in an unstructured Task. So a read that fails while the user is still on the scanner keeps its toast, and the existing testFailedNfcReadCompletesWithoutRoute expectations still hold.

New test: testNfcReadErrorAfterTheScannerVisitEndsShowsNoToast holds a strong AppViewModel reference (the scanner stores app strongly). At the previous head it would have shown the noPaymentRequest toast, so it does test the change. The generic, non-NfcReadError branch has no dedicated test; it is a two-line mirror of the tested branch.

Parity: compared at the read-only pin of bitkit-android#1883 (dcabb9d). Android reads NFC through NfcReaderEffect, which is tied to the scanner composable and stops while the scanner is paused or gone (NearbyScanSources.kt). Its unreadable-tag toast therefore cannot arrive after the scanner visit either. The outcome matches; only the mechanism differs.

Limitations: source analysis only. No app build or test run was possible: only a Linux Swift toolchain is available, which cannot build this iOS app. The new call sites pass a local function as a non-escaping closure, the same way the existing processScan(isCurrent: isStillCurrent) call does. Device testing was not performed in this review.

Suggested additional test cases:

  • iOS, PIN enabled, physical device with NFC. Open the Send scanner and tap NFC. While the system NFC sheet is up, background the app until it locks, then return and unlock. Expected: no NFC error toast appears after unlock, and no payment flow opens.
  • iOS, physical device. On the main scanner, start an NFC read and hold a tag with no payment request. Expected: the NFC error toast still appears (the in-visit failure is unchanged).

Earlier findings reconciled at this revision: 3 still present, 8 verified fixed, 2 not substantiated.

Existing concerns

  • [LOW] End NFC scan ownership when its scanner visit ends — Still present at 6eafe92. handleNfcRead and handleSendNfcRead take isHandlingScan through beginUserScan before the system NFC session starts, and clear it only in a defer when the function returns, after readNfcPaymentRequest (and any decode) finishes. Leaving the scanner makes isStillCurrent fail, so the late result is neither routed nor (new in 6eafe92) toasted, but the lock stays held. A new QR, paste or NFC read that reaches beginUserScan while nearbyScanID is nil is refused. invalidateScansForAppLock bumps lockGeneration and does not clear the lock, and Scanner onDisappear stops only Bluetooth. The only change since 8e4659c (6eafe92 'fix: drop an nfc read error once its scanner visit ended') passes isStillCurrent into readNfcPaymentRequest to gate the error toast. It does not change the lock lifetime. Introduction stays 'worsened': at the merge base f17214e only camera/paste held this lock and no NFC read existed. The PR adds NFC reads that hold it for the whole system session. Already tracked in open issue #1400. The original report is #1302 (review), and the author scoped it out in #1302 (comment). There is no material new evidence, so it should be referenced as an existing concern and not re-published.
  • [MEDIUM] Confirm the Bluetooth recipient before paying — Still present at 6eafe92. connectToStrongest picks the highest-RSSI eligible advertiser, with no recipient choice or confirmation, and hands its request to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes, but that review does not identify the intended receiver. Docs/nearby-payments.md specifies strongest-advertiser selection. NearbyPaymentScanner.swift and the doc are unchanged since 8e4659c, which only touched ScannerManager.swift and ScannerManagerTests.swift. Already tracked in open issue #1401, which links Android synonymdev/bitkit-android#2005. The original report is #1302 (review), and the author moved it to that issue in #1302 (comment). There is no material new evidence, so it should be referenced as an existing concern.
  • [LOW] Addressed bitcoin: request with a literal lightning: in its label fails over NFC and Bluetooth — Mechanism confirmed by source analysis. ScannedPaymentRequest.normalized returns any addressed bitcoin: URI unchanged. isNearbyPaymentRequest admits a bitcoin: URI unless it has a req- key or a non-BOLT11 lightning= pair, so a label or message containing a literal 'lightning:' passes. Both NFC and Bluetooth then pass the URI to the shared decoder. The pinned bitkit-core 045c7ff (unchanged between base and head in Package.resolved) checks contains("lightning:") before the bitcoin: branch and decodes the whole URI as a Lightning invoice. Decoding fails and the payer never reaches review. No funds move. The same input already fails over QR/paste at the merge base, so the PR does not create the decoder defect. It makes the failure reachable from two new inputs (NFC tags and nearby Bluetooth receivers), hence 'worsened'. The author scoped the fix to the decoder and tracks it in synonymdev/bitkit-core#227 (open), which is in another repository, so tracked_separately does not apply. This is already reported in the cited review with no material new evidence, so it should be referenced, not re-published.

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

@pwltr pwltr 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.

Reviewed 6eafe92 against f17214e.

Low: An addressless Bitcoin request read over NFC can open BTCPay setup from either the main scanner or Send Options. With no outer amount, Bitkit/Utilities/ScannedPaymentRequest.swift:55 promotes the Lightning field without checking that it contains an invoice. Both NFC callers (Bitkit/Managers/ScannerManager.swift:325, Bitkit/Managers/ScannerManager.swift:347) can then reach the setup handler at Bitkit/ViewModels/AppViewModel.swift:1031. The payer lands on a connection screen and must still confirm separately to connect. Validate the field before promoting it.

Low: The status pill at Bitkit/Components/Scanner.swift:284 is an enabled button even when Bluetooth permission is still needed or NFC is unavailable. Activating it does nothing in those states, including through VoiceOver. Expose the same pill as static status when it has no NFC action.

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: high

@piotr-iohk

Copy link
Copy Markdown
Collaborator

@jvsena42 please resolve conflicts.

jvsena42 and others added 2 commits November 25, 2026 05:53
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. Merged master in 7e9881e: in QuickPayPaymentCoordinator.init both sides stay (the submission check and master's needsUpdateToSend recheck), and the nearby request now checks the Receive tab is shown, since master removed the Spending onboarding. 54d7c2f moves one test to the node path, because master now refuses Spark sends while Spark can't list. The affected test classes pass (287 tests), and an independent review of the merge found no defects.

@pwltr pwltr 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.

Consider reworking nearby payment parsing so validation and payment routing use the same interpretation of the URI.

Reviewed 54d7c2f against d9cf874. Both guards split Bitcoin queries on Swift Character boundaries. A combining mark immediately after ? makes the delimiter part of a larger character. Both guards then miss the query, while BitkitCore splits on the literal ? and reads the later fields.

Medium: A nearby advertiser can make a Bluetooth-authorized payment scanner resolve a nested Lightning address before the payer chooses a request. The empty-query fallback bypasses invoice validation in Bitkit/Managers/ScannerManager.swift:369. The regular payment scanner and Send Options then resolve the nested address in Bitkit/ViewModels/AppViewModel.swift:1094, exposing request timing and source network information to the endpoint.

Low: A malformed request received over NFC or Bluetooth can still open review with an unsupported req- parameter. Bitkit/Utilities/ScannedPaymentRequest.swift:116 misses the required key, and a payer who approves the on-chain invoice can pay without satisfying the required term. Extend the existing lookup and required-parameter refusal tests to cover this delimiter case.

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: 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 54d7c2f, re-reviewed after the comparison base changed (f17214e → d9cf874), with target-branch changes touching files this PR changes. No coverage was carried over from earlier reviews.

No new actionable code findings.

Every changed surface was traced at the pinned head: NFC reading and NDEF parsing, the Bluetooth sending and receiving sides and their protocol, the Bluetooth request filter and the rewrite of addressless bitcoin:?lightning= requests, scan-lock handover between Bluetooth, camera QR, NFC and photo scans, PIN-lock checks (scan lock generations, cancelling a pending sheet replacement, QuickPay lock checks, the stop just before submission), QuickPay suppression, the Receive and USDT Receive advertising conditions, the scanner status pill and permission states, the TapPay intro sheet, the Nearby payments setting with its backup and restore, entitlements and Info.plist, and translations.

Validation:

  • Source analysis: QuickPay is decided synchronously in openPaymentSheet / appropriateSendRoute while a Bluetooth request's suppression is held, and no Send screen re-decides it later. A user scan that takes over from a Bluetooth request still decoding cancels the Bluetooth decode through the scanned-data ownership check in AppViewModel.handleScannedData. Scanning and Receive advertising cannot run behind the PIN screen, because MainNavView is unmounted while locked.
  • Dependency check: bitkit-core 0.8.0-rc15 @ 045c7ff (the version the app pins exactly) was fetched and its Scanner::decode read. bitcoin: and ethereum: inputs accepted by isNearbyPaymentRequest cannot reach the decoder's LNURL or Lightning-address network lookup, and the app decodes a unified URI's lightning value only after the local BOLT11 check.
  • Executed probe (Swift 6.4.2 on Linux, using the PR's ScannedPaymentRequest.swift, NdefPayloadParser.swift and PosNfcFixtures.swift plus isNearbyPaymentRequest copied unchanged): the Square/Numo fixtures pass; LNURL, Lightning-address, wrapped req- and unified-with-req- inputs are refused; a mismatched amount keeps the URI addressless. This checks the pure helpers only, not an app build or runtime behavior.
  • CI at this head: build-local, SwiftFormat and validate passed; Run Tests and Run Integration Tests were still in progress when checked.

Parity with synonymdev/bitkit-android#1883 (pinned at bca0fa0; only these shared contracts were compared, not a full review): the Bluetooth service and characteristic UUIDs, the 3-byte meta format, 512-byte chunks, the 4096-byte limit and the -60 dBm threshold are identical. The backup key maps to Android's isNearbyPaymentsEnabled, which defaults to on on both platforms. The Bluetooth filters lead to equivalent outcomes: Android refuses a bitcoin: URI without a valid network address before decoding, while iOS lets the decoder fail with the same error toast.

Non-blocking consistency suggestions:

  • The PR says Docs/nearby-payments.md is identical to the Android copy, but the iOS copy has an extra final paragraph about which requests Bluetooth accepts (BOLT11/USDT only; LNURL, Lightning addresses and BOLT12 refused) that Android's docs/nearby-payments.md lacks at bca0fa0. Both apps behave that way, so syncing the text is enough.

Limitations:

  • Device testing was not performed in this review; the simulator has neither NFC nor Bluetooth, and no iPhone ↔ Android exchange has been run by anyone (author's Gaps).
  • Unverified on a device: when Bluetooth permission is first requested from the scanner, the app goes inactive and Scanner calls nearby.stop(), dropping the Bluetooth manager while the system prompt is up. Scanning should restart when the app becomes active again; the author's case 16a covers this.
  • The PR description mixes requirements with write-ups of earlier review fixes, so discovery was not fully blind to that discussion.

Suggested additional test cases:

  • iOS + Android: Android Receive advertising nearby. On the iPhone scanner, open the photo picker and wait over 10 s, then pick a photo of a different QR invoice. Expected: nothing opens behind the picker, and the photo's invoice opens rather than the Bluetooth one.
  • iOS hardware-wallet send (Send sheet with a connected hardware wallet), with a nearby phone advertising a Lightning-only lightning: invoice. Expected: no Lightning flow opens; the on-chain-only error toast appears and Send stays on Options.
  • iOS Receive on the Hardware tab with Bluetooth allowed: "Scan or tap to pay" appears, and a nearby scanner opens the hardware-wallet bitcoin: request for review.
  • Restore an Android settings backup with Nearby payments off onto iOS. Expected: Security > Nearby payments is off and Receive shows no "Scan or tap to pay" label.

Earlier findings reconciled at this revision: 5 still present, 4 verified fixed, 1 not substantiated.

Existing concerns

  • [LOW] End NFC scan ownership when its scanner visit ends — Still present at 54d7c2f. handleNfcRead and handleSendNfcRead take isHandlingScan through beginUserScan before the system NFC session starts. They clear it only in a defer when the function returns, after readNfcPaymentRequest and any decode. Leaving the scanner makes isStillCurrent fail, so the late result neither routes nor shows a toast, but the lock stays held. A new QR, paste or NFC read that reaches beginUserScan while nearbyScanID is nil is refused. invalidateScansForAppLock bumps lockGeneration and cancels the pending route replacement without clearing the lock. Scanner onDisappear stops only Bluetooth. Since 6eafe92, ScannerManager.swift, NfcReader.swift and Scanner.swift are unchanged; the base moved to d9cf874 through a master merge that does not touch these paths. Already tracked in open issue #1400, and the author scoped it out of this PR (#1302 (comment)). Original report: #1302 (review). No material new evidence: list it as an existing concern, do not publish it again.
  • [MEDIUM] Confirm the Bluetooth recipient before paying — Still present at 54d7c2f. connectToStrongest picks the eligible advertiser with the strongest signal, without letting the payer choose or confirm the recipient, and hands its request to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes, but that review does not identify the intended receiver. Docs/nearby-payments.md specifies strongest-advertiser selection. NearbyPaymentScanner.swift and the doc are unchanged since 6eafe92. Already tracked in open issue #1401, which links Android #2005. The author moved it there in #1302 (comment). Original report: #1302 (review). No material new evidence: list it as an existing concern.
  • [LOW] Addressed bitcoin: request with a literal lightning: in its label fails over NFC and Bluetooth — Still present at 54d7c2f. An addressed bitcoin:?label=...lightning:... request read over NFC or Bluetooth is passed through ScannedPaymentRequest.normalized unchanged. isNearbyPaymentRequest admits it because only lightning= values are checked. AppViewModel then passes the raw URI to bitkit-core decode. At the pinned core revision 045c7ff, which I fetched into the workspace, Scanner::decode takes the Lightning branch whenever the text contains 'lightning:', so decoding fails and the payer never reaches review. The author scoped it to bitkit-core#227 (#1302 (comment)); that issue is open, and Package.resolved still pins 0.8.0-rc15 at 045c7ff. Classified as worsened because the PR makes the existing decoder behaviour reachable from NFC tags and nearby devices. Original report: #1302 (review). No material new evidence: list it as an existing concern.
  • [MEDIUM] Stop Receive advertising from restarting while a pushed route hides the QR — Raised by Greptile on the current head; the thread is unresolved and has no author reply. ReceiveQr is the root of the Receive NavigationStack. Pushing Edit (or another ReceiveRoute) calls onDisappear, which stops the advertiser, but the root view and its onChange(of: scenePhase) and onChange(of: nearbyRequest) handlers stay mounted. updateNearbyAdvertising restarts advertising whenever scenePhase is active and nearbyRequest is non-nil. Neither nearbyRequest nor updateNearbyAdvertising checks that the QR is visible or that navigationPath is empty. Trigger: with Receive showing a request, tap Edit, then make the app inactive and active again (Control Center, or background without PIN), or let the request change while Edit is open. Consequence: a nearby payer's scanner can receive and open the old request while the receiver is replacing it, and no 'Scan or tap to pay' label is on screen. This contradicts the code's own stated rule (ReceiveQr.swift:458-460: 'Only a request the payer can check on screen is offered'). The payer still reviews before paying. Expected: advertise only while the QR is visible, for example by tracking visibility in onAppear/onDisappear or requiring navigationPath.isEmpty. Basis: source analysis. It depends on SwiftUI keeping a NavigationStack root mounted and delivering environment/onChange updates while a route is pushed; that was not run on a device or simulator. A focused issue search returned no match.
  • [LOW] Expose the scanner status pill as static text when it has no NFC action — Still present; pwltr's review has no author reply. The status pill is always an enabled Button. Its action returns immediately unless sources.nfc is true, and sources.nfc is false when NFC is unavailable or while the Bluetooth permission buttons are shown. In those states, tapping the pill, or activating it with VoiceOver, which announces a button, does nothing. Expected: render it as static status, or mark it disabled / drop the button trait, when there is no NFC action. Basis: source analysis. A focused issue search returned no match.

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

jvsena42 and others added 3 commits November 25, 2026 07:43
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

@pwltr Thanks. Both findings reproduced and are fixed in 6e2de6c.

isNearbyPaymentRequest, hasRequiredParameter and normalized now split the query on Unicode scalars (ScannedPaymentRequest.queryFields, hasLiteralPrefix), so the literal ?, & and = separate fields as in bitkit-core even when a combining mark follows them. Validation and routing now read the same fields.

  • Medium, nested Lightning address over Bluetooth: fixed. Before the fix, testNearbyRequestDoesNotResolveAnLnurlBeforeReview failed on bitcoin:?\u{301}&lightning=alice@example.com: Bluetooth discovery alone started a decode. Both that test and testNearbyAllowlistAcceptsPaymentSchemesOnly now refuse it, and bitcoin:bcrt1q?amount=0.1&\u{301}&lightning=LNURL… too.
  • Low, missed req- key: fixed. testNearbyRequestWithARequiredParameterIsRefused and testDelimiterFollowedByACombiningMarkStillSplitsTheQuery cover ?\u{301}&req-pop=… and &\u{301}&req-pop=…, and the normalized rewrite of bitcoin:?lightning=<invoice>&\u{301}.

These tests failed before the fix (4 failures) and pass after it. ScannerManagerTests, ScannedPaymentRequestTests and ReceiveNearbyOfferTests pass (70 tests). An independent review found no other place on the NFC or Bluetooth path where Swift's Character reading and core's byte reading disagree on a request.

Twin: Android is not affected. Kotlin strings split on UTF-16 code units, so a combining mark does not join the delimiter.

@jvsena42

Copy link
Copy Markdown
Member Author

@piotr-iohk Thanks. The doc is synced: bitkit-android 7ebf6ef19 adds the paragraph listing which requests Bluetooth accepts, so both nearby-payments.md copies are identical again. The Greptile finding you listed as Medium is fixed in 62b07d3 and 3c26e98; details are in its thread. pwltr's parsing findings are fixed in 6e2de6c.

@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 head advanced before the Receive UI replays.

The PR moved to 3c26e98 after this run; these results are for 62b07d3.

Reviewed 62b07d3. The PR advanced to 3c26e98 during this run; these results apply to 62b07d3.

Findings:

  • MEDIUM — Apply the visibility guard to USDT Receive too (Bitkit/Views/Wallets/UsdtReceiveView.swift:101). With Bluetooth allowed and an eligible Paykit contact, open the USDT Receive QR, tap the header's Request Payment button, then reactivate the app while Choose recipient covers the QR. The retained USDT view still has page == .address; its scene observer calls updateNearbyAdvertising, which checks neither visibility nor the Receive navigation path and can serve the hidden request again. The Bitcoin guard added in 62b07d3 does not cover this sibling. This extends the existing hidden-Receive finding. Verified by source tracing; the USDT runtime case was not driven.

The Unicode delimiter fixes now check the same literal fields as bitkit-core. This addresses the two parsing findings in the previous review.

QA for 62b07d3:

Check: Reject nearby requests that hide fields behind Unicode combining marks ✅ The exact-head regression selection and generated parser checks passed.

The unmodified app and test target built on the iOS 27.0 simulator. Scanner, NFC normalization, nearby protocol, Receive eligibility and QuickPay tests passed. A separate Swift probe used the unchanged parser and filter with combining-mark variants and generated queries, comparing query fields with a byte-delimiter reference. SwiftFormat passed for the latest changed Swift files.

Keep nearby advertising stopped while editing a Receive request ⏭️ The head advanced before this UI replay started.

The new Bitcoin visibility and navigation guards were inspected and their helper tests passed. The real view's Edit, reactivation and return-to-QR wiring was not driven at this head.

Keep USDT nearby advertising stopped behind the recipient picker ⏭️ The sibling path was traced in code; the head advanced before a runtime replay.

Physical NFC/Bluetooth portions of manual cases 1–9 and 11–26 were left out because they require provisioned test iPhones, tags, terminals or peers. Earlier physical reports prove portions of BTC payments, NFC cancel/timeout recovery, changed amounts, Bluetooth lifecycle and USDT discovery at their recorded revisions:

Manual case 10's simulator NFC availability behavior is unchanged and retains its earlier evidence. The 8e4659c simulator report covers unchanged photo-visit and PIN-lock scanner behavior; QuickPay's merged paths were checked in the current XCTest selection.

Covered the contiguous 6eafe92 to 62b07d3 delta, open feedback and the master-merge interactions in QuickPay and Receive. No device case drove the new delimiter or visibility code; XCTest and source inspection covered them.

Twin synonymdev/bitkit-android#1883 matches the wire format and Bluetooth allowlist. Kotlin's delimiter splitting already treats combining marks separately; its Receive advertiser follows the navigation entry lifecycle.


Reviewed by gpt-6.1-sol-high

@pwltr pwltr 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.

Reviewed 3c26e98 against d9cf874.

The Receive advertisers use parent screen state that can stay eligible after the payment QR is hidden. Tie both advertisers to whether their QR is visible, including when a route or a sheet covers it.

Low: Show Details hides the QR on Bitcoin and USDT while Bluetooth can still serve the request. On Savings and Hardware, that can include the amount and note while the details show only the address. USDT can still serve the requested amount. Bitkit/Views/Wallets/Receive/ReceiveQr.swift:472, Bitkit/Views/Wallets/UsdtReceiveView.swift:82

Low candidate: The native Share sheet can leave either request readable if the Receive view stays active underneath it. USDT can also restart advertising if the app reactivates while the Paykit recipient picker covers the QR and the retained view receives the scene update. Bitkit/Views/Wallets/Receive/QrArea.swift:77, Bitkit/Views/Wallets/Receive/ReceiveQr.swift:509, Bitkit/Views/Wallets/UsdtReceiveView.swift:76

Low: The NFC error-message test repeats the production lookup keys, and the failed-read test leaves out the transport failure. Add .failed to the existing failed-read test and check the toast it presents. BitkitTests/ScannerManagerTests.swift:429, BitkitTests/ScannerManagerTests.swift:1290

Review details

Quick review
Model: Claude Opus 5.5
Reasoning effort: high

General review
Model: GPT-6.2 Sol
Reasoning effort: high

Combined review
Model: GPT-6.2 Sol
Reasoning effort: high

@jvsena42

Copy link
Copy Markdown
Member Author

@pwltr Thanks for the approval. All three Low findings are moved to #1428 so the PR can merge: advertising while Show Details, the Share sheet or the Paykit picker hides the QR (Bitcoin and USDT), and the NFC error-toast tests. The issue notes the Android check as well.

@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 54d7c2f, including affected code paths, at 3c26e98. Baseline: previous review. Coverage of the parts this update leaves unchanged carries over from that baseline. The merge base is the same and the PR touches the same files.

Code review completed with unverified earlier concerns.

The update has three commits: Bluetooth request queries are now split the way the decoder splits them, and receive advertising stops while the QR page is covered or no longer on screen.

Query splitting. The new helpers split on the literal ? and & characters and compare prefixes character code by character code. These are queryFields, hasLiteralPrefix and droppingLiteralPrefix in ScannedPaymentRequest. Their output matches how bitkit-core 0.8.0-rc15 (045c7ff6, scanner/implementation.rs, split_once('?') / split('&')) splits the query. A combining accent right after a delimiter therefore no longer hides a req- field or a lightning= value from the Bluetooth filter or from normalized. I checked this with a standalone swiftc probe of the three helpers on Linux, run on the PR's test inputs. It confirmed the split and showed that the old Character-based split missed req-pop after ?\u{301}. The probe is not an app build or a unit-test run.

Receive advertising. ReceiveQr now advertises only when the QR page is shown, nothing covers it and the app is active. Edit or Paykit request screens pushed on the navigation path, the passphrase prompt and the Trezor pairing sheet all count as covering it. ReceiveQr is only ever the starting screen of the Receive sheet, so an empty navigation path correctly means the QR page is not covered. The sheet already gets TrezorManager, so the new environment read is safe. Android ties advertising to the QR screen and the app being in the foreground in the same way (NearbyEffects.kt at bitkit-android 7ebf6ef1). I did not do a cross-platform runtime comparison.

Validation and limits. I read the unit tests added in this update (ReceiveNearbyOfferTests, ScannedPaymentRequestTests, ScannerManagerTests) but did not run them: there is no Xcode or simulator in this environment. Whether advertising restarts after an interactive swipe back from Edit depends on when SwiftUI fires onAppear and onDisappear on the starting screen. Source code cannot settle that, so it is left to the runtime check below.

Device testing: not performed in this review.

Suggested additional test cases

  • iOS, Nearby payments on, Receive open on Savings with a second phone scanning over Bluetooth: open Edit, then swipe back to the QR. Expected: the payer stops seeing the request while Edit is open and sees it again (with any edited amount) after swiping back. Repeat with a cancelled half-swipe; the request must stay hidden while Edit remains open.
  • iOS, hardware-wallet Receive tab with a Trezor that needs a passphrase or pairing code: start address verification so the passphrase or pairing sheet appears. Expected: the request disappears from the paying phone while the sheet is up and comes back after the sheet closes.

Earlier findings reconciled at this revision: 7 still present, 3 verified fixed, 1 could not be verified.

Reconciliation incomplete: the following earlier concerns remain unverified. This report does not establish that they are fixed or invalid, or establish approval or device readiness.

Could not verify earlier concern — Receive request may stay readable under the native Share sheet: The reviewer marked this a candidate. Source shows QrArea presents ShareSheet through .sheet, and neither QrArea's share state nor any scene change is an input to isQrCovered or the USDT nearbyRequest. A presented sheet does not fire onDisappear on the presenter, so advertising continues. Whether that is a defect depends on runtime facts source cannot settle: how much of the QR the system share sheet covers, and whether presenting UIActivityViewController changes scenePhase. The shared content is also the same request being advertised. Without a device the consequence cannot be established. Moved by the author to open issue #1428.

Existing concerns

  • [LOW] End NFC scan ownership when its scanner visit ends — Still present at 3c26e98. handleNfcRead and handleSendNfcRead take isHandlingScan through beginUserScan before the system NFC session starts, and clear it only in a defer when the function returns, after readNfcPaymentRequest and any decode. Leaving the scanner makes isStillCurrent fail, so the late result is neither routed nor toasted, but the lock stays held. A new QR, paste or NFC read that reaches beginUserScan while nearbyScanID is nil is refused. invalidateScansForAppLock bumps lockGeneration and cancels the pending route replacement without clearing the lock, and Scanner onDisappear stops only Bluetooth. The three commits since 54d7c2f change only isNearbyPaymentRequest in ScannerManager.swift; NfcReader.swift and Scanner.swift are unchanged. Tracked in open issue #1400; the author scoped it out of this PR (#1302 (comment)). Original report: #1302 (review). No material new evidence: reference it as an existing concern, do not publish it again.
  • [MEDIUM] Confirm the Bluetooth recipient before paying — Still present at 3c26e98. connectToStrongest picks the eligible advertiser with the strongest signal, without letting the payer choose or confirm the recipient, and hands its request to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes, but that review does not identify the intended receiver. NearbyPaymentScanner.swift is unchanged since 54d7c2f. Tracked in open issue #1401, which links Android #2005; the author moved it there in #1302 (comment). Original report: #1302 (review). No material new evidence: list it as an existing concern.
  • [LOW] Addressed bitcoin: request with a literal lightning: in its label fails over NFC and Bluetooth — Still present at 3c26e98. The new literal-delimiter helpers do not change this: normalized still returns an addressed bitcoin: URI unchanged, and isNearbyPaymentRequest only checks fields that begin with lightning=. A label containing a literal lightning: is therefore admitted. AppViewModel then passes the raw URI to bitkit-core decode, which at the pinned 045c7ff takes the Lightning branch on contains("lightning:") and fails, so the payer never reaches review. Package.resolved still pins 0.8.0-rc15 at 045c7ff. The author scoped it to bitkit-core#227 (#1302 (comment)), which is open. Original report: #1302 (review). No material new evidence: list it as an existing concern.
  • [LOW] Expose the scanner status pill as static text when it has no NFC action — Still present at 3c26e98; Scanner.swift is unchanged since 54d7c2f. The status pill is always a SwiftUI Button with no .disabled and no accessibility trait change. Its action returns immediately unless sources.nfc is true. sources.nfc is false when NFC is unavailable, when no onNfcRead callback exists, or when the Bluetooth permission button row is shown, because the NFC button then appears separately. In those states VoiceOver and Switch Control expose an enabled 'ScannerStatus' button that does nothing when activated. No canonical issue: a focused search of synonymdev/bitkit-ios issues for 'scanner status pill' and 'status pill NFC' returned no matches. Original report: #1302 (review). No material new evidence since the 54d7c2f publication: reference it rather than re-publishing.
  • [LOW] Stop USDT Receive advertising while the payment-request recipient picker covers the QR — Verified by source analysis at 3c26e98. This is the USDT sibling of the fixed L4 mechanism, which the L4 fix does not cover. On the USDT tab, ReceiveQr renders UsdtReceiveView with contactAction = paymentRequestAction, which appends .paymentRequestRecipient to the Receive navigation path. ReceiveQr's own nearbyRequest returns nil for .usdt, so its new isQrCovered guard does not apply. UsdtReceiveView has its own NearbyPaymentAdvertiser. Its nearbyRequest depends only on settings, page == .address, deposit and the offline cover, and updateNearbyAdvertising checks only scenePhase. It stops on onDisappear when the picker is pushed. If the app goes inactive and active again while the picker covers the retained view, onChange(of: scenePhase) restarts advertising with the hidden request. Severity LOW rather than the other bot reviewer's MEDIUM: the served request is the receiver's own unchanged USDT request, so the consequence is a request being readable while not shown, with no wrong payee or amount. The thread was not driven at runtime by anyone. The author moved it to open issue #1428 (#1302 (comment)).
  • [LOW] Stop Receive advertising while Show Details replaces the QR — Verified by source analysis at 3c26e98. Show Details replaces the QR with the details view, on Bitcoin tabs through ReceiveQr.showDetails and on USDT through UsdtReceiveView's own showDetails. Neither flag feeds nearbyRequest, advertisedRequest or isQrCovered, so Bluetooth keeps serving the request while the QR is hidden. The PR's own nearbyRequest doc says only a request the payer can check on screen is offered. On Savings and Hardware the served request can carry the amount and note. Consequence: a request remains readable while its QR is not shown, but it is the receiver's own current request. Moved by the author to open issue #1428.
  • [LOW] Cover the NFC transport failure in the failed-read toast test — Test-coverage item, not a runtime defect. testFailedNfcReadCompletesWithoutRoute iterates cancelled, timedOut, noPaymentRequest, multiplePaymentRequests and unavailable, but not NfcReadError.failed (the transport failure). It asserts the toast description equals error.message, which is the production lookup, so a wrong .failed message would not be caught there. testNfcErrorMessages checks the .failed key directly. The author accepted adding .failed and moved it to open issue #1428.

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

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

5 participants