Skip to content

feat: nfc and bluetooth nearby payments - #1302

Open
jvsena42 wants to merge 21 commits into
masterfrom
feat/nfc-payments
Open

jvsena42 wants to merge 21 commits into
masterfrom
feat/nfc-payments

Conversation

@jvsena42

@jvsena42 jvsena42 commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Warning

Do not merge until this has been reviewed and tested on a physical iPhone. NFC and Bluetooth do not work on the simulator. A partial iPhone 13 ↔ Galaxy S22 pass ran at d9a0b2a (report); the remaining device cases, and the fixes after it, are not verified on an iPhone yet.

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:, lightning:, ethereum: (USDT) and lnurlp:. The decoded request must be on-chain, Lightning or LNURL-pay. Sign-in, setup, LNURL-withdraw/auth/channel, node and contact links are refused with 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.

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

  • Bitkit/Views/Wallets/UsdtReceiveView.swift: USDT deposit addresses on other networks are not offered over Bluetooth; only the Arbitrum request is.
  • Bitkit/Views/Wallets/UsdtSendView.swift: the USDT send scanner has no NFC or Bluetooth.
  • NFC card emulation on iOS, which needs Apple's HCE entitlement (EEA, licensed payment providers) or the NFC & SE Platform.
  • Paying Bolt Card terminals (lnurlw emulation plus a server relay).
  • Background NFC tag reading: iOS passes only universal links to apps in the background.
  • Bluetooth in the background: advertising and scanning stop when the app leaves the foreground.
  • Including the TapPay intro's seen flag in the cross-platform backup.
  • Translations other than English.

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 (lnurlp://… or LNURL1…) → LNURL pay amount screen — 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 plain text or two different requests → "NFC Read Failed" toast — 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 plain text → 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

[Medium impact] No blocking code issue remains from this review; the PR's physical-device testing requirement still applies.

Summary

Adds NFC payment reads and Bluetooth nearby payments, with receive advertising, payment-only Bluetooth input, settings backup, and translated controls.

  • Payment scanners can read requests from NFC tags and nearby phones.
  • Receive screens offer payment requests to nearby phones over Bluetooth.
  • The scanner introduces NFC and nearby payment controls to iPhone users.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[NFC or Bluetooth request] --> B[Record current scanner visit]
  B --> C[Decode request]
  C --> D{Same visit?}
  D -->|Yes| E[Open normal payment flow]
  D -->|No| F[Drop old result]
  G[Leave scanner and return] --> H[Visit counter changes]
  H --> D
Loading

Reviews (13) · Last reviewed commit: "fix: drop a scan once its scanner visit ..." · 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
Master asks for the payment PIN before QuickPay settings are raised.
The NFC intro toggle now goes through changeQuickpaySetting too.

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

Copy link
Copy Markdown
Member Author

Merged master in 23f0c20. The only conflict was SettingsViewModel.swift: master made the QuickPay settings private(set) and now asks for the payment PIN before they are raised (#1326). I kept master's lines and added enableNearbyPayments back.

The TapPay (NFC) intro sheet's QuickPay toggle wrote enableQuickpay directly. It now goes through changeQuickpaySetting and shows the same PIN check as QuickPay settings. This matches the Android adaptation in bitkit-android#1883.

Build passes, and 74 tests pass (ScannerManagerTests, ScannedPaymentRequestTests, QuickpaySettingsTests, QuickPayLimitsTests, QuickPayPaymentCoordinatorTests). SwiftFormat and translation validation are clean. Not driven on a device: the intro sheet only shows on an iPhone with NFC.

@jvsena42
jvsena42 marked this pull request as ready for review November 17, 2026 13:02
Comment thread Bitkit/Managers/ScannerManager.swift Resolved
@jvsena42
jvsena42 marked this pull request as draft November 17, 2026 13:10
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review November 17, 2026 13:28

@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 reassessment of the complete PR diff against merge base b6860d5a, at ac7649a. No verified baseline was supplied. The saved comparison base changed from 79da5450 to b6860d5 and that base change touches settings and scanner files, so earlier coverage was not inherited.

1 actionable finding — resolve or provide an evidence-backed rebuttal.

A Bluetooth request still suppresses QuickPay until its route is chosen. A QR or NFC read takes that lock and releases the suppression before the user's route is chosen, and an NFC read holds the lock from the moment the system sheet opens. Earlier threads on required BIP 321 parameters, routing after the scanner or Send path changes, a refused invoice stopping further reads, a Bluetooth decode dropping a QR or NFC read, and QuickPay staying suppressed after that takeover are fixed at this revision. Removing the addressless BIP 321 rewrite after the core bump remains bitkit-ios#1344.

The service UUID, meta layout, 512-byte chunks, version byte, -60 dBm threshold, and backup field isNearbyPaymentsEnabled match bitkit-android#1883 at 483562df. iOS accepts lnurlp: and any lightning: URI over Bluetooth, then refuses a decoded non-payment, which is the allowlist this PR specifies. iOS cannot emulate an NFC tag.

Validation: source inspection only. SwiftFormat and Run Integration Tests succeeded on ac7649a. Run Tests was still in progress. This review did not execute those suites. Device testing: not performed. The author reports manual cases 1–26 have not been run on an iPhone.

Suggested additional test cases

  • Platform: iPhone, same session, no relaunch. Setup: Nearby payments is on, then restore a settings backup whose isNearbyPaymentsEnabled value is false. Action: open Security and Receive without killing the app. Expected result: the Nearby payments toggle is off, Receive does not show "Scan or tap to pay", and a nearby scanner does not receive the request.
  • Platform: iPhone, QuickPay on, Bluetooth allowed, payment scanner open. Setup: a second phone advertising a Lightning invoice, and a different Lightning invoice below the QuickPay threshold available as a QR and as an NFC tag. Action: while the Bluetooth request is still decoding, scan the QR, then repeat with the NFC tag. Expected result: QuickPay pays the scanned invoice. The Bluetooth invoice is not paid and does not open a review.

Findings

  • [MEDIUM] Reload nearby payments after settings restore — inline at Bitkit/ViewModels/SettingsViewModel.swift:115.

Reviewer model: grok-4.7
Reasoning effort: xhigh

@jvsena42
jvsena42 marked this pull request as draft November 17, 2026 13:59
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review November 17, 2026 14:03
@jvsena42
jvsena42 requested review from a team and piotr-iohk November 17, 2026 14:03

@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 — an NFC result can still route over Enter Manually.

The PR moved to 346f7e0 after this run; these results are for ac7649a.

These results are for ac7649a. The later settings-restore fix is at 346f7e0 and is outside this review.

Findings:

  • MEDIUM — NFC decoding still routes after leaving the Send scanner. Bitkit/Managers/ScannerManager.swift:313: the actual SendOptionsView NFC callback supplies no isCurrent check, so the new checks receive the default { true }. With decoding held after the NFC input returns, opening Enter Manually does not invalidate the request: releasing the real decoder stores the tag address and pushes Amount over Manual. I reproduced this twice through the actual callback. This is a remaining part of the NFC late-routing concern; early NFC locking itself passes. Capture the originating presentation and pass the live Send navigation check, as the nearby handler does.

QA for ac7649a:

Built the unmodified head and ran the selected nearby/scanner/payment-navigation and QuickPay XCTest suites. The new UI cases used an iPhone 17 Pro 2x simulator, iOS 27.0, Xcode 27.0, with the Debug hook below. It forces NFC availability, controls the NFC input boundary, injects nearby requests through the actual scanner callback, holds before the real decoder, and logs routing and PIN decisions. It does not exercise Core NFC sessions or Bluetooth transport. Only regtest funds were used; no payment was submitted.

The NFC lock passes in both scanner UIs, cancellation releases it, and the intro's PIN protection passes. The delayed NFC result after Enter Manually fails. Earlier passing cases are carried only where this delta leaves their demonstrated paths unchanged, from the previous report.

Ignore an NFC result after leaving its scanner ❌ On ac7649a with a Debug hook holding before real NFC payment decoding, Enter Manually opened, but releasing decoding pushed Amount over Manual. The hook log reports current=true and retains the NFC address. Reproduced twice.

Case nfc-stale.

nfc-stale-recheck2x.2x.mp4

Recording at 2× speed.

The recording shows Manual followed by Amount. The hook recorded:

NFC boundary response=bitcoin:bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
NFC decoding held
NFC decoder returned; current=true
send route=Optional(Bitkit.SendRoute.amount); suppressed=false; address=bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
Keep Bluetooth out while an NFC read is pending inside Send ✅ On ac7649a with the NFC boundary held by a Debug hook, an injected nearby callback reported not taken; releasing the tag request opened Amount for the NFC address with QuickPay suppression false, as checked in the hook log.

Case nfc-lock-send.

nfc-lock-send2x.2x.mp4

Recording at 2× speed.

Keep Bluetooth out while an NFC read is pending on the main scanner ✅ On ac7649a with the NFC boundary held by a Debug hook, the nearby callback reported not taken. Releasing the tag opened Amount; the hook log identifies the NFC address and suppression=false.

Case nfc-lock-main.

nfc-lock-main2x.2x.mp4

Recording at 2× speed.

Resume payment scanning after cancelling an NFC read ✅ On ac7649a with a Debug NFC boundary hook, cancellation opened no payment; the next nearby callback opened Amount. The hook log confirms taken=true and suppression=true for that nearby request.

Case nfc-cancel.

nfc-cancel2x.2x.mp4

Recording at 2× speed.

Use the TapPay introduction with payment PIN protection ✅ On ac7649a with a Debug NFC-availability hook, cancelling PIN approval left QuickPay off; the correct PIN enabled it, disabling needed no prompt, Settings opened QuickPay, and the intro stayed dismissed after relaunch.

Case 9-ui.

intro2x.2x.mp4

Recording at 2× speed.

Check: nearby parsers, scanner locking and QuickPay authorization ✅ The unmodified pinned head built and passed the selected NDEF parser, nearby protocol, normalization, ScannerManager, payment navigation and QuickPay suites, including pending-NFC lock and cancellation regressions.

Case unit-checks.

Hide NFC on a simulator ✅ Carried from 7bcf5b7: Home and the scanner hid NFC on an unmodified simulator build.

Case 10. Earlier report.

case10-2x.2x.mp4

QR replaces a pending Bluetooth request on the main scanner ✅ Carried from 6451b28: the main user-scan callback replaced a held nearby decode; logs showed suppression=false and the late nearby callback returned taken=false.

Case takeover-main. Earlier report.

takeover-main2x.2x.mp4

User scan replaces a pending Bluetooth request inside Send ✅ Carried from 6451b28: the Send user-scan callback replaced a held nearby decode; logs showed suppression=false and the late nearby callback returned taken=false.

Case takeover-send. Earlier report.

takeover-send2x.2x.mp4

Bluetooth keeps QuickPay suppressed while routing ✅ Carried from 6451b28: the nearby callback opened Amount with suppression=true and returned taken=true; no radio exchange ran.

Case nearby-control. Earlier report.

nearby-control2x.2x.mp4

Keep the nearby setting after relaunch ✅ Carried from 7bcf5b7: Nearby payments defaulted on, switched off, and stayed off after relaunch.

Case 15-ui. Earlier report.

case15ui-2x.2x.mp4

Show scanner controls with the camera denied ✅ Carried from 7bcf5b7: both main and Send scanners showed the camera-denied controls.

Case 17-ui. Earlier report.

case17ui-2x.2x.mp4

Ignore a delayed nearby request after Enter Manually ✅ Carried from 6451b28: Enter Manually remained visible after the delayed nearby decoder returned; its callback reported taken=false.

Case send-ui. Earlier report.

send-ui2x.2x.mp4

Physical cases remain unrun. The device build could not be signed because the required team certificate and private key were unavailable; no provisioned test iPhone, Android peer or written NFC tags were available. Callback and unit checks do not replace these cases.

Read a Lightning tag ⏭️ Needs a provisioned NFC test iPhone and a Lightning tag.

Case 1. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Read a unified Bitcoin tag ⏭️ Needs a provisioned NFC test iPhone and a unified Bitcoin tag.

Case 2. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Read an LNURL-pay tag ⏭️ Needs a provisioned NFC test iPhone and an LNURL-pay tag.

Case 3. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Read a USDT tag ⏭️ Needs a provisioned NFC test iPhone and a USDT tag.

Case 4. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Pay a small NFC invoice with QuickPay ⏭️ Needs an NFC test iPhone, a tag and a funded Lightning wallet to exercise automatic payment.

Case 5a. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Review a large NFC invoice ⏭️ Needs an NFC test iPhone and an above-threshold Lightning tag.

Case 5b. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Read NFC inside Send ⏭️ Needs an NFC test iPhone and a physical or Android-emulated tag. The Send routing callback was exercised separately.

Case 6. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Cancel or time out an NFC read ⏭️ Needs the real iOS NFC session to test cancellation and timeout.

Case 7. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Reject unreadable or conflicting NFC tags ⏭️ Needs an NFC test iPhone and plain-text or conflicting physical tags. Plain text is refused by the shared scanner; conflicting payloads are refused on the NFC sheet.

Case 8. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Show TapPay introduction once ⏭️ Physical NFC eligibility needs a provisioned test iPhone. The intro controls, payment PIN and persistence passed separately with the availability hook.

Case 9. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Receive Bitcoin over Bluetooth from Android ⏭️ Needs a provisioned test iPhone and an Android Bluetooth peer.

Case 11. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Read Android Receive over Bluetooth ⏭️ Needs Android Receive and a provisioned test iPhone to exchange the request over Bluetooth.

Case 12. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Exchange Bluetooth requests between iPhones ⏭️ Needs two physical test iPhones.

Case 13. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Review Bluetooth requests with QuickPay enabled ⏭️ Needs a physical Bluetooth peer and a funded Lightning test wallet with QuickPay enabled. Suppression state was checked separately.

Case 14. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Turn nearby advertising off and on ⏭️ Stopping and restarting advertising needs physical Bluetooth hardware and an observing peer. Switch persistence passed separately.

Case 15. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Allow Bluetooth from a fresh scanner ⏭️ Needs physical iOS Bluetooth permission prompting and radio activation.

Case 16a. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Open Settings after Bluetooth denial ⏭️ Needs a physical iPhone with Bluetooth permission denied.

Case 16b. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Use nearby payment controls without camera permission ⏭️ NFC and Bluetooth operation with camera access denied needs physical hardware. The camera-denied layout passed separately.

Case 17. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Choose the strongest nearby phone ⏭️ Needs multiple physical advertisers and controlled distance.

Case 18. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Pause advertising in the background ⏭️ Needs physical Bluetooth hardware and a peer observing advertising across background and foreground.

Case 19. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Reject non-payment Bluetooth requests ⏭️ Needs a physical Bluetooth peer serving non-payment requests. Payment-only refusal is covered by the scanner unit checks.

Case 20. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Open Receive before Bluetooth permission ⏭️ Needs a physical iPhone with Bluetooth permission not yet determined.

Case 21. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Receive Arbitrum USDT over Bluetooth ⏭️ Needs a physical iPhone and a Bluetooth peer to exchange the Arbitrum USDT request.

Case 22. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Advertise an edited Receive request ⏭️ Needs a physical Bluetooth peer to read the edited advertised request.

Case 23. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Avoid Bluetooth power alerts ⏭️ Needs a physical iPhone with Bluetooth powered off.

Case 24. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Resume Bluetooth after cancelling review ⏭️ Needs a physical Bluetooth peer to observe scanning resume and retry after ten seconds.

Case 26. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Read Android Receive through NFC ⏭️ Needs a provisioned NFC test iPhone and a physical Android phone on the twin branch.

Case nfc-android. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

QuickPay the user invoice after replacing a Bluetooth decode ⏭️ No provisioned physical test iPhone or radio peer was available. Prior simulator results establish routing and suppression only, not payment execution.

Case quickpay-takeover. Physical-device signing was unavailable; the simulator cannot establish this hardware behavior.

Apply a restored nearby-payment setting without relaunching ⏭️ The later settings-restore fix at 346f7e0 is outside this run; its same-session toggle and advertising behavior have not been checked here.

Case restore-nearby. Earlier report.

Case 25's system-sheet refusal expectation was withdrawn and accepted; it remains retired.

The settings-restore case was raised during this run and followed by a later fix. That fix and its device behavior are not assessed here.

Debug hook used for the new simulator cases

Not pushed. Replaces only the NFC input boundary, forces availability, supplies the nearby callback and holds before the real payment decoder. Routing guards, decoder results and PIN verification are unchanged. Logging observes the original decisions.

diff --git a/Bitkit/Components/Scanner.swift b/Bitkit/Components/Scanner.swift
index c62642fe4..b016bf7bc 100644
--- a/Bitkit/Components/Scanner.swift
+++ b/Bitkit/Components/Scanner.swift
@@ -412,6 +412,27 @@ struct Scanner: View {
         }
         .cornerRadius(16)
         .contentShape(Rectangle())
+        .task { // test hook
+            #if DEBUG // test hook
+                if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1", let onNearbyRequest { // test hook
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                    reviewLog("scanner appeared") // test hook
+                    for _ in 0..<18000 { // test hook
+                        guard !Task.isCancelled else { break } // test hook
+                        let input = folder.appendingPathComponent("review-nearby.txt") // test hook
+                        if let request = try? String(contentsOf: input, encoding: .utf8) { // test hook
+                            try? FileManager.default.removeItem(at: input) // test hook
+                            Task { @MainActor in // test hook
+                                reviewLog("nearby callback started") // test hook
+                                let taken = await onNearbyRequest(request) // test hook
+                                reviewLog("nearby callback taken=\(taken)") // test hook
+                            } // test hook
+                        } // test hook
+                        try? await Task.sleep(for: .milliseconds(100)) // test hook
+                    } // test hook
+                } // test hook
+            #endif // test hook
+        } // test hook
         .onAppear {
             startNearbyScanning()
             guard !cameraManager.hasPermission else { return }
diff --git a/Bitkit/Managers/ScannerManager.swift b/Bitkit/Managers/ScannerManager.swift
index 9687fca3e..d6531836d 100644
--- a/Bitkit/Managers/ScannerManager.swift
+++ b/Bitkit/Managers/ScannerManager.swift
@@ -147,6 +147,9 @@ class ScannerManager: ObservableObject {
                     settings: settings,
                     sheetViewModel: sheets
                 )
+                #if DEBUG // test hook
+                    reviewLog("main routed; suppressed=\(app.isQuickPaySuppressed); address=\(app.scannedOnchainInvoice?.address ?? "none")") // test hook
+                #endif // test hook
                 // A refused request (e.g. an expired invoice) only shows a toast and opens no sheet.
                 didOpenScanFlow = !app.didRejectScannedPayment &&
                     sheets.activeSheetConfiguration?.presentationID != presentationBefore
@@ -259,6 +262,9 @@ class ScannerManager: ObservableObject {
                 wallet?.prepareFixedAmountOnchainSend(amountSats: invoice.amountSatoshis)
             }
 
+            #if DEBUG // test hook
+                reviewLog("send route=\(String(describing: route)); suppressed=\(app.isQuickPaySuppressed); address=\(app.scannedOnchainInvoice?.address ?? "none")") // test hook
+            #endif // test hook
             completion(route)
         } catch {
             guard isCurrent(), !(error is CancellationError) else { return }
diff --git a/Bitkit/Services/NfcReader.swift b/Bitkit/Services/NfcReader.swift
index 3056b2566..37eb86f74 100644
--- a/Bitkit/Services/NfcReader.swift
+++ b/Bitkit/Services/NfcReader.swift
@@ -43,10 +43,30 @@ 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"] == "1" { return true } // test hook
+        #endif // test hook
+        return NFCNDEFReaderSession.readingAvailable // test hook
     }
 
     func readPaymentRequest(alertMessage: String) async throws -> String {
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" { // test hook
+                reviewLog("NFC boundary pending") // test hook
+                let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                for _ in 0..<1800 { // test hook
+                    let response = folder.appendingPathComponent("review-nfc-response.txt") // test hook
+                    if let value = try? String(contentsOf: response, encoding: .utf8) { // test hook
+                        try? FileManager.default.removeItem(at: response) // test hook
+                        reviewLog("NFC boundary response=\(value)") // test hook
+                        if value == "cancel" { throw NfcReadError.cancelled } // test hook
+                        return value // test hook
+                    } // test hook
+                    try await Task.sleep(for: .milliseconds(100)) // test hook
+                } // test hook
+                throw NfcReadError.timedOut // test hook
+            } // test hook
+        #endif // test hook
         guard isAvailable else { throw NfcReadError.unavailable }
         guard continuation == nil else { throw NfcReadError.busy }
 
@@ -120,3 +140,14 @@ extension NfcReader: NFCNDEFReaderSessionDelegate {
         }
     }
 }
+
+#if DEBUG // test hook
+    @MainActor // test hook
+    func reviewLog(_ message: String) { // test hook
+        guard ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" else { return } // test hook
+        let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+        let file = folder.appendingPathComponent("review-events.txt") // test hook
+        let previous = (try? String(contentsOf: file, encoding: .utf8)) ?? "" // test hook
+        try? (previous + "\(Date().timeIntervalSince1970) \(message)\n").write(to: file, atomically: true, encoding: .utf8) // test hook
+    } // test hook
+#endif // test hook
diff --git a/Bitkit/ViewModels/AppViewModel.swift b/Bitkit/ViewModels/AppViewModel.swift
index 7f680a6a1..290cb553d 100644
--- a/Bitkit/ViewModels/AppViewModel.swift
+++ b/Bitkit/ViewModels/AppViewModel.swift
@@ -996,7 +996,22 @@ extension AppViewModel {
         if let prevalidatedPaymentRequest {
             data = prevalidatedPaymentRequest
         } else {
+            #if DEBUG // test hook
+                if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" { // test hook
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                    if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-hold-decode.txt").path) { // test hook
+                        reviewLog("NFC decoding held") // test hook
+                        for _ in 0..<1800 { // test hook
+                            if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-release-decode.txt").path) { break } // test hook
+                            try await Task.sleep(for: .milliseconds(100)) // test hook
+                        } // test hook
+                    } // test hook
+                } // test hook
+            #endif // test hook
             data = try await scanPaymentOperations.decodeInvoice(uri)
+            #if DEBUG // test hook
+                reviewLog("NFC decoder returned; current=\(isCurrentScanGeneration())") // test hook
+            #endif // test hook
             try ensureScannedDataHandlingOwnership(
                 handlingId,
                 claimedContactPaymentContext: claimedContactPaymentContext,
diff --git a/Bitkit/ViewModels/SettingsViewModel.swift b/Bitkit/ViewModels/SettingsViewModel.swift
index fd0afe288..dee2691c9 100644
--- a/Bitkit/ViewModels/SettingsViewModel.swift
+++ b/Bitkit/ViewModels/SettingsViewModel.swift
@@ -330,6 +330,9 @@ class SettingsViewModel: NSObject, ObservableObject {
     }
 
     private func applyQuickpayChange(_ change: QuickpaySettingChange) {
+        #if DEBUG // test hook
+            reviewLog("QuickPay applying \(String(describing: change))") // test hook
+        #endif // test hook
         switch change {
         case let .enabled(isEnabled): enableQuickpay = isEnabled
         case let .amount(amount): quickpayAmount = amount
diff --git a/Bitkit/Views/Security/PaymentAuthorization.swift b/Bitkit/Views/Security/PaymentAuthorization.swift
index 8c8e2c0a1..0c19893da 100644
--- a/Bitkit/Views/Security/PaymentAuthorization.swift
+++ b/Bitkit/Views/Security/PaymentAuthorization.swift
@@ -29,10 +29,16 @@ final class PaymentAuthorization {
         }
         resolvePin(false)
         isAskingForPin = true
+        #if DEBUG // test hook
+            reviewLog("PIN requested") // test hook
+        #endif // test hook
         return await withCheckedContinuation { pinContinuation = $0 }
     }
 
     fileprivate func resolvePin(_ approved: Bool) {
+        #if DEBUG // test hook
+            reviewLog("PIN resolved approved=\(approved); wasAsking=\(isAskingForPin)") // test hook
+        #endif // test hook
         isAskingForPin = false
         let continuation = pinContinuation
         pinContinuation = nil

Delta review: 6451b28…ac7649a, covering NFC ownership and tests, TapPay authorization integration, the translated scanner button labels, reached main/Send/QuickPay paths, and prior open feedback. The master merge was checked for its interaction with this feature; unrelated master changes were excluded. Translations had source validation but no locale-by-locale device run. Physical eligibility, radio exchange, actual QuickPay execution, and the pending settings-restore case remain unverified.

Twin: bitkit-android#1883 feat: nfc and bluetooth nearby payments. Its protocol document matches byte for byte at Android 483562d. Android's documented NFC activation/navigation checks drop stale reads; iOS's remaining Send NFC route above does not match that behavior. Android ↔ iOS radio exchange remains unverified.


Reviewed by gpt-6.1-sol-high

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

@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: Follow-up of the full pull request at d9a0b2a, since ac7649a (baseline review). Merge base b6860d5 is unchanged, and the previous head is an ancestor. This pass covered the two new commits. Inherited coverage is the unchanged NFC parsing, scan lock and QuickPay takeover, Bluetooth central and peripheral behavior, payment allowlist and BIP 321 rewrite, Receive and USDT advertising lifecycle, NFC intro sheet, scanner controls, the earlier unit-test inspection, and the Android comparison at 483562df.

No new actionable code findings.

An NFC read on the main scanner and on Send now keeps the sheet and navigation origin from when the read starts. Send also requires its own path to still be on the scanner. After the tag is decoded, a closed sheet or a move to Enter Manually or Contacts produces no route and does not keep the invoice. The scan lock is still taken for the whole read and released when it ends. Restoring settings assigns enableNearbyPayments from isNearbyPaymentsEnabled, and a backup without that key restores the default on. Receive and USDT already gate advertising on that property when nearbyRequest is read again.

Compared with bitkit-android#1883 at 79e9f719: the backup field and default on still match. Since 483562df, Android only changed NFC reader activation so a read that finishes after the scanner pauses is dropped. iOS now drops the decoded NFC request when the sheet or Send path is no longer current. iOS still starts NFC from the button or pill, which is the existing platform difference.

Validation: testNfcReadCannotRouteAfterItsSendSheetCloses, testNfcReadCannotRouteAfterTheSendSheetMovesOn, and testNearbyPaymentsFollowARestoredBackup were inspected and not executed. This review did not build the app or run tests, and it did not start a simulator. Device testing was not performed. The author's unit-test run is on 11599905d, which does not include these commits. A device build still needs the NFC Tag Reading capability from the PR setup.

Suggested additional test cases

  • iPhone with a Lightning tag. Open Send, start NFC, and after the system sheet closes open Enter Manually or close Send before a payment appears. Expected: no payment route opens and QuickPay does not pay.
  • iPhone, Nearby payments on, Receive showing "Scan or tap to pay". Restore a backup with isNearbyPaymentsEnabled false and return to Receive without relaunching. Expected: Security shows Nearby payments off and the Receive label is gone.

Device testing: not performed in this review.

Earlier findings reconciled at this revision: 6 verified fixed, 1 not substantiated.

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: ⛔️ Request changes — returning to the Send scanner revives an old NFC read.

Findings:

  • MEDIUM — Returning to Options revives the old NFC read. Bitkit/Views/Wallets/Send/SendOptionsView.swift:59: hold NFC payment decoding, open Enter Manually, then tap Back before decoding completes. navigationPath.isEmpty becomes true again, so the old request is retained and Amount opens without another NFC tap. I reproduced this through the actual callback with the real decoder held by a Debug hook: current=true, onchain=true, and route=amount. Invalidate the scanner visit permanently when it ends. This is remaining evidence for the existing NFC thread.

The original stay-on-Manual case and closing either scanner now pass. The settings-restore fix also passes the committed regression and same-session toggle check.

QA for d9a0b2a:

Built the unmodified d9a0b2a and ran the selected NDEF parser, nearby protocol, normalization, scanner-manager, payment-navigation, settings-restore and QuickPay XCTest suites. The new runtime checks used an iPhone 17 Pro 2x simulator, iOS 27.0, Xcode 27.0, with the Debug hook below. It supplies the NFC input, holds before real decoding, injects nearby requests through the real callback, and invokes the real settings restore. Routing, decoder results, ownership checks and settings reload behavior are unchanged. Only regtest funds were used; no payment was submitted.

Physical cases remain unrun: the device build failed because the required signing certificate and private key were unavailable, and no provisioned iPhone and radio-peer test pair was available. Simulator callback tests do not establish Core NFC, Bluetooth permission/power behavior, radio exchange, or actual QuickPay payment.

Ignore a delayed NFC request after Enter Manually ✅ On the Debug hook build, the actual NFC callback was held before the real decoder; Manual remained open after release. Hook logs show current=false and no retained on-chain or Lightning invoice.

Case nfc-manual.

nfc-manual2x.2x.mp4

Recording at 2× speed.

Discard the old NFC read after leaving and returning to the scanner ❌ On the Debug hook build, Manual then Back revived the held NFC decode. Releasing the real decoder opened Amount for the old tag; logs show current=true and the invoice retained.

Case nfc-return.

nfc-return2x.2x.mp4

Recording at 2× speed.

The hook recorded:

NFC decoding held
scanner appeared
NFC decoder returned; current=true; retained=false
scan finished; onchain=true; lightning=false
send route=Optional(Bitkit.SendRoute.amount); suppressed=false
Ignore a delayed NFC request after closing Send ✅ On the Debug hook build, closing Send while the real NFC decoder was held left Home visible after release. Logs show current=false and neither invoice retained.

Case nfc-close.

nfc-close2x.2x.mp4

Recording at 2× speed.

Keep Bluetooth out while an NFC read is pending inside Send ✅ On the Debug hook build, a nearby callback during the held NFC read returned not taken. Releasing the tag opened Amount for the NFC address; logs show suppression=false. This also supplies the stay-on-scanner control.

Case nfc-lock-send.

nfc-lock-send2x.2x.mp4

Recording at 2× speed.

Keep Bluetooth out while an NFC read is pending on the main scanner ✅ On the Debug hook build, the nearby callback returned not taken while the NFC boundary was held. Releasing NFC opened Amount; the hook log identifies the NFC address and suppression=false.

Case nfc-lock-main.

nfc-lock-main2x.2x.mp4

Recording at 2× speed.

Ignore a delayed NFC request after closing the main scanner ✅ On the Debug hook build, dismissing the main scanner during held NFC decoding left Home visible after release. Logs show current=false and no retained invoice.

Case nfc-main-close.

nfc-main-close2x.2x.mp4

Recording at 2× speed.

Resume payment scanning after cancelling an NFC read ✅ On the Debug hook build, cancelling the NFC boundary opened no payment; the next nearby callback opened Amount. The log shows taken=true and suppression=true for that request.

Case nfc-cancel.

nfc-cancel2x.2x.mp4

Recording at 2× speed.

Apply restored nearby settings without relaunching ✅ On the Debug hook build, a settings backup with isNearbyPaymentsEnabled=false switched the visible Security toggle off; restoring a backup without the key switched it on in the same session. Hook logs confirm liveNearby=false then true.

Case restore-nearby.

restore-nearby2x.2x.mp4

Recording at 2× speed.

The hook recorded:

restore=off; liveNearby=false
restore=missing; liveNearby=true
Check: Check nearby parsers, NFC navigation and restored settings ✅ Unmodified pinned-head build and focused XCTest suites passed, including all three new NFC and settings regressions.

Case unit-checks.

Hide NFC on a simulator ✅ Carried from 7bcf5b7: simulator Home and scanner hide NFC; visibility code untouched.

Case 10.

Demonstrated at 7bcf5b7; later changes leave this behavior untouched. Earlier report.

case10-2x.2x.mp4

Earlier recording.

QR replaces a pending Bluetooth request on the main scanner ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, the real user-scan callback opened Amount for the user address while a different nearby request was held. Logs show suppression false at the user route and the late nearby callback returned taken=false; Amount remained visible.

Case takeover-main.

Demonstrated at 6451b28; later changes leave this behavior untouched. Earlier report.

takeover-main2x.2x.mp4

Earlier recording.

User scan replaces a pending Bluetooth request inside Send ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, the real user-scan callback opened Amount for the user address while a different nearby request was held. Logs show suppression false at the user route and the late nearby callback returned taken=false; Amount remained visible.

Case takeover-send.

Demonstrated at 6451b28; later changes leave this behavior untouched. Earlier report.

takeover-send2x.2x.mp4

Earlier recording.

Bluetooth keeps QuickPay suppressed while routing ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, staying in Send and releasing real decoding opened Amount. Logs show current=true, suppressed=true at the route, and taken=true. No radio exchange ran.

Case nearby-control.

Demonstrated at 6451b28; later changes leave this behavior untouched. Earlier report.

nearby-control2x.2x.mp4

Earlier recording.

Keep the nearby setting after relaunch ✅ Carried from 7bcf5b7: Switch default and persistence passed at 7bcf5b7; unchanged by delta.

Case 15-ui.

Demonstrated at 7bcf5b7; later changes leave this behavior untouched. Earlier report.

case15ui-2x.2x.mp4

Earlier recording.

Show scanner controls with the camera denied ✅ Carried from 7bcf5b7: Main and Send camera-denied layouts passed at 7bcf5b7; unchanged by delta.

Case 17-ui.

Demonstrated at 7bcf5b7; later changes leave this behavior untouched. Earlier report.

case17ui-2x.2x.mp4

Earlier recording.

Ignore a delayed nearby request after Enter Manually ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, Enter Manually stayed visible after releasing the real nearby decoder. Logs show current=false and taken=false.

Case send-ui.

Demonstrated at 6451b28; later changes leave this behavior untouched. Earlier report.

send-ui2x.2x.mp4

Earlier recording.

Use the TapPay introduction with payment PIN protection ✅ Carried from ac7649a: On ac7649a with a Debug NFC-availability hook, cancelling PIN approval left QuickPay off; the correct PIN enabled it, disabling needed no prompt, Settings opened QuickPay, and the intro stayed dismissed after relaunch.

Case 9-ui.

Demonstrated at ac7649a; later changes leave this behavior untouched. Earlier report.

intro2x.2x.mp4

Earlier recording.

Read a Lightning tag ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 1.

Needs a provisioned NFC test iPhone and a Lightning tag.

Read a unified Bitcoin tag ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 2.

Needs a provisioned NFC test iPhone and a unified Bitcoin tag.

Read an LNURL-pay tag ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 3.

Needs a provisioned NFC test iPhone and an LNURL-pay tag.

Read a USDT tag ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 4.

Needs a provisioned NFC test iPhone and a USDT tag.

Pay a small NFC invoice with QuickPay ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 5a.

Needs an NFC test iPhone, a tag and a funded Lightning wallet to exercise automatic payment.

Review a large NFC invoice ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 5b.

Needs an NFC test iPhone and an above-threshold Lightning tag.

Read NFC inside Send ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 6.

Needs an NFC test iPhone and a physical or Android-emulated tag. The Send routing callback was exercised separately.

Cancel or time out an NFC read ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 7.

Needs the real iOS NFC session to test cancellation and timeout.

Reject unreadable or conflicting NFC tags ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 8.

Needs an NFC test iPhone and plain-text or conflicting physical tags. Plain text is refused by the shared scanner; conflicting payloads are refused on the NFC sheet.

Show TapPay introduction once ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 9.

Physical NFC eligibility needs a provisioned test iPhone. The intro controls, payment PIN and persistence passed separately with the availability hook.

Receive Bitcoin over Bluetooth from Android ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 11.

Needs a provisioned test iPhone and an Android Bluetooth peer.

Read Android Receive over Bluetooth ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 12.

Needs Android Receive and a provisioned test iPhone to exchange the request over Bluetooth.

Exchange Bluetooth requests between iPhones ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 13.

Needs two physical test iPhones.

Review Bluetooth requests with QuickPay enabled ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 14.

Needs a physical Bluetooth peer and a funded Lightning test wallet with QuickPay enabled. Suppression state was checked separately.

Turn nearby advertising off and on ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 15.

Stopping and restarting advertising needs physical Bluetooth hardware and an observing peer. Switch persistence passed separately.

Allow Bluetooth from a fresh scanner ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 16a.

Needs physical iOS Bluetooth permission prompting and radio activation.

Open Settings after Bluetooth denial ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 16b.

Needs a physical iPhone with Bluetooth permission denied.

Use nearby payment controls without camera permission ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 17.

NFC and Bluetooth operation with camera access denied needs physical hardware. The camera-denied layout passed separately.

Choose the strongest nearby phone ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 18.

Needs multiple physical advertisers and controlled distance.

Pause advertising in the background ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 19.

Needs physical Bluetooth hardware and a peer observing advertising across background and foreground.

Reject non-payment Bluetooth requests ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 20.

Needs a physical Bluetooth peer serving non-payment requests. Payment-only refusal is covered by the scanner unit checks.

Open Receive before Bluetooth permission ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 21.

Needs a physical iPhone with Bluetooth permission not yet determined.

Receive Arbitrum USDT over Bluetooth ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 22.

Needs a physical iPhone and a Bluetooth peer to exchange the Arbitrum USDT request.

Advertise an edited Receive request ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 23.

Needs a physical Bluetooth peer to read the edited advertised request.

Avoid Bluetooth power alerts ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 24.

Needs a physical iPhone with Bluetooth powered off.

Resume Bluetooth after cancelling review ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case 26.

Needs a physical Bluetooth peer to observe scanning resume and retry after ten seconds.

Read Android Receive through NFC ⏭️ Not run: no provisioned physical test iPhone or radio fixture.

Case nfc-android.

Needs a provisioned NFC test iPhone and a physical Android phone on the twin branch.

QuickPay the user invoice after replacing a Bluetooth decode ⏭️ Not run: actual QR and NFC takeover payments require a provisioned test iPhone, radio peers and a funded Lightning wallet.

Case quickpay-takeover.

No provisioned physical test iPhone or radio peer was available. Prior simulator results establish routing and suppression only, not payment execution.

Stop Bluetooth advertising after restoring nearby payments off ⏭️ Actual advertising after restore needs a provisioned iPhone and a Bluetooth peer. The live setting and toggle passed separately.

Case restore-advertising.

No provisioned iPhone with the required signing identity and Bluetooth peer. Simulator does not supply Bluetooth.

Case 25's original system-sheet refusal expectation was withdrawn and accepted; it stays retired.

Receive advertising after restore was inspected in both Bitcoin and USDT Receive: each derives the request from enableNearbyPayments and observes request changes. The restore case above proves the live setting and visible toggle; it does not prove radio advertising.

Debug hook used for the current simulator cases

Not pushed. Forces NFC availability and supplies its input, pauses before the real decoder until explicit release, injects the nearby callback, logs the result, and calls settings restore with the current backup changed only at the nearby-payment key.

diff --git a/Bitkit/Components/Scanner.swift b/Bitkit/Components/Scanner.swift
index c62642fe4..aa98d48e1 100644
--- a/Bitkit/Components/Scanner.swift
+++ b/Bitkit/Components/Scanner.swift
@@ -412,6 +412,27 @@ struct Scanner: View {
         }
         .cornerRadius(16)
         .contentShape(Rectangle())
+        .task {
+            #if DEBUG
+                if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1", let onNearbyRequest {
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+                    reviewLog("scanner appeared")
+                    for _ in 0..<18000 {
+                        guard !Task.isCancelled else { break }
+                        let input = folder.appendingPathComponent("review-nearby.txt")
+                        if let request = try? String(contentsOf: input, encoding: .utf8) {
+                            try? FileManager.default.removeItem(at: input)
+                            Task { @MainActor in
+                                reviewLog("nearby callback started")
+                                let taken = await onNearbyRequest(request)
+                                reviewLog("nearby callback taken=\(taken)")
+                            }
+                        }
+                        try? await Task.sleep(for: .milliseconds(100))
+                    }
+                }
+            #endif
+        }
         .onAppear {
             startNearbyScanning()
             guard !cameraManager.hasPermission else { return }
diff --git a/Bitkit/ContentView.swift b/Bitkit/ContentView.swift
index f0646a1cf..b359742cd 100644
--- a/Bitkit/ContentView.swift
+++ b/Bitkit/ContentView.swift
@@ -7,5 +7,24 @@ struct ContentView: View {
         AppScene()
             .id(session.id)
             .environmentObject(session)
+            .task {
+                #if DEBUG
+                    guard ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" else { return }
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+                    for _ in 0..<18000 {
+                        guard !Task.isCancelled else { return }
+                        let input = folder.appendingPathComponent("review-restore.txt")
+                        if let mode = try? String(contentsOf: input, encoding: .utf8) {
+                            try? FileManager.default.removeItem(at: input)
+                            var backup = SettingsViewModel.shared.getSettingsDictionary()
+                            if mode == "missing" { backup.removeValue(forKey: "isNearbyPaymentsEnabled") }
+                            else { backup["isNearbyPaymentsEnabled"] = mode == "on" }
+                            SettingsViewModel.shared.restoreSettingsDictionary(backup)
+                            reviewLog("restore=\(mode); liveNearby=\(SettingsViewModel.shared.enableNearbyPayments)")
+                        }
+                        try? await Task.sleep(for: .milliseconds(100))
+                    }
+                #endif
+            }
     }
 }
diff --git a/Bitkit/Managers/ScannerManager.swift b/Bitkit/Managers/ScannerManager.swift
index 0cd17505f..844f1e536 100644
--- a/Bitkit/Managers/ScannerManager.swift
+++ b/Bitkit/Managers/ScannerManager.swift
@@ -147,6 +147,9 @@ class ScannerManager: ObservableObject {
                     settings: settings,
                     sheetViewModel: sheets
                 )
+                #if DEBUG
+                    reviewLog("main routed; suppressed=\(app.isQuickPaySuppressed); address=\(app.scannedOnchainInvoice?.address ?? "none")")
+                #endif
                 // A refused request (e.g. an expired invoice) only shows a toast and opens no sheet.
                 didOpenScanFlow = !app.didRejectScannedPayment &&
                     sheets.activeSheetConfiguration?.presentationID != presentationBefore
@@ -259,6 +262,9 @@ class ScannerManager: ObservableObject {
                 wallet?.prepareFixedAmountOnchainSend(amountSats: invoice.amountSatoshis)
             }
 
+            #if DEBUG
+                reviewLog("send route=\(String(describing: route)); suppressed=\(app.isQuickPaySuppressed); address=\(app.scannedOnchainInvoice?.address ?? "none")")
+            #endif
             completion(route)
         } catch {
             guard isCurrent(), !(error is CancellationError) else { return }
diff --git a/Bitkit/Services/NfcReader.swift b/Bitkit/Services/NfcReader.swift
index 3056b2566..5f111d4d2 100644
--- a/Bitkit/Services/NfcReader.swift
+++ b/Bitkit/Services/NfcReader.swift
@@ -43,10 +43,30 @@ final class NfcReader: NSObject, NfcPaymentReading {
     private var continuation: CheckedContinuation<String, Error>?
 
     var isAvailable: Bool {
-        NFCNDEFReaderSession.readingAvailable
+        #if DEBUG
+            if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" { return true }
+        #endif
+        return NFCNDEFReaderSession.readingAvailable
     }
 
     func readPaymentRequest(alertMessage: String) async throws -> String {
+        #if DEBUG
+            if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" {
+                reviewLog("NFC boundary pending")
+                let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+                for _ in 0..<1800 {
+                    let response = folder.appendingPathComponent("review-nfc-response.txt")
+                    if let value = try? String(contentsOf: response, encoding: .utf8) {
+                        try? FileManager.default.removeItem(at: response)
+                        reviewLog("NFC boundary response=\(value)")
+                        if value == "cancel" { throw NfcReadError.cancelled }
+                        return value
+                    }
+                    try await Task.sleep(for: .milliseconds(100))
+                }
+                throw NfcReadError.timedOut
+            }
+        #endif
         guard isAvailable else { throw NfcReadError.unavailable }
         guard continuation == nil else { throw NfcReadError.busy }
 
@@ -120,3 +140,14 @@ extension NfcReader: NFCNDEFReaderSessionDelegate {
         }
     }
 }
+
+#if DEBUG
+    @MainActor
+    func reviewLog(_ message: String) {
+        guard ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" else { return }
+        let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+        let file = folder.appendingPathComponent("review-events.txt")
+        let previous = (try? String(contentsOf: file, encoding: .utf8)) ?? ""
+        try? (previous + "\(Date().timeIntervalSince1970) \(message)\n").write(to: file, atomically: true, encoding: .utf8)
+    }
+#endif
diff --git a/Bitkit/ViewModels/AppViewModel.swift b/Bitkit/ViewModels/AppViewModel.swift
index 7f680a6a1..ddee7ef4f 100644
--- a/Bitkit/ViewModels/AppViewModel.swift
+++ b/Bitkit/ViewModels/AppViewModel.swift
@@ -859,6 +859,9 @@ extension AppViewModel {
         scannedDataHandlingId = handlingId
         didRejectScannedPayment = false
         defer {
+            #if DEBUG
+                reviewLog("scan finished; onchain=\(scannedOnchainInvoice != nil); lightning=\(scannedLightningInvoice != nil)")
+            #endif
             if scannedDataHandlingId == handlingId {
                 scannedDataHandlingId = nil
             }
@@ -996,7 +999,22 @@ extension AppViewModel {
         if let prevalidatedPaymentRequest {
             data = prevalidatedPaymentRequest
         } else {
+            #if DEBUG
+                if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" {
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
+                    if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-hold-decode.txt").path) {
+                        reviewLog("NFC decoding held")
+                        for _ in 0..<1800 {
+                            if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-release-decode.txt").path) { break }
+                            try await Task.sleep(for: .milliseconds(100))
+                        }
+                    }
+                }
+            #endif
             data = try await scanPaymentOperations.decodeInvoice(uri)
+            #if DEBUG
+                reviewLog("NFC decoder returned; current=\(isCurrentScanGeneration()); retained=\(scannedOnchainInvoice != nil)")
+            #endif
             try ensureScannedDataHandlingOwnership(
                 handlingId,
                 claimedContactPaymentContext: claimedContactPaymentContext,
diff --git a/Bitkit/ViewModels/SettingsViewModel.swift b/Bitkit/ViewModels/SettingsViewModel.swift
index b3965ed80..9a1917300 100644
--- a/Bitkit/ViewModels/SettingsViewModel.swift
+++ b/Bitkit/ViewModels/SettingsViewModel.swift
@@ -330,6 +330,9 @@ class SettingsViewModel: NSObject, ObservableObject {
     }
 
     private func applyQuickpayChange(_ change: QuickpaySettingChange) {
+        #if DEBUG
+            reviewLog("QuickPay applying \(String(describing: change))")
+        #endif
         switch change {
         case let .enabled(isEnabled): enableQuickpay = isEnabled
         case let .amount(amount): quickpayAmount = amount
diff --git a/Bitkit/Views/Security/PaymentAuthorization.swift b/Bitkit/Views/Security/PaymentAuthorization.swift
index 8c8e2c0a1..d2d3301ac 100644
--- a/Bitkit/Views/Security/PaymentAuthorization.swift
+++ b/Bitkit/Views/Security/PaymentAuthorization.swift
@@ -29,10 +29,16 @@ final class PaymentAuthorization {
         }
         resolvePin(false)
         isAskingForPin = true
+        #if DEBUG
+            reviewLog("PIN requested")
+        #endif
         return await withCheckedContinuation { pinContinuation = $0 }
     }
 
     fileprivate func resolvePin(_ approved: Bool) {
+        #if DEBUG
+            reviewLog("PIN resolved approved=\(approved); wasAsking=\(isAskingForPin)")
+        #endif
         isAskingForPin = false
         let continuation = pinContinuation
         pinContinuation = nil

Delta review: ac7649a…d9a0b2a, all five changed files and reached main/Send decoding, navigation, settings backup/restore, Receive and USDT advertising gates, and test isolation, plus earlier open feedback. No device case exercised actual NFC/Bluetooth transport, radio permission/power states, advertising after restore, or payment execution.

Twin: bitkit-android#1883 feat: nfc and bluetooth nearby payments, at 79e9f719. The shared protocol document matches byte for byte, and the backup key/default match. Android's NFC dispatcher invalidates each reader activation; iOS's Send leave-and-return case above still revives the old result. Android ↔ iOS radio exchange remains unverified.


Reviewed by gpt-6.1-sol-high

@jvsena42
jvsena42 marked this pull request as draft November 17, 2026 16:07
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jvsena42
jvsena42 marked this pull request as ready for review November 17, 2026 16:26
@jvsena42
jvsena42 requested review from a team and piotr-iohk November 17, 2026 16:26

piotr-iohk commented Nov 17, 2026 •

Copy link
Copy Markdown
Collaborator

Partial physical-device testing completed on staging/regtest with an iPhone 13 and Samsung Galaxy S22, cross-testing the two apps:

The basic BLE and NFC flows worked in the cases exercised:

  • Nearby/BLE request discovery between the phones and successful BTC payments, covering on-chain Savings and Lightning via Spark.
  • NFC with Bluetooth disabled on Android, reading the S22's advertised request from the iPhone after explicitly starting the NFC reader through the scanner.
  • Small, fixed-amount Lightning QuickPay, and an above-limit payment correctly requiring a swipe. Nearby/BLE requests also required manual confirmation. The swipe for BLE is expected because QuickPay is suppressed for that input.
  • USDT request discovery/navigation was exercised, but USDT settlement was not tested because the wallets have no USDT balance.

One UX observation: the iPhone needs the explicit NFC-reader action; merely bringing the phones together from Home does not start an NFC read. The iPhone is the NFC reader in this pairing, so reverse-direction NFC reading from the iPhone was not validated.

This is a partial pass on the revisions above, not a full sign-off. Updating both devices to the newer revisions now; further testing will cover scanner exit/re-entry and stale results, cancel/timeout/retry, changed receive amounts, lifecycle/permissions, and the remaining QuickPay settings/limits cases. I will follow up with results on the newer revision.

@ovi-reviewer ovi-reviewer Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Verdict: ⚠️ Not verified — the scanner-visit fix passes; the remaining physical-device cases are not fully verified.

Findings: None in this delta.

The remaining NFC leave-and-return finding is fixed at 594cbab. Both NFC and Bluetooth now discard an old result after leaving and returning to Send, the main scanner sheet or a full-screen scanner. Fresh requests still route.

QA for 594cbab:

Built the unmodified pinned head and ran the selected XCTest suites. Recorded callback checks ran on an iPhone 17 Pro 2x simulator, iOS 27.0, Xcode 27.0, with the Debug hook below. It supplies the NFC input or nearby callback, holds before the real decoder, and logs the result. It also opens the actual full-screen scanner for setup; Back and subsequent navigation use the app UI. Routing guards, decoder results and payment decisions are unchanged. Only regtest funds were used; no payment was submitted.

These checks do not exercise Core NFC sessions, Bluetooth radios, permissions or completed QuickPay payments. The physical-device report establishes basic iPhone 13 ↔ Galaxy S22 NFC/BLE BTC payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation at iOS d9a0b2a / Android 79e9f719. It does not establish USDT settlement or every format, threshold, permission and lifecycle variant below. The explicitly reported Android → iPhone NFC exchange is retained as its own passing case.

The remaining hardware cases could not be completed: the physical-device build lacked the required signing certificate/private key and NFC Tag Reading provisioning, and no provisioned test iPhone with the required peers/tags was available. Simulator callback checks do not replace those cases.

Discard the old NFC read after leaving and returning to Send ✅ On the Debug hook build, NFC decoding was held while Enter Manually opened and Back returned to Options. The old decode returned current=false, retained no invoice and opened no route; a fresh NFC read then opened Amount. The recording and hook log establish routing, not NFC transport.

Case nfc-return.

nfc-return.2x.mp4

Recording at 2× speed.

NFC boundary pending
NFC boundary response=bitcoin:bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
NFC decoding held
Send visit invalidated; visit=1
scanner appeared
NFC decoder returned; current=false; retained=false
scan finished; onchain=false; lightning=false
NFC boundary pending
NFC boundary response=bitcoin:bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
NFC decoder returned; current=true; retained=false
scan finished; onchain=true; lightning=false
send route=Optional(Bitkit.SendRoute.amount); suppressed=false; address=bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
Send visit invalidated; visit=2
Discard the old Bluetooth request after leaving and returning to Send ✅ On the Debug hook build, leaving Options for Manual and returning did not revive the held nearby decode: current=false, no retained invoice, taken=false. A fresh callback opened Amount with QuickPay suppression=true, as checked in the recording and hook log.

Case nearby-return.

nearby-return.2x.mp4

Recording at 2× speed.

nearby callback started
nearby decoding held
Send visit invalidated; visit=1
scanner appeared
nearby decoder returned; current=false; retained=false
scan finished; onchain=false; lightning=false
nearby callback taken=false
nearby callback started
nearby decoder returned; current=true; retained=false
scan finished; onchain=true; lightning=false
send route=Optional(Bitkit.SendRoute.amount); suppressed=true; address=bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
nearby callback taken=true
Send visit invalidated; visit=2
Discard the old NFC read after reopening the main scanner ✅ On the Debug hook build, dismissing and reopening the scanner left the old real NFC decode invalid. It retained no invoice or route; a fresh read opened Amount. Checked in the recording and hook log.

Case nfc-main-return.

nfc-main-return.2x.mp4

Recording at 2× speed.

Discard the old Bluetooth request after reopening the main scanner ✅ On the Debug hook build, the held nearby decode returned current=false and taken=false after the scanner was dismissed and reopened. A fresh callback opened Amount with QuickPay suppressed. Checked in the recording and hook log.

Case nearby-main-return.

nearby-main-return.2x.mp4

Recording at 2× speed.

Discard the old NFC read after returning to a full-screen scanner ✅ On the Debug hook build, Back then reopening the full-screen scanner at the same route changed the navigation generation. The old real NFC decode returned current=false and retained no invoice; a fresh read opened Amount. The recording shows navigation and the hook log checks generation and ownership.

Case nfc-full-return.

nfc-full-return.2x.mp4

Recording at 2× speed.

navigation generation=5; path=[Bitkit.Route.scanner]
setup opened full-screen scanner
scanner appeared
NFC boundary pending
NFC boundary response=bitcoin:bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
NFC decoding held
navigation generation=6; path=[]
navigation generation=7; path=[Bitkit.Route.scanner]
setup opened full-screen scanner
scanner appeared
NFC decoder returned; current=false; retained=false
scan finished; onchain=false; lightning=false
NFC boundary pending
NFC boundary response=bitcoin:bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
NFC decoder returned; current=true; retained=false
scan finished; onchain=true; lightning=false
main routed; suppressed=false; address=bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
Discard the old Bluetooth request after returning to a full-screen scanner ✅ On the Debug hook build, Back then reopening the same full-screen scanner did not revive the held nearby decode: current=false, no retained invoice, taken=false. A fresh callback opened Amount with suppression=true. Checked in the recording and hook log.

Case nearby-full-return.

nearby-full-return.2x.mp4

Recording at 2× speed.

navigation generation=9; path=[Bitkit.Route.scanner]
setup opened full-screen scanner
scanner appeared
nearby callback started
nearby decoding held
navigation generation=10; path=[]
navigation generation=11; path=[Bitkit.Route.scanner]
setup opened full-screen scanner
scanner appeared
nearby decoder returned; current=false; retained=false
scan finished; onchain=false; lightning=false
nearby callback taken=false
nearby callback started
nearby decoder returned; current=true; retained=false
scan finished; onchain=true; lightning=false
main routed; suppressed=true; address=bcrt1q6rhpng9evdsfnn833a4f4vej0asu6dk5srld6x
nearby callback taken=true
Ignore a delayed NFC request while Enter Manually stays open ✅ On the Debug hook build, Manual stayed open after the held real NFC decode was released. Logs show current=false and neither invoice retained. Returning to Options and making a fresh read then opened Amount.

Case nfc-manual.

nfc-manual.2x.mp4

Recording at 2× speed.

Check: scanner, navigation and restored settings ✅ The unmodified pinned head built and the selected parser, scanner, navigation, settings and QuickPay XCTest suites passed, including the new leave-and-return regression. SwiftFormat lint on all four changed Swift files and the delta whitespace check passed.

Case unit-checks.

Hide NFC on a simulator ✅ Carried from 7bcf5b7: Carried: simulator Home and scanner hide NFC; visibility code untouched.

Case 10.

Source report.

case10-2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

QR replaces a pending Bluetooth request on the main scanner ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, the real user-scan callback opened Amount for the user address while a different nearby request was held. Logs show suppression false at the user route and the late nearby callback returned taken=false; Amount remained visible.

Case takeover-main.

Source report.

takeover-main2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

User scan replaces a pending Bluetooth request inside Send ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, the real user-scan callback opened Amount for the user address while a different nearby request was held. Logs show suppression false at the user route and the late nearby callback returned taken=false; Amount remained visible.

Case takeover-send.

Source report.

takeover-send2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Bluetooth keeps QuickPay suppressed while routing ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, staying in Send and releasing real decoding opened Amount. Logs show current=true, suppressed=true at the route, and taken=true. No radio exchange ran.

Case nearby-control.

Source report.

nearby-control2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Keep the nearby setting after relaunch ✅ Carried from 7bcf5b7: Switch default and persistence passed at 7bcf5b7; unchanged by delta.

Case 15-ui.

Source report.

case15ui-2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Show scanner controls with the camera denied ✅ Carried from 7bcf5b7: Main and Send camera-denied layouts passed at 7bcf5b7; unchanged by delta.

Case 17-ui.

Source report.

case17ui-2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Ignore a delayed nearby request after Enter Manually ✅ Carried from 6451b28: On 6451b28 plus the Debug hook, Enter Manually stayed visible after releasing the real nearby decoder. Logs show current=false and taken=false.

Case send-ui.

Source report.

send-ui2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Use the TapPay introduction with payment PIN protection ✅ Carried from ac7649a: On ac7649a with a Debug NFC-availability hook, cancelling PIN approval left QuickPay off; the correct PIN enabled it, disabling needed no prompt, Settings opened QuickPay, and the intro stayed dismissed after relaunch.

Case 9-ui.

Source report.

intro2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Ignore a delayed NFC request after closing Send ✅ Carried from d9a0b2a: On the Debug hook build, closing Send while the real NFC decoder was held left Home visible after release. Logs show current=false and neither invoice retained.

Case nfc-close.

Source report.

nfc-close2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Keep Bluetooth out while an NFC read is pending inside Send ✅ Carried from d9a0b2a: On the Debug hook build, a nearby callback during the held NFC read returned not taken. Releasing the tag opened Amount for the NFC address; logs show suppression=false. This also supplies the stay-on-scanner control.

Case nfc-lock-send.

Source report.

nfc-lock-send2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Keep Bluetooth out while an NFC read is pending on the main scanner ✅ Carried from d9a0b2a: On the Debug hook build, the nearby callback returned not taken while the NFC boundary was held. Releasing NFC opened Amount; the hook log identifies the NFC address and suppression=false.

Case nfc-lock-main.

Source report.

nfc-lock-main2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Ignore a delayed NFC request after closing the main scanner ✅ Carried from d9a0b2a: On the Debug hook build, dismissing the main scanner during held NFC decoding left Home visible after release. Logs show current=false and no retained invoice.

Case nfc-main-close.

Source report.

nfc-main-close2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Resume payment scanning after cancelling an NFC read ✅ Carried from d9a0b2a: On the Debug hook build, cancelling the NFC boundary opened no payment; the next nearby callback opened Amount. The log shows taken=true and suppression=true for that request.

Case nfc-cancel.

Source report.

nfc-cancel2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Apply restored nearby settings without relaunching ✅ Carried from d9a0b2a: On the Debug hook build, a settings backup with isNearbyPaymentsEnabled=false switched the visible Security toggle off; restoring a backup without the key switched it on in the same session. Hook logs confirm liveNearby=false then true.

Case restore-nearby.

Source report.

restore-nearby2x.2x.mp4

Earlier recording; the demonstrated behavior is unchanged.

Read Android Receive through NFC ✅ Carried from d9a0b2a: The physical-device report confirms the iPhone explicitly started NFC and read the Galaxy S22 Receive request with Android Bluetooth disabled. This is the reported d9a0b2a / Android 79e9f719 result; NFC transport is unchanged in this delta.

Case nfc-android.

Source report.

Read a Lightning tag ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 1.

Source report.

Needs a provisioned NFC test iPhone and a Lightning tag. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Read a unified Bitcoin tag ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 2.

Source report.

Needs a provisioned NFC test iPhone and a unified Bitcoin tag. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Read an LNURL-pay tag ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 3.

Needs a provisioned NFC test iPhone and an LNURL-pay tag.

Read a USDT tag ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 4.

Needs a provisioned NFC test iPhone and a USDT tag.

Pay a small NFC invoice with QuickPay ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 5a.

Source report.

Needs an NFC test iPhone, a tag and a funded Lightning wallet to exercise automatic payment. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Review a large NFC invoice ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 5b.

Source report.

Needs an NFC test iPhone and an above-threshold Lightning tag. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Read NFC inside Send ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 6.

Source report.

Needs an NFC test iPhone and a physical or Android-emulated tag. The Send routing callback was exercised separately. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Cancel or time out an NFC read ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 7.

Needs the real iOS NFC session to test cancellation and timeout.

Reject unreadable or conflicting NFC tags ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 8.

Needs an NFC test iPhone and plain-text or conflicting physical tags. Plain text is refused by the shared scanner; conflicting payloads are refused on the NFC sheet.

Show TapPay introduction once ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 9.

Physical NFC eligibility needs a provisioned test iPhone. The intro controls, payment PIN and persistence passed separately with the availability hook.

Receive Bitcoin over Bluetooth from Android ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 11.

Source report.

Needs a provisioned test iPhone and an Android Bluetooth peer. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Read Android Receive over Bluetooth ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 12.

Source report.

Needs Android Receive and a provisioned test iPhone to exchange the request over Bluetooth. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Exchange Bluetooth requests between iPhones ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 13.

Needs two physical test iPhones.

Review Bluetooth requests with QuickPay enabled ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 14.

Source report.

Needs a physical Bluetooth peer and a funded Lightning test wallet with QuickPay enabled. Suppression state was checked separately. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Turn nearby advertising off and on ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 15.

Stopping and restarting advertising needs physical Bluetooth hardware and an observing peer. Switch persistence passed separately.

Allow Bluetooth from a fresh scanner ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 16a.

Needs physical iOS Bluetooth permission prompting and radio activation.

Open Settings after Bluetooth denial ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 16b.

Needs a physical iPhone with Bluetooth permission denied.

Use nearby payment controls without camera permission ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 17.

NFC and Bluetooth operation with camera access denied needs physical hardware. The camera-denied layout passed separately.

Choose the strongest nearby phone ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 18.

Needs multiple physical advertisers and controlled distance.

Pause advertising in the background ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 19.

Needs physical Bluetooth hardware and a peer observing advertising across background and foreground.

Reject non-payment Bluetooth requests ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 20.

Needs a physical Bluetooth peer serving non-payment requests. Payment-only refusal is covered by the scanner unit checks.

Open Receive before Bluetooth permission ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 21.

Needs a physical iPhone with Bluetooth permission not yet determined.

Receive Arbitrum USDT over Bluetooth ⏭️ Partial physical evidence exists in the linked report; the exact format, scanner, threshold or Receive variants requested by this case are not individually identified.

Case 22.

Source report.

Needs a physical iPhone and a Bluetooth peer to exchange the Arbitrum USDT request. The report establishes basic NFC/BLE payments, small fixed-amount QuickPay, an above-limit swipe and USDT request navigation, but does not map those results to every setup in this case.

Advertise an edited Receive request ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 23.

Needs a physical Bluetooth peer to read the edited advertised request.

Avoid Bluetooth power alerts ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 24.

Needs a physical iPhone with Bluetooth powered off.

Resume Bluetooth after cancelling review ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case 26.

Needs a physical Bluetooth peer to observe scanning resume and retry after ten seconds.

QuickPay the user invoice after replacing a Bluetooth decode ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case quickpay-takeover.

No provisioned physical test iPhone or radio peer was available. Prior simulator results establish routing and suppression only, not payment execution.

Stop Bluetooth advertising after restoring nearby payments off ⏭️ Not completed: no provisioned physical test iPhone and the required radio peers or tags were available for this case.

Case restore-advertising.

No provisioned iPhone with the required signing identity and Bluetooth peer. Simulator does not supply Bluetooth.

Case 25 remains retired: the plain-text system-sheet expectation was withdrawn.

Debug hook for the current callback cases

Not pushed. Forces NFC availability, supplies input through the NFC boundary or actual nearby callback, holds before real decoding until explicit file release, and logs decisions. The Home setup hook opens the actual full-screen scanner; it does not change scanner validity checks.

diff --git a/Bitkit/Components/Scanner.swift b/Bitkit/Components/Scanner.swift
index c62642fe4..b016bf7bc 100644
--- a/Bitkit/Components/Scanner.swift
+++ b/Bitkit/Components/Scanner.swift
@@ -412,6 +412,27 @@ struct Scanner: View {
         }
         .cornerRadius(16)
         .contentShape(Rectangle())
+        .task { // test hook
+            #if DEBUG // test hook
+                if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1", let onNearbyRequest { // test hook
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                    reviewLog("scanner appeared") // test hook
+                    for _ in 0..<18000 { // test hook
+                        guard !Task.isCancelled else { break } // test hook
+                        let input = folder.appendingPathComponent("review-nearby.txt") // test hook
+                        if let request = try? String(contentsOf: input, encoding: .utf8) { // test hook
+                            try? FileManager.default.removeItem(at: input) // test hook
+                            Task { @MainActor in // test hook
+                                reviewLog("nearby callback started") // test hook
+                                let taken = await onNearbyRequest(request) // test hook
+                                reviewLog("nearby callback taken=\(taken)") // test hook
+                            } // test hook
+                        } // test hook
+                        try? await Task.sleep(for: .milliseconds(100)) // test hook
+                    } // test hook
+                } // test hook
+            #endif // test hook
+        } // test hook
         .onAppear {
             startNearbyScanning()
             guard !cameraManager.hasPermission else { return }
diff --git a/Bitkit/Managers/ScannerManager.swift b/Bitkit/Managers/ScannerManager.swift
index e2c03ea51..08c4844cf 100644
--- a/Bitkit/Managers/ScannerManager.swift
+++ b/Bitkit/Managers/ScannerManager.swift
@@ -147,6 +147,9 @@ class ScannerManager: ObservableObject {
                     settings: settings,
                     sheetViewModel: sheets
                 )
+                #if DEBUG // test hook
+                    reviewLog("main routed; suppressed=\(app.isQuickPaySuppressed); address=\(app.scannedOnchainInvoice?.address ?? "none")") // test hook
+                #endif // test hook
                 // A refused request (e.g. an expired invoice) only shows a toast and opens no sheet.
                 didOpenScanFlow = !app.didRejectScannedPayment &&
                     sheets.activeSheetConfiguration?.presentationID != presentationBefore
@@ -259,6 +262,9 @@ class ScannerManager: ObservableObject {
                 wallet?.prepareFixedAmountOnchainSend(amountSats: invoice.amountSatoshis)
             }
 
+            #if DEBUG // test hook
+                reviewLog("send route=\(String(describing: route)); suppressed=\(app.isQuickPaySuppressed); address=\(app.scannedOnchainInvoice?.address ?? "none")") // test hook
+            #endif // test hook
             completion(route)
         } catch {
             guard isCurrent(), !(error is CancellationError) else { return }
diff --git a/Bitkit/Services/NfcReader.swift b/Bitkit/Services/NfcReader.swift
index 3056b2566..37eb86f74 100644
--- a/Bitkit/Services/NfcReader.swift
+++ b/Bitkit/Services/NfcReader.swift
@@ -43,10 +43,30 @@ 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"] == "1" { return true } // test hook
+        #endif // test hook
+        return NFCNDEFReaderSession.readingAvailable // test hook
     }
 
     func readPaymentRequest(alertMessage: String) async throws -> String {
+        #if DEBUG // test hook
+            if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" { // test hook
+                reviewLog("NFC boundary pending") // test hook
+                let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                for _ in 0..<1800 { // test hook
+                    let response = folder.appendingPathComponent("review-nfc-response.txt") // test hook
+                    if let value = try? String(contentsOf: response, encoding: .utf8) { // test hook
+                        try? FileManager.default.removeItem(at: response) // test hook
+                        reviewLog("NFC boundary response=\(value)") // test hook
+                        if value == "cancel" { throw NfcReadError.cancelled } // test hook
+                        return value // test hook
+                    } // test hook
+                    try await Task.sleep(for: .milliseconds(100)) // test hook
+                } // test hook
+                throw NfcReadError.timedOut // test hook
+            } // test hook
+        #endif // test hook
         guard isAvailable else { throw NfcReadError.unavailable }
         guard continuation == nil else { throw NfcReadError.busy }
 
@@ -120,3 +140,14 @@ extension NfcReader: NFCNDEFReaderSessionDelegate {
         }
     }
 }
+
+#if DEBUG // test hook
+    @MainActor // test hook
+    func reviewLog(_ message: String) { // test hook
+        guard ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" else { return } // test hook
+        let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+        let file = folder.appendingPathComponent("review-events.txt") // test hook
+        let previous = (try? String(contentsOf: file, encoding: .utf8)) ?? "" // test hook
+        try? (previous + "\(Date().timeIntervalSince1970) \(message)\n").write(to: file, atomically: true, encoding: .utf8) // test hook
+    } // test hook
+#endif // test hook
diff --git a/Bitkit/ViewModels/AppViewModel.swift b/Bitkit/ViewModels/AppViewModel.swift
index 7f680a6a1..9e232a514 100644
--- a/Bitkit/ViewModels/AppViewModel.swift
+++ b/Bitkit/ViewModels/AppViewModel.swift
@@ -859,6 +859,9 @@ extension AppViewModel {
         scannedDataHandlingId = handlingId
         didRejectScannedPayment = false
         defer {
+            #if DEBUG // test hook
+                reviewLog("scan finished; onchain=\(scannedOnchainInvoice != nil); lightning=\(scannedLightningInvoice != nil)") // test hook
+            #endif // test hook
             if scannedDataHandlingId == handlingId {
                 scannedDataHandlingId = nil
             }
@@ -949,7 +952,22 @@ extension AppViewModel {
             else {
                 throw ScanHandlingError.unsupportedRequest
             }
+            #if DEBUG // test hook
+                if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" { // test hook
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                    if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-hold-decode.txt").path) { // test hook
+                        reviewLog("nearby decoding held") // test hook
+                        for _ in 0..<1800 { // test hook
+                            if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-release-decode.txt").path) { break } // test hook
+                            try await Task.sleep(for: .milliseconds(100)) // test hook
+                        } // test hook
+                    } // test hook
+                } // test hook
+            #endif // test hook
             let data = try await scanPaymentOperations.decodeInvoice(uri)
+            #if DEBUG // test hook
+                reviewLog("nearby decoder returned; current=\(isCurrentScanGeneration()); retained=\(scannedOnchainInvoice != nil)") // test hook
+            #endif // test hook
             try ensureScannedDataHandlingOwnership(
                 handlingId,
                 claimedContactPaymentContext: claimedContactPaymentContext,
@@ -996,7 +1014,22 @@ extension AppViewModel {
         if let prevalidatedPaymentRequest {
             data = prevalidatedPaymentRequest
         } else {
+            #if DEBUG // test hook
+                if ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" { // test hook
+                    let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                    if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-hold-decode.txt").path) { // test hook
+                        reviewLog("NFC decoding held") // test hook
+                        for _ in 0..<1800 { // test hook
+                            if FileManager.default.fileExists(atPath: folder.appendingPathComponent("review-release-decode.txt").path) { break } // test hook
+                            try await Task.sleep(for: .milliseconds(100)) // test hook
+                        } // test hook
+                    } // test hook
+                } // test hook
+            #endif // test hook
             data = try await scanPaymentOperations.decodeInvoice(uri)
+            #if DEBUG // test hook
+                reviewLog("NFC decoder returned; current=\(isCurrentScanGeneration()); retained=\(scannedOnchainInvoice != nil)") // test hook
+            #endif // test hook
             try ensureScannedDataHandlingOwnership(
                 handlingId,
                 claimedContactPaymentContext: claimedContactPaymentContext,
diff --git a/Bitkit/ViewModels/NavigationViewModel.swift b/Bitkit/ViewModels/NavigationViewModel.swift
index 2b08cbb24..3709b0e6d 100644
--- a/Bitkit/ViewModels/NavigationViewModel.swift
+++ b/Bitkit/ViewModels/NavigationViewModel.swift
@@ -214,6 +214,9 @@ class NavigationViewModel: ObservableObject {
         didSet {
             if path != oldValue {
                 pathGeneration += 1
+                #if DEBUG // test hook
+                    reviewLog("navigation generation=\(pathGeneration); path=\(path)") // test hook
+                #endif // test hook
             }
         }
     }
diff --git a/Bitkit/Views/HomeScreen.swift b/Bitkit/Views/HomeScreen.swift
index ef082e6dc..22adf2c95 100644
--- a/Bitkit/Views/HomeScreen.swift
+++ b/Bitkit/Views/HomeScreen.swift
@@ -4,6 +4,7 @@ import UIKit
 struct HomeScreen: View {
     @Environment(CalculatorInputManager.self) private var calculatorInput
     @EnvironmentObject var activity: ActivityListViewModel
+    @EnvironmentObject var navigation: NavigationViewModel // test hook
     @EnvironmentObject var app: AppViewModel
     @EnvironmentObject var currency: CurrencyViewModel
     @EnvironmentObject var settings: SettingsViewModel
@@ -99,6 +100,22 @@ struct HomeScreen: View {
                 .allowsHitTesting(false)
                 .accessibilityHidden(true)
         }
+        .task { // test hook
+            #if DEBUG // test hook
+                guard ProcessInfo.processInfo.environment["REVIEW_NFC"] == "1" else { return } // test hook
+                let folder = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0] // test hook
+                for _ in 0..<18000 { // test hook
+                    guard !Task.isCancelled else { return } // test hook
+                    let input = folder.appendingPathComponent("review-navigation.txt") // test hook
+                    if (try? String(contentsOf: input, encoding: .utf8)) == "scanner" { // test hook
+                        try? FileManager.default.removeItem(at: input) // test hook
+                        navigation.navigate(.scanner) // test hook
+                        reviewLog("setup opened full-screen scanner") // test hook
+                    } // test hook
+                    try? await Task.sleep(for: .milliseconds(100)) // test hook
+                } // test hook
+            #endif // test hook
+        } // test hook
         .navigationBarHidden(true)
         .onAppear {
             TimedSheetManager.shared.onPrimaryScreenEntered()
diff --git a/Bitkit/Views/Wallets/Send/SendOptionsView.swift b/Bitkit/Views/Wallets/Send/SendOptionsView.swift
index 53c77d426..b2d14e8eb 100644
--- a/Bitkit/Views/Wallets/Send/SendOptionsView.swift
+++ b/Bitkit/Views/Wallets/Send/SendOptionsView.swift
@@ -128,6 +128,9 @@ struct SendOptionsView: View {
         .onChange(of: navigationPath.isEmpty) { _, isOnOptions in
             if !isOnOptions {
                 scannerVisit += 1
+                #if DEBUG // test hook
+                    reviewLog("Send visit invalidated; visit=\(scannerVisit)") // test hook
+                #endif // test hook
             }
         }
     }

Delta review: d9a0b2a…594cbab, all four changed files and reached main/Send NFC, Bluetooth, navigation, decoding and test-isolation code, plus the prior open finding. The prior head is an ancestor and the PR head remained 594cbab at the final check. No current-head device case exercised physical transport, permissions/power, advertising after restore or payment execution.

Twin: bitkit-android#1883 feat: nfc and bluetooth nearby payments, at 965ff980. The shared protocol document matches byte for byte. The linked physical pairing report applies to the earlier revisions it names.


Reviewed by gpt-6.1-sol-high

@jvsena42

Copy link
Copy Markdown
Member Author

Thanks for the device pass. About the explicit NFC action: that's how iOS works. Core NFC only reads tags inside an NFCNDEFReaderSession that the app starts from a user action, so bringing the phones together on Home can't start a read. iOS background tag reading only opens universal links for the app's associated domains. It can't deliver a bitcoin:/lightning: request. The reverse direction, Android reading an iPhone, isn't possible either, because iOS can't emulate an NDEF tag.

I've updated the merge warning at the top of the description to reference your partial pass. Fixes since d9a0b2a (594cbab, the scanner-visit fix) still need a device check.

@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 reassessment of iOS PR #1302 against its merge base at 594cbab. No baseline coverage was inherited. The PR description included earlier fix notes alongside its requirements, so discovery was not fully blind.

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

The highest-risk result is that an invalid addressless Bitcoin request can reach NFC QuickPay. A Swift probe using the PR’s invoice fixture confirmed that conflicting amount fields disappear before validation. A separate Swift/Rust probe confirmed why the lnurlp:// form in manual case 3 fails. Translation validation passed locally, and the unit CI run passed for the supplied head and base.

The GATT identifiers, framing, read offsets and backup key match the Android comparison revision. Android filters Bluetooth Lightning inputs more narrowly. The scanner, permission, Receive and TapPay states were compared with the linked design frames. The iOS privacy toggle and camera-denied UI can also have simulator journeys, as the Android twin does. The Appium suite exercises typed scanner inputs, which do not validate radio delivery.

All eight prior threads are marked resolved. The current-head routing check verifies the navigation leave-and-return fix. For manual cases 8 and 25, align the expected result with the withdrawn plain-text finding. A single ordinary text value reaches the shared scanner and gets its error there. Empty or conflicting payloads get the refusal on the NFC sheet.

Device testing: not performed in this review. The physical-device report records iPhone 13–Galaxy S22 BTC payments, iPhone NFC reads, QuickPay threshold behavior and Bluetooth confirmation on iOS d9a0b2a and Android 79e9f71. USDT reached the send flow without settlement. Retain the PR’s manual cases 1–26 for the signed physical build, including the scanner-visit change since that report.

Suggested additional test cases

  • On iPhone, interrupt a pending Bluetooth decode with Control Center, then return. The old request should leave no invoice or route, and a fresh request should still open review.
  • With two distinct wallets, leave Bluetooth enabled and disconnect the receiving iPhone from the network while Savings Receive is visible. The other phone should stop finding the request when the QR is covered and should discover the current request after recovery.

Findings

  • [HIGH] Reject duplicate amounts before extracting a Lightning invoice — inline at Bitkit/Utilities/ScannedPaymentRequest.swift:31.
  • [MEDIUM] Decode the LNURL-pay URL promised by manual case 3 — inline at Bitkit/Managers/ScannerManager.swift:427.
  • [MEDIUM] Get consent before resolving a nearby LNURL over the network — inline at Bitkit/Managers/ScannerManager.swift:358.
  • [MEDIUM] Advertise only the Receive request currently available on screen — inline at Bitkit/Views/Wallets/Receive/ReceiveQr.swift:478.
  • [MEDIUM] Invalidate pending Bluetooth delivery when the scene becomes inactive — inline at Bitkit/Services/NearbyPaymentScanner.swift:214.
  • [MEDIUM] Pause the Send scanner behind the connection-issues screen — inline at Bitkit/Views/Wallets/Send/SendOptionsView.swift:79.

Reviewer model: gpt-6.2-astra
Reasoning effort: high

}
}
guard let request = lightningParams.lazy.compactMap({ params[$0] }).first else { return trimmed }
return "lightning:\(request)"

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.

[HIGH] Reject duplicate amounts before extracting a Lightning invoice

An addressless NFC request can contain a valid, below-threshold Lightning invoice and two conflicting amount fields. The rewrite returns the bare invoice, so the decoder never sees the conflict and NFC QuickPay could pay without confirmation. A Swift 6.4.2 probe against the pinned normalizer and PosNfcFixtures.squareInvoice confirmed that amount=0.01&AMOUNT=0.02 produces the standalone invoice. Payment execution is a source prediction. Reject duplicate singleton fields before extraction and assert that neither NFC nor Bluetooth routes the invalid request. The existing required-key test covers a different condition. BIP 321 invalid URI examples

private func readNfcPaymentRequest() async -> String? {
do {
let request = try await nfcReader.readPaymentRequest(alertMessage: t("other__nfc_alert"))
return ScannedPaymentRequest.normalized(request)

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.

[MEDIUM] Decode the LNURL-pay URL promised by manual case 3

An NFC tag carrying lnurlp://merchant.example/pay would show a decoding error instead of opening the LNURL-pay amount screen. The Swift probe produced //merchant.example/pay after scheme removal. A focused Rust probe using the pinned core’s LNURL predicates and Bitcoin address parser confirmed that the remainder matches none of them. testNearbyPaymentSchemeAllowlist-style prefix checks cannot establish end-to-end support. Convert this URL form into an input the shipped decoder understands, and assert that it produces LNURL-pay data through the real scan path. Manual case 3 · Core decoder

await processSendScan(uri, scope: .paymentRequests, isCurrent: isStillCurrent) { routed = $0 != nil }
return routed
}
await processScan(uri, context: .main, scope: .paymentRequests, isCurrent: isStillCurrent)

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.

[MEDIUM] Get consent before resolving a nearby LNURL over the network

With the payment scanner open, a Bluetooth request containing a remote LNURL can cause the phone to contact that endpoint before the user selects a recipient. The payment-only path awaits decoding before it checks the decoded type. Core fetches LNURL metadata during decoding, including for a withdrawal that the app subsequently refuses. The endpoint would therefore learn the scanner’s network egress address and request timing even though no payment review was accepted. Defer remote resolution until the user selects the request, or limit automatic handling to locally decodable payment instructions. Cover a refused response with a mock transport and assert that discovery alone sends no request. Core network call · Pinned LNURL client

message: wallet.invoiceNote
))
default:
guard !receiveUnavailable(for: selectedTab) else { return nil }

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.

[MEDIUM] Advertise only the Receive request currently available on screen

Open Receive on USDT, then switch to Savings while the Bitcoin invoice refresh is pending or has failed. The view hides the QR behind a spinner or Retry, but nearbyRequest can return the previous persisted BIP 21 URI because receiveUnavailable(for: .savings) is always false. A nearby payer could see the previous amount and note while the receiver has no current QR to verify. The offline overlay also keeps an already-advertising Receive view mounted when it covers the QR. Derive advertising eligibility from the same refresh and visibility state as the displayed request. Assert that the advertiser stops during either condition and resumes with the refreshed URI. Receive display gate · Offline overlay

isDelivering = true
isScanning = false
Task { [weak self] in
let wasTaken = await onRequest(request)

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.

[MEDIUM] Invalidate pending Bluetooth delivery when the scene becomes inactive

Open Control Center while a nearby request is awaiting decoding. The scanner calls stop(), but the delivery task still runs. Its isDelivering check happens after onRequest has already had the opportunity to store the invoice and open review. The sheet ID and navigation generation can both stay unchanged throughout the interruption. The earlier navigation thread is resolved, and its Back and Send-navigation fixes are present. Scene inactivity is a separate way to stop the same delivery. Cancel the pending task or revoke its ownership on stop, and assert that completing the old decode after reactivation leaves no invoice or payment route.

}
}
},
isNearbyPaused: !navigationPath.isEmpty

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.

[MEDIUM] Pause the Send scanner behind the connection-issues screen

With a running node and Send Options open, lose network connectivity while Bluetooth stays on. The offline overlay covers Options but keeps it mounted, and the Send navigation path remains empty. A nearby on-chain request can still decode locally and append its route behind the overlay. On reconnection the user would see an unsolicited payment review for a request received while the scanner was hidden. Pass the overlay’s visibility into both the pause condition and the in-flight request check. Verify that reconnecting returns to Options and that a subsequent visible scan works. Send overlay

Copy link
Copy Markdown
Collaborator

Physical-device follow-up on 18 November 2026, supplementing the current-head code review. Cross-testing used iPhone 13 (iOS 27.0.1) and Samsung Galaxy S22 SM-S901B (Android 16) on staging/regtest:

Results combine observed screen behavior with app/system logs where available. No wallet logs or payment addresses are attached.

Passed in this session

  • Enter Manually stayed open for at least 10 seconds on both phones without an unexpected payment route. Reopening the scanner accepted a fresh request.
  • Changed Receive amounts reached the other phone correctly: iPhone → S22 over BLE, 1,000 → 2,000 sats; S22 → iPhone over NFC, 3,000 → 4,000 sats.
  • iPhone NFC recovered after both cancellation and a logged reader timeout. A cancellation/retry completed a 2,000-sat Lightning payment, iPhone Spark → Android LDK, confirmed by send/receive logs.
  • S22 NFC Receive was not readable while locked or while Bitkit was in the background; it worked after unlocking/reopening. iPhone BLE Receive was not discovered while locked or on the iOS Home screen; discovery recovered afterward. Closing Receive to Bitkit Home and reopening it also recovered.
  • With Nearby payments disabled on S22, BLE stayed silent during the check and explicit iPhone NFC still opened review. Re-enabling Nearby restored BLE discovery.
  • iPhone system Bluetooth off/on updated the scanner label and restored discovery. Android's NFC enable control opened system NFC settings and its label updated after enabling NFC.
  • Denying Android camera permission showed the permission UI while BLE still accepted an amountless request. Restoring permission restored the preview. Revoking/restoring Nearby devices permission updated the control/label and restored BLE discovery.
  • With QuickPay off, a verified fixed 3,000-sat Lightning request read over iPhone NFC opened review with swipe-to-pay and did not pay automatically. BLE input also required manual confirmation.
  • Android's USDT scanner rejected a BTC request, remained open, and accepted a subsequent USDT request from the iPhone without reopening the scanner. The USDT amount/network flow opened; no USDT payment was submitted.

Observations and separate bug

One BLE recovery after toggling Nearby payments took about 102 seconds from advertising start to a new peer connection; it recovered on its own, and a repeat was immediate. Cause remains unconfirmed.

Android Receive amount resets after background/foreground: #1971. Confirmed on this NFC build and installed mainnet 3.1.1 (197). The same 4,000-sat check retained the amount on iOS 594cbab; iOS mainnet was not checked.

Scope still open

The ordinary manual-entry and lifecycle checks did not deliberately hold an in-flight decode or payment preparation. They do not verify the new code-review findings involving cancellation, scene inactivity, recipient takeover, offline overlays or the initial saved privacy setting. The earlier controlled iOS routing checks are separate evidence.

Static/malformed NFC tags, physical POS/Square hardware, a second Android NFC reader, Android 9–11 location behavior, a specifically expired Lightning invoice, reads during invoice regeneration, and funded USDT settlement remain untested here. The rejected-BTC/valid-USDT case does not cover all USDT networks or deposit variants.

Earlier partial testing at iOS d9a0b2a / Android 79e9f71 covered successful BTC on-chain/Lightning payments and above-limit QuickPay requiring a swipe. Those results are retained at their original revisions.

This is a partial device pass. The code-review findings remain open for fixes or evidence-backed rebuttals; these results do not establish merge approval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: nfc and bluetooth payments

4 participants