Repository navigation
feat: nfc and bluetooth nearby payments - #1302
Conversation
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
[High impact] The reviewed changes appear safe to merge; the hidden-Receive advertising issue is fixed. SummaryAdds NFC payment reads and Bluetooth nearby payments, with scanner controls, Receive advertising, settings backup support, and QuickPay safeguards.
Diagram%%{init: {'theme': 'neutral'}}%%
flowchart LR
NFC[User starts NFC read] --> Scanner[Shared scanner]
BLE[Bluetooth request] --> Checks[Payment-only checks]
Checks --> Review[Normal payment review]
Scanner --> Payment[Usual payment flow]
Receive[Visible Receive page] --> Gate{Active and uncovered?}
Gate -->|Yes| Advertise[Advertise request]
Gate -->|No| Stop[Stop advertising]
Reviews (32) · Last reviewed commit: "fix: stop receive advertising under its ..." · Reviewed by Greptile |
talosmachina
left a comment
There was a problem hiding this comment.
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
.quickpaygoes throughshouldUseQuickpay, which now checksisQuickPaySuppressed; 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
.paymentRequestsrefuse 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
handleScannedDatatoasts and returns without settingdidRejectScannedPayment(expired bolt11, network mismatch,lnurlp:with the node not running),didOpenScanFlowis true,deliverclearsonRequest, 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)
There was a problem hiding this comment.
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 confirmsbitcoin:?lightning=<invoice>&req-foo=barbecomeslightning:<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, buthandleNearbyRequestreturnstrue.NearbyPaymentScanner.deliverthen clears its request handler, so later nearby requests are ignored until the scanner is reopened. The Send-sheet handler correctly returnsfalsefor 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
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 0a0d2eb8b, including affected code paths, at 8e4659c9e. Baseline: previous QA review.
No new actionable code findings.
A camera, paste, scanner manual-entry, photo-payload, or Send Enter Manually lookup that is still in flight when the app locks behind the PIN does not route and does not choose QuickPay. The lock generation is captured before the decode await and checked again before a route; Enter Manually also skips the error toast. ScannerManagerTests covers the camera and Send-scanner cases. Enter Manually routing and toast suppression are not driven by a test. Device testing: not performed in this review.
Compared only the lock-during-lookup contract with bitkit-android#1883 at fa0ebe8, not that PR as a whole. Android opens the request for review with QuickPay suppressed. This iOS change drops the route, matching its own comments.
Suggested additional test cases:
- iOS with PIN on. From the scanner, scan or paste an LNURL or Lightning address. Background the app while it is still resolving, then unlock. Send and QuickPay stay closed, and no error toast appears.
- iOS with PIN on. Send, Enter Manually, enter an LNURL or Lightning address, and tap Continue. Background the app during the lookup, then unlock. The manual-entry screen remains, with the typed value, no new route, and no error toast.
Earlier findings reconciled at this revision: 2 still present, 12 verified fixed, 2 not substantiated.
Existing concerns
- [LOW] End NFC scan ownership when its scanner visit ends — Still present. Leaving the scanner makes originCheck fail, so the finished NFC result is not routed, but isHandlingScan stays set until the system NFC session and any in-flight decode return. A new QR, paste, or NFC read then reaches beginUserScan with nearbyScanID nil and is refused. invalidateScansForAppLock bumps lockGeneration without clearing the lock, and Scanner onDisappear stops only Bluetooth. The commits since 0a0d2eb do not change handleNfcRead or handleSendNfcRead. Issue #1400 is open. The report is the review body #1302 (review); the author scoped it out of this PR in #1302 (comment). No material new evidence.
- [MEDIUM] Confirm the Bluetooth recipient before paying — Still present. connectToStrongest picks the highest-RSSI eligible advertiser, with no recipient choice or confirmation, and hands its invoice to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes. That review does not identify the intended receiver. Docs/nearby-payments.md specifies strongest-advertiser selection. NearbyPaymentScanner.swift is unchanged since 0a0d2eb. Issue #1401 is open and links the Android twin synonymdev/bitkit-android#2005. The report is #1302 (review); the author moved it to that issue in #1302 (comment). No material new evidence.
Reviewer model: grok-4.7
Reasoning effort: xhigh
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings:
No new findings in the delta. The physical iPhone check required by the PR remains open.
QA for 8e4659c:
Check: Scanner, NFC and QuickPay regressions ✅ All 408 selected XCTest cases passed on the unmodified build.
The selection included both scanner lock guards, NFC parsing and toast presentation, Bluetooth QuickPay suppression, and opening review on the Send screen attached by a same-invoice rescan.
Discard a pasted payment request from before a PIN lock ✅ The Home and Send scanners stayed open after unlock, and a fresh paste reached Send in both.
A debug hold paused a regtest Bitcoin request at the shared decoder boundary used by LNURL and Lightning-address lookups. The routing log showed the stale result was discarded and confirmed the fresh recipient.
scanner-lock2x.2x.mp4
Discard a manual payment lookup from before a PIN lock ✅ Enter Manually stayed open after a held success and a held connection error, and a fresh Continue reached Send.
The state log showed no stale recipient or toast. Debug controls held the lookup and supplied the connection error.
manual-lock2x.2x.mp4
Open a payment from the native Photos picker ✅ Selecting the verified QR opened Send for its regtest recipient using CPU-only Vision.
The unmodified iOS 26.5 simulator build selected the same image and Apple Vision reported that it could not create its inference context. The replay used Vision revision 1 on the CPU, and the routing log confirmed the recipient.
native-photo-import2x.2x.mp4
Keep photo priority within its scanner visit ✅ Leaving and reopening a scanner discarded its old photo, and nearby delivery waited for a photo still pending on the current visit.
Replayed Send Options after Enter Manually and Back, a reopened full-screen scanner, and two overlapping photo decodes. Debug controls held the decodes and supplied nearby requests. The routing logs confirmed which recipients opened.
send-options-photo-ownership2x.2x.mp4
reopen-full-scanner-photo2x.2x.mp4
concurrent-photo-ownership2x.2x.mp4
Require a swipe after QuickPay is interrupted by a PIN lock ✅ Confirm opened after unlock, and the manual swipe paid 1,000 sats once over LDK on regtest.
A debug hold paused QuickPay just before submission. The app log confirmed the reservation was released. The Lightning receiver reported the invoice open and unpaid after unlock, then settled for 1,000 sats after the swipe.
quickpay-background-swipe2x.2x.mp4
quickpay-swipe2x.2x.mp4
Manual cases 1–9 and 11–26 still need a provisioned NFC or Bluetooth iPhone and the relevant tags, terminals or peers for complete coverage. Prior hardware runs covered portions of cross-platform BTC payments, NFC cancellation and retry, edited Receive amounts, Bluetooth lifecycle, and USDT discovery. Physical QA at d9a0b2a · Physical QA at 594cbab
The no-NFC simulator behavior in manual case 10 was previously verified and its availability check is unchanged. Simulator QA at b38dbf1
Reviewed all seven delta files and rechecked the stopped QuickPay rescan. XCTest and source inspection covered the NFC wrapper and toast changes. The simulator replay settled over LDK. Spark's pre-submission checks ran in XCTest. 04fe5fb to 8e4659c · QuickPay rescan thread · Current-head QA review
Twin synonymdev/bitkit-android#1883 matches the nearby wire format and lowercase-only wrapper handling. Android opens review for a request that finishes after a PIN lock with QuickPay suppressed. iOS discards that result. Android twin
Reviewed by gpt-6.2-sol-high
pwltr
left a comment
There was a problem hiding this comment.
Consider separating scanner input handling from presentation so QR, NFC and Bluetooth share one check for whether the originating screen is still active.
Reviewed 8e4659c against f17214e.
Low: An addressed Bitcoin request with a literal lightning: in its label or message fails over NFC and Bluetooth. Bitkit/Utilities/ScannedPaymentRequest.swift:33 passes the URI through, and the checks at Bitkit/Managers/ScannerManager.swift:368 and Bitkit/Managers/ScannerManager.swift:473 allow it. BitkitCore 045c7ff then treats the whole URI as a BOLT11 invoice, so the payer never reaches review. Add this case to the existing decoder coverage and match the payment scheme at the start of the request.
Low candidate: An NFC read may display its error after the user has left the scanner or the app has locked. Bitkit/Managers/ScannerManager.swift:479 and Bitkit/Managers/ScannerManager.swift:483 post errors before the originating-visit checks at Bitkit/Managers/ScannerManager.swift:324 and Bitkit/Managers/ScannerManager.swift:343. Apply the same visit check to error feedback. A non-silent Core NFC result needs to arrive after the visit ends for the stale toast to appear.
Low: Remove the direct RSSI and size assertions at BitkitTests/NearbyProtocolTests.swift:13 and BitkitTests/NearbyProtocolTests.swift:14. The existing tests already check both sides of those boundaries through scanner eligibility and request encoding.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Cross-project review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@pwltr Thanks for the approval. Your review of 8e4659c, at 6eafe92:
Tests: 80/80 in ScannerManager and PaymentNavigationHelper tests. Nothing was run on a device. |
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings:
No new findings. Both NFC entry points now suppress app error toasts from an earlier scanner visit or PIN-lock generation. Original review · Author follow-up
QA for 6eafe92:
Check: Show NFC errors only while the originating scanner is active ✅ All 90 selected XCTest cases passed on the unmodified iOS 27.0 simulator build.
The selection covered a late Send NFC failure, active-visit error feedback, quiet cancel and timeout, and scanner routing and ownership.
Check: Discard a held NFC error after the scanner closes or the app locks ✅ Home and Send suppressed late app toasts while an active scanner still showed the expected error.
Three temporary XCTest cases held the reader result across a Home scanner close and reopen or a Send scanner lock. They used an injected NFC reader with the app source at 6eafe92.
Manual cases 1–9 and 11–26 need physical NFC or Bluetooth hardware, with the relevant tags, terminals or peers. Earlier iPhone and Galaxy runs covered parts of those cases, including BTC payments, NFC cancellation and retry, edited amounts, Bluetooth lifecycle and USDT discovery. Physical QA at d9a0b2a · Physical QA at 594cbab
Case 10's NFC availability check carries forward from the earlier simulator run. The previous simulator report also covers paste, manual entry, Photos and QuickPay. Case 10 at b38dbf1 · Simulator QA at 8e4659c
Reviewed both files in the 8e4659c to 6eafe92 delta. XCTest exercised the app toast path. Error presentation on the system NFC sheet still needs hardware.
The Android twin matches the shared NFC and Bluetooth wire formats. The app toast guard here is specific to the iOS reader session. synonymdev/bitkit-android#1883
Reviewed by gpt-6.2-sol-high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 8e4659c, including affected code paths, at 6eafe92. Baseline: previous review. Base and merge base are unchanged (f17214e), and the previous head is an ancestor of the current head. The update is one commit that changes ScannerManager.swift and ScannerManagerTests.swift. Coverage of the rest of the PR is inherited from the baseline.
No new actionable code findings.
What changed: readNfcPaymentRequest now takes the caller's visit check. handleNfcRead and handleSendNfcRead pass isStillCurrent, which is the caller's check plus originCheck. originCheck covers task cancellation, the active sheet's presentation, navigation path generation and lock generation. An NFC failure toast, or a generic error toast, now shows only while that check holds. A read that ends after the payer left the scanner, the sheet was replaced, or the app locked is logged and nothing is shown. Routing behavior is unchanged: a failed read still completes with nil on Send.
Why in-visit errors still show: the PIN lock (invalidateScansForAppLock) runs only when the app goes to the background (AppScene.swift). The iOS NFC system sheet only makes the app inactive, and the NFC read runs in an unstructured Task. So a read that fails while the user is still on the scanner keeps its toast, and the existing testFailedNfcReadCompletesWithoutRoute expectations still hold.
New test: testNfcReadErrorAfterTheScannerVisitEndsShowsNoToast holds a strong AppViewModel reference (the scanner stores app strongly). At the previous head it would have shown the noPaymentRequest toast, so it does test the change. The generic, non-NfcReadError branch has no dedicated test; it is a two-line mirror of the tested branch.
Parity: compared at the read-only pin of bitkit-android#1883 (dcabb9d). Android reads NFC through NfcReaderEffect, which is tied to the scanner composable and stops while the scanner is paused or gone (NearbyScanSources.kt). Its unreadable-tag toast therefore cannot arrive after the scanner visit either. The outcome matches; only the mechanism differs.
Limitations: source analysis only. No app build or test run was possible: only a Linux Swift toolchain is available, which cannot build this iOS app. The new call sites pass a local function as a non-escaping closure, the same way the existing processScan(isCurrent: isStillCurrent) call does. Device testing was not performed in this review.
Suggested additional test cases:
- iOS, PIN enabled, physical device with NFC. Open the Send scanner and tap NFC. While the system NFC sheet is up, background the app until it locks, then return and unlock. Expected: no NFC error toast appears after unlock, and no payment flow opens.
- iOS, physical device. On the main scanner, start an NFC read and hold a tag with no payment request. Expected: the NFC error toast still appears (the in-visit failure is unchanged).
Earlier findings reconciled at this revision: 3 still present, 8 verified fixed, 2 not substantiated.
Existing concerns
- [LOW] End NFC scan ownership when its scanner visit ends — Still present at 6eafe92. handleNfcRead and handleSendNfcRead take isHandlingScan through beginUserScan before the system NFC session starts, and clear it only in a defer when the function returns, after readNfcPaymentRequest (and any decode) finishes. Leaving the scanner makes isStillCurrent fail, so the late result is neither routed nor (new in 6eafe92) toasted, but the lock stays held. A new QR, paste or NFC read that reaches beginUserScan while nearbyScanID is nil is refused. invalidateScansForAppLock bumps lockGeneration and does not clear the lock, and Scanner onDisappear stops only Bluetooth. The only change since 8e4659c (6eafe92 'fix: drop an nfc read error once its scanner visit ended') passes isStillCurrent into readNfcPaymentRequest to gate the error toast. It does not change the lock lifetime. Introduction stays 'worsened': at the merge base f17214e only camera/paste held this lock and no NFC read existed. The PR adds NFC reads that hold it for the whole system session. Already tracked in open issue #1400. The original report is #1302 (review), and the author scoped it out in #1302 (comment). There is no material new evidence, so it should be referenced as an existing concern and not re-published.
- [MEDIUM] Confirm the Bluetooth recipient before paying — Still present at 6eafe92. connectToStrongest picks the highest-RSSI eligible advertiser, with no recipient choice or confirmation, and hands its request to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes, but that review does not identify the intended receiver. Docs/nearby-payments.md specifies strongest-advertiser selection. NearbyPaymentScanner.swift and the doc are unchanged since 8e4659c, which only touched ScannerManager.swift and ScannerManagerTests.swift. Already tracked in open issue #1401, which links Android synonymdev/bitkit-android#2005. The original report is #1302 (review), and the author moved it to that issue in #1302 (comment). There is no material new evidence, so it should be referenced as an existing concern.
- [LOW] Addressed bitcoin: request with a literal lightning: in its label fails over NFC and Bluetooth — Mechanism confirmed by source analysis. ScannedPaymentRequest.normalized returns any addressed bitcoin: URI unchanged. isNearbyPaymentRequest admits a bitcoin: URI unless it has a req- key or a non-BOLT11 lightning= pair, so a label or message containing a literal 'lightning:' passes. Both NFC and Bluetooth then pass the URI to the shared decoder. The pinned bitkit-core 045c7ff (unchanged between base and head in Package.resolved) checks contains("lightning:") before the bitcoin: branch and decodes the whole URI as a Lightning invoice. Decoding fails and the payer never reaches review. No funds move. The same input already fails over QR/paste at the merge base, so the PR does not create the decoder defect. It makes the failure reachable from two new inputs (NFC tags and nearby Bluetooth receivers), hence 'worsened'. The author scoped the fix to the decoder and tracks it in synonymdev/bitkit-core#227 (open), which is in another repository, so tracked_separately does not apply. This is already reported in the cited review with no material new evidence, so it should be referenced, not re-published.
Reviewer model: claude-opus-5-5
Reasoning effort: high
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 6eafe92 against f17214e.
Low: An addressless Bitcoin request read over NFC can open BTCPay setup from either the main scanner or Send Options. With no outer amount, Bitkit/Utilities/ScannedPaymentRequest.swift:55 promotes the Lightning field without checking that it contains an invoice. Both NFC callers (Bitkit/Managers/ScannerManager.swift:325, Bitkit/Managers/ScannerManager.swift:347) can then reach the setup handler at Bitkit/ViewModels/AppViewModel.swift:1031. The payer lands on a connection screen and must still confirm separately to connect. Validate the field before promoting it.
Low: The status pill at Bitkit/Components/Scanner.swift:284 is an enabled button even when Bluetooth permission is still needed or NFC is unavailable. Activating it does nothing in those states, including through VoiceOver. Expose the same pill as static status when it has no NFC action.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
|
@jvsena42 please resolve conflicts. |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@piotr-iohk Resolved. Merged master in 7e9881e: in |
pwltr
left a comment
There was a problem hiding this comment.
Consider reworking nearby payment parsing so validation and payment routing use the same interpretation of the URI.
Reviewed 54d7c2f against d9cf874. Both guards split Bitcoin queries on Swift Character boundaries. A combining mark immediately after ? makes the delimiter part of a larger character. Both guards then miss the query, while BitkitCore splits on the literal ? and reads the later fields.
Medium: A nearby advertiser can make a Bluetooth-authorized payment scanner resolve a nested Lightning address before the payer chooses a request. The empty-query fallback bypasses invoice validation in Bitkit/Managers/ScannerManager.swift:369. The regular payment scanner and Send Options then resolve the nested address in Bitkit/ViewModels/AppViewModel.swift:1094, exposing request timing and source network information to the endpoint.
Low: A malformed request received over NFC or Bluetooth can still open review with an unsupported req- parameter. Bitkit/Utilities/ScannedPaymentRequest.swift:116 misses the required key, and a payer who approves the on-chain invoice can pay without satisfying the required term. Extend the existing lookup and required-parameter refusal tests to cover this delimiter case.
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR at 54d7c2f, re-reviewed after the comparison base changed (f17214e → d9cf874), with target-branch changes touching files this PR changes. No coverage was carried over from earlier reviews.
No new actionable code findings.
Every changed surface was traced at the pinned head: NFC reading and NDEF parsing, the Bluetooth sending and receiving sides and their protocol, the Bluetooth request filter and the rewrite of addressless bitcoin:?lightning= requests, scan-lock handover between Bluetooth, camera QR, NFC and photo scans, PIN-lock checks (scan lock generations, cancelling a pending sheet replacement, QuickPay lock checks, the stop just before submission), QuickPay suppression, the Receive and USDT Receive advertising conditions, the scanner status pill and permission states, the TapPay intro sheet, the Nearby payments setting with its backup and restore, entitlements and Info.plist, and translations.
Validation:
- Source analysis: QuickPay is decided synchronously in
openPaymentSheet/appropriateSendRoutewhile a Bluetooth request's suppression is held, and no Send screen re-decides it later. A user scan that takes over from a Bluetooth request still decoding cancels the Bluetooth decode through the scanned-data ownership check inAppViewModel.handleScannedData. Scanning and Receive advertising cannot run behind the PIN screen, becauseMainNavViewis unmounted while locked. - Dependency check: bitkit-core 0.8.0-rc15 @ 045c7ff (the version the app pins exactly) was fetched and its
Scanner::decoderead.bitcoin:andethereum:inputs accepted byisNearbyPaymentRequestcannot reach the decoder's LNURL or Lightning-address network lookup, and the app decodes a unified URI'slightningvalue only after the local BOLT11 check. - Executed probe (Swift 6.4.2 on Linux, using the PR's
ScannedPaymentRequest.swift,NdefPayloadParser.swiftandPosNfcFixtures.swiftplusisNearbyPaymentRequestcopied unchanged): the Square/Numo fixtures pass; LNURL, Lightning-address, wrappedreq-and unified-with-req-inputs are refused; a mismatchedamountkeeps the URI addressless. This checks the pure helpers only, not an app build or runtime behavior. - CI at this head:
build-local,SwiftFormatandvalidatepassed;Run TestsandRun Integration Testswere still in progress when checked.
Parity with synonymdev/bitkit-android#1883 (pinned at bca0fa0; only these shared contracts were compared, not a full review): the Bluetooth service and characteristic UUIDs, the 3-byte meta format, 512-byte chunks, the 4096-byte limit and the -60 dBm threshold are identical. The backup key maps to Android's isNearbyPaymentsEnabled, which defaults to on on both platforms. The Bluetooth filters lead to equivalent outcomes: Android refuses a bitcoin: URI without a valid network address before decoding, while iOS lets the decoder fail with the same error toast.
Non-blocking consistency suggestions:
- The PR says
Docs/nearby-payments.mdis identical to the Android copy, but the iOS copy has an extra final paragraph about which requests Bluetooth accepts (BOLT11/USDT only; LNURL, Lightning addresses and BOLT12 refused) that Android'sdocs/nearby-payments.mdlacks at bca0fa0. Both apps behave that way, so syncing the text is enough.
Limitations:
- Device testing was not performed in this review; the simulator has neither NFC nor Bluetooth, and no iPhone ↔ Android exchange has been run by anyone (author's Gaps).
- Unverified on a device: when Bluetooth permission is first requested from the scanner, the app goes inactive and
Scannercallsnearby.stop(), dropping the Bluetooth manager while the system prompt is up. Scanning should restart when the app becomes active again; the author's case 16a covers this. - The PR description mixes requirements with write-ups of earlier review fixes, so discovery was not fully blind to that discussion.
Suggested additional test cases:
- iOS + Android: Android Receive advertising nearby. On the iPhone scanner, open the photo picker and wait over 10 s, then pick a photo of a different QR invoice. Expected: nothing opens behind the picker, and the photo's invoice opens rather than the Bluetooth one.
- iOS hardware-wallet send (Send sheet with a connected hardware wallet), with a nearby phone advertising a Lightning-only
lightning:invoice. Expected: no Lightning flow opens; the on-chain-only error toast appears and Send stays on Options. - iOS Receive on the Hardware tab with Bluetooth allowed: "Scan or tap to pay" appears, and a nearby scanner opens the hardware-wallet
bitcoin:request for review. - Restore an Android settings backup with Nearby payments off onto iOS. Expected: Security > Nearby payments is off and Receive shows no "Scan or tap to pay" label.
Earlier findings reconciled at this revision: 5 still present, 4 verified fixed, 1 not substantiated.
Existing concerns
- [LOW] End NFC scan ownership when its scanner visit ends — Still present at 54d7c2f. handleNfcRead and handleSendNfcRead take isHandlingScan through beginUserScan before the system NFC session starts. They clear it only in a defer when the function returns, after readNfcPaymentRequest and any decode. Leaving the scanner makes isStillCurrent fail, so the late result neither routes nor shows a toast, but the lock stays held. A new QR, paste or NFC read that reaches beginUserScan while nearbyScanID is nil is refused. invalidateScansForAppLock bumps lockGeneration and cancels the pending route replacement without clearing the lock. Scanner onDisappear stops only Bluetooth. Since 6eafe92, ScannerManager.swift, NfcReader.swift and Scanner.swift are unchanged; the base moved to d9cf874 through a master merge that does not touch these paths. Already tracked in open issue #1400, and the author scoped it out of this PR (#1302 (comment)). Original report: #1302 (review). No material new evidence: list it as an existing concern, do not publish it again.
- [MEDIUM] Confirm the Bluetooth recipient before paying — Still present at 54d7c2f. connectToStrongest picks the eligible advertiser with the strongest signal, without letting the payer choose or confirm the recipient, and hands its request to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes, but that review does not identify the intended receiver. Docs/nearby-payments.md specifies strongest-advertiser selection. NearbyPaymentScanner.swift and the doc are unchanged since 6eafe92. Already tracked in open issue #1401, which links Android #2005. The author moved it there in #1302 (comment). Original report: #1302 (review). No material new evidence: list it as an existing concern.
- [LOW] Addressed bitcoin: request with a literal lightning: in its label fails over NFC and Bluetooth — Still present at 54d7c2f. An addressed bitcoin:?label=...lightning:... request read over NFC or Bluetooth is passed through ScannedPaymentRequest.normalized unchanged. isNearbyPaymentRequest admits it because only lightning= values are checked. AppViewModel then passes the raw URI to bitkit-core decode. At the pinned core revision 045c7ff, which I fetched into the workspace, Scanner::decode takes the Lightning branch whenever the text contains 'lightning:', so decoding fails and the payer never reaches review. The author scoped it to bitkit-core#227 (#1302 (comment)); that issue is open, and Package.resolved still pins 0.8.0-rc15 at 045c7ff. Classified as worsened because the PR makes the existing decoder behaviour reachable from NFC tags and nearby devices. Original report: #1302 (review). No material new evidence: list it as an existing concern.
- [MEDIUM] Stop Receive advertising from restarting while a pushed route hides the QR — Raised by Greptile on the current head; the thread is unresolved and has no author reply. ReceiveQr is the root of the Receive NavigationStack. Pushing Edit (or another ReceiveRoute) calls onDisappear, which stops the advertiser, but the root view and its onChange(of: scenePhase) and onChange(of: nearbyRequest) handlers stay mounted. updateNearbyAdvertising restarts advertising whenever scenePhase is active and nearbyRequest is non-nil. Neither nearbyRequest nor updateNearbyAdvertising checks that the QR is visible or that navigationPath is empty. Trigger: with Receive showing a request, tap Edit, then make the app inactive and active again (Control Center, or background without PIN), or let the request change while Edit is open. Consequence: a nearby payer's scanner can receive and open the old request while the receiver is replacing it, and no 'Scan or tap to pay' label is on screen. This contradicts the code's own stated rule (ReceiveQr.swift:458-460: 'Only a request the payer can check on screen is offered'). The payer still reviews before paying. Expected: advertise only while the QR is visible, for example by tracking visibility in onAppear/onDisappear or requiring navigationPath.isEmpty. Basis: source analysis. It depends on SwiftUI keeping a NavigationStack root mounted and delivering environment/onChange updates while a route is pushed; that was not run on a device or simulator. A focused issue search returned no match.
- [LOW] Expose the scanner status pill as static text when it has no NFC action — Still present; pwltr's review has no author reply. The status pill is always an enabled Button. Its action returns immediately unless sources.nfc is true, and sources.nfc is false when NFC is unavailable or while the Bluetooth permission buttons are shown. In those states, tapping the pill, or activating it with VoiceOver, which announces a button, does nothing. Expected: render it as static status, or mark it disabled / drop the button trait, when there is no NFC action. Basis: source analysis. A focused issue search returned no match.
Reviewer model: claude-opus-5-5
Reasoning effort: high
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>
|
@pwltr Thanks. Both findings reproduced and are fixed in 6e2de6c.
These tests failed before the fix (4 failures) and pass after it. ScannerManagerTests, ScannedPaymentRequestTests and ReceiveNearbyOfferTests pass (70 tests). An independent review found no other place on the NFC or Bluetooth path where Swift's Twin: Android is not affected. Kotlin strings split on UTF-16 code units, so a combining mark does not join the delimiter. |
|
@piotr-iohk Thanks. The doc is synced: bitkit-android 7ebf6ef19 adds the paragraph listing which requests Bluetooth accepts, so both |
There was a problem hiding this comment.
Verdict: 💬 Comment — the head advanced before the Receive UI replays.
The PR moved to 3c26e98 after this run; these results are for 62b07d3.
Reviewed 62b07d3. The PR advanced to 3c26e98 during this run; these results apply to 62b07d3.
Findings:
- MEDIUM — Apply the visibility guard to USDT Receive too (
Bitkit/Views/Wallets/UsdtReceiveView.swift:101). With Bluetooth allowed and an eligible Paykit contact, open the USDT Receive QR, tap the header's Request Payment button, then reactivate the app while Choose recipient covers the QR. The retained USDT view still haspage == .address; its scene observer callsupdateNearbyAdvertising, which checks neither visibility nor the Receive navigation path and can serve the hidden request again. The Bitcoin guard added in 62b07d3 does not cover this sibling. This extends the existing hidden-Receive finding. Verified by source tracing; the USDT runtime case was not driven.
The Unicode delimiter fixes now check the same literal fields as bitkit-core. This addresses the two parsing findings in the previous review.
QA for 62b07d3:
Check: Reject nearby requests that hide fields behind Unicode combining marks ✅ The exact-head regression selection and generated parser checks passed.
The unmodified app and test target built on the iOS 27.0 simulator. Scanner, NFC normalization, nearby protocol, Receive eligibility and QuickPay tests passed. A separate Swift probe used the unchanged parser and filter with combining-mark variants and generated queries, comparing query fields with a byte-delimiter reference. SwiftFormat passed for the latest changed Swift files.
Keep nearby advertising stopped while editing a Receive request ⏭️ The head advanced before this UI replay started.
The new Bitcoin visibility and navigation guards were inspected and their helper tests passed. The real view's Edit, reactivation and return-to-QR wiring was not driven at this head.
Keep USDT nearby advertising stopped behind the recipient picker ⏭️ The sibling path was traced in code; the head advanced before a runtime replay.
Physical NFC/Bluetooth portions of manual cases 1–9 and 11–26 were left out because they require provisioned test iPhones, tags, terminals or peers. Earlier physical reports prove portions of BTC payments, NFC cancel/timeout recovery, changed amounts, Bluetooth lifecycle and USDT discovery at their recorded revisions:
Manual case 10's simulator NFC availability behavior is unchanged and retains its earlier evidence. The 8e4659c simulator report covers unchanged photo-visit and PIN-lock scanner behavior; QuickPay's merged paths were checked in the current XCTest selection.
Covered the contiguous 6eafe92 to 62b07d3 delta, open feedback and the master-merge interactions in QuickPay and Receive. No device case drove the new delimiter or visibility code; XCTest and source inspection covered them.
Twin synonymdev/bitkit-android#1883 matches the wire format and Bluetooth allowlist. Kotlin's delimiter splitting already treats combining marks separately; its Receive advertiser follows the navigation entry lifecycle.
Reviewed by gpt-6.1-sol-high
pwltr
left a comment
There was a problem hiding this comment.
Reviewed 3c26e98 against d9cf874.
The Receive advertisers use parent screen state that can stay eligible after the payment QR is hidden. Tie both advertisers to whether their QR is visible, including when a route or a sheet covers it.
Low: Show Details hides the QR on Bitcoin and USDT while Bluetooth can still serve the request. On Savings and Hardware, that can include the amount and note while the details show only the address. USDT can still serve the requested amount. Bitkit/Views/Wallets/Receive/ReceiveQr.swift:472, Bitkit/Views/Wallets/UsdtReceiveView.swift:82
Low candidate: The native Share sheet can leave either request readable if the Receive view stays active underneath it. USDT can also restart advertising if the app reactivates while the Paykit recipient picker covers the QR and the retained view receives the scene update. Bitkit/Views/Wallets/Receive/QrArea.swift:77, Bitkit/Views/Wallets/Receive/ReceiveQr.swift:509, Bitkit/Views/Wallets/UsdtReceiveView.swift:76
Low: The NFC error-message test repeats the production lookup keys, and the failed-read test leaves out the transport failure. Add .failed to the existing failed-read test and check the toast it presents. BitkitTests/ScannerManagerTests.swift:429, BitkitTests/ScannerManagerTests.swift:1290
Review details
Quick review
Model: Claude Opus 5.5
Reasoning effort: high
General review
Model: GPT-6.2 Sol
Reasoning effort: high
Combined review
Model: GPT-6.2 Sol
Reasoning effort: high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since 54d7c2f, including affected code paths, at 3c26e98. Baseline: previous review. Coverage of the parts this update leaves unchanged carries over from that baseline. The merge base is the same and the PR touches the same files.
Code review completed with unverified earlier concerns.
The update has three commits: Bluetooth request queries are now split the way the decoder splits them, and receive advertising stops while the QR page is covered or no longer on screen.
Query splitting. The new helpers split on the literal ? and & characters and compare prefixes character code by character code. These are queryFields, hasLiteralPrefix and droppingLiteralPrefix in ScannedPaymentRequest. Their output matches how bitkit-core 0.8.0-rc15 (045c7ff6, scanner/implementation.rs, split_once('?') / split('&')) splits the query. A combining accent right after a delimiter therefore no longer hides a req- field or a lightning= value from the Bluetooth filter or from normalized. I checked this with a standalone swiftc probe of the three helpers on Linux, run on the PR's test inputs. It confirmed the split and showed that the old Character-based split missed req-pop after ?\u{301}. The probe is not an app build or a unit-test run.
Receive advertising. ReceiveQr now advertises only when the QR page is shown, nothing covers it and the app is active. Edit or Paykit request screens pushed on the navigation path, the passphrase prompt and the Trezor pairing sheet all count as covering it. ReceiveQr is only ever the starting screen of the Receive sheet, so an empty navigation path correctly means the QR page is not covered. The sheet already gets TrezorManager, so the new environment read is safe. Android ties advertising to the QR screen and the app being in the foreground in the same way (NearbyEffects.kt at bitkit-android 7ebf6ef1). I did not do a cross-platform runtime comparison.
Validation and limits. I read the unit tests added in this update (ReceiveNearbyOfferTests, ScannedPaymentRequestTests, ScannerManagerTests) but did not run them: there is no Xcode or simulator in this environment. Whether advertising restarts after an interactive swipe back from Edit depends on when SwiftUI fires onAppear and onDisappear on the starting screen. Source code cannot settle that, so it is left to the runtime check below.
Device testing: not performed in this review.
Suggested additional test cases
- iOS, Nearby payments on, Receive open on Savings with a second phone scanning over Bluetooth: open Edit, then swipe back to the QR. Expected: the payer stops seeing the request while Edit is open and sees it again (with any edited amount) after swiping back. Repeat with a cancelled half-swipe; the request must stay hidden while Edit remains open.
- iOS, hardware-wallet Receive tab with a Trezor that needs a passphrase or pairing code: start address verification so the passphrase or pairing sheet appears. Expected: the request disappears from the paying phone while the sheet is up and comes back after the sheet closes.
Earlier findings reconciled at this revision: 7 still present, 3 verified fixed, 1 could not be verified.
Reconciliation incomplete: the following earlier concerns remain unverified. This report does not establish that they are fixed or invalid, or establish approval or device readiness.
Could not verify earlier concern — Receive request may stay readable under the native Share sheet: The reviewer marked this a candidate. Source shows QrArea presents ShareSheet through .sheet, and neither QrArea's share state nor any scene change is an input to isQrCovered or the USDT nearbyRequest. A presented sheet does not fire onDisappear on the presenter, so advertising continues. Whether that is a defect depends on runtime facts source cannot settle: how much of the QR the system share sheet covers, and whether presenting UIActivityViewController changes scenePhase. The shared content is also the same request being advertised. Without a device the consequence cannot be established. Moved by the author to open issue #1428.
Existing concerns
- [LOW] End NFC scan ownership when its scanner visit ends — Still present at 3c26e98. handleNfcRead and handleSendNfcRead take isHandlingScan through beginUserScan before the system NFC session starts, and clear it only in a defer when the function returns, after readNfcPaymentRequest and any decode. Leaving the scanner makes isStillCurrent fail, so the late result is neither routed nor toasted, but the lock stays held. A new QR, paste or NFC read that reaches beginUserScan while nearbyScanID is nil is refused. invalidateScansForAppLock bumps lockGeneration and cancels the pending route replacement without clearing the lock, and Scanner onDisappear stops only Bluetooth. The three commits since 54d7c2f change only isNearbyPaymentRequest in ScannerManager.swift; NfcReader.swift and Scanner.swift are unchanged. Tracked in open issue #1400; the author scoped it out of this PR (#1302 (comment)). Original report: #1302 (review). No material new evidence: reference it as an existing concern, do not publish it again.
- [MEDIUM] Confirm the Bluetooth recipient before paying — Still present at 3c26e98. connectToStrongest picks the eligible advertiser with the strongest signal, without letting the payer choose or confirm the recipient, and hands its request to Send. QuickPay is suppressed for Bluetooth input, so the payer still sees the normal review and swipes, but that review does not identify the intended receiver. NearbyPaymentScanner.swift is unchanged since 54d7c2f. Tracked in open issue #1401, which links Android #2005; the author moved it there in #1302 (comment). Original report: #1302 (review). No material new evidence: list it as an existing concern.
- [LOW] Addressed bitcoin: request with a literal lightning: in its label fails over NFC and Bluetooth — Still present at 3c26e98. The new literal-delimiter helpers do not change this: normalized still returns an addressed bitcoin: URI unchanged, and isNearbyPaymentRequest only checks fields that begin with lightning=. A label containing a literal lightning: is therefore admitted. AppViewModel then passes the raw URI to bitkit-core decode, which at the pinned 045c7ff takes the Lightning branch on contains("lightning:") and fails, so the payer never reaches review. Package.resolved still pins 0.8.0-rc15 at 045c7ff. The author scoped it to bitkit-core#227 (#1302 (comment)), which is open. Original report: #1302 (review). No material new evidence: list it as an existing concern.
- [LOW] Expose the scanner status pill as static text when it has no NFC action — Still present at 3c26e98; Scanner.swift is unchanged since 54d7c2f. The status pill is always a SwiftUI Button with no .disabled and no accessibility trait change. Its action returns immediately unless sources.nfc is true. sources.nfc is false when NFC is unavailable, when no onNfcRead callback exists, or when the Bluetooth permission button row is shown, because the NFC button then appears separately. In those states VoiceOver and Switch Control expose an enabled 'ScannerStatus' button that does nothing when activated. No canonical issue: a focused search of synonymdev/bitkit-ios issues for 'scanner status pill' and 'status pill NFC' returned no matches. Original report: #1302 (review). No material new evidence since the 54d7c2f publication: reference it rather than re-publishing.
- [LOW] Stop USDT Receive advertising while the payment-request recipient picker covers the QR — Verified by source analysis at 3c26e98. This is the USDT sibling of the fixed L4 mechanism, which the L4 fix does not cover. On the USDT tab, ReceiveQr renders UsdtReceiveView with contactAction = paymentRequestAction, which appends .paymentRequestRecipient to the Receive navigation path. ReceiveQr's own nearbyRequest returns nil for .usdt, so its new isQrCovered guard does not apply. UsdtReceiveView has its own NearbyPaymentAdvertiser. Its nearbyRequest depends only on settings, page == .address, deposit and the offline cover, and updateNearbyAdvertising checks only scenePhase. It stops on onDisappear when the picker is pushed. If the app goes inactive and active again while the picker covers the retained view, onChange(of: scenePhase) restarts advertising with the hidden request. Severity LOW rather than the other bot reviewer's MEDIUM: the served request is the receiver's own unchanged USDT request, so the consequence is a request being readable while not shown, with no wrong payee or amount. The thread was not driven at runtime by anyone. The author moved it to open issue #1428 (#1302 (comment)).
- [LOW] Stop Receive advertising while Show Details replaces the QR — Verified by source analysis at 3c26e98. Show Details replaces the QR with the details view, on Bitcoin tabs through ReceiveQr.showDetails and on USDT through UsdtReceiveView's own showDetails. Neither flag feeds nearbyRequest, advertisedRequest or isQrCovered, so Bluetooth keeps serving the request while the QR is hidden. The PR's own nearbyRequest doc says only a request the payer can check on screen is offered. On Savings and Hardware the served request can carry the amount and note. Consequence: a request remains readable while its QR is not shown, but it is the receiver's own current request. Moved by the author to open issue #1428.
- [LOW] Cover the NFC transport failure in the failed-read toast test — Test-coverage item, not a runtime defect. testFailedNfcReadCompletesWithoutRoute iterates cancelled, timedOut, noPaymentRequest, multiplePaymentRequests and unavailable, but not NfcReadError.failed (the transport failure). It asserts the toast description equals error.message, which is the production lookup, so a wrong
.failedmessage would not be caught there. testNfcErrorMessages checks the.failedkey directly. The author accepted adding.failedand moved it to open issue #1428.
Reviewer model: claude-opus-5-5
Reasoning effort: high
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
ethereum:requests reach their usual flows and QuickPay applies.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.bitcoin:(everylightning=part must be a BOLT11 invoice),lightning:BOLT11 invoices andethereum:(USDT). Invoices are checked locally (network prefix, amount and bech32 checksum) before decoding. LNURL and Lightning addresses are refused before decoding, since decoding contacts their server before the user picked the request, and BOLT12 offers are refused because the decoder does not read them. The decoded request must be on-chain or Lightning. Sign-in, setup, LNURL-withdraw/auth/channel, node and contact links get the usual unreadable-code toast. NFC stays unrestricted.isNearbyPaymentsEnabled.TAGformat only, which covers NDEF sessions and avoids App Store error ITMS-90778),NFCReaderUsageDescription, and the Type 4 tag AIDD2760000850101so 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
Protocol compatibility
lightning:<bolt11>lightning:/bitcoin:/LNURL tagslnurlwcardethereum:tag worksReview round
bitcoin:?…URI with a required (req-) parameter is no longer rewritten tolightning:<invoice>, which dropped that parameter. The scanner refuses it instead (0eeb163f2,testRequestWithRequiredParameterIsKept).34cd05baf,testNearbyRequestCannotRouteAfterItsScannerCloses).ebcfe41d1).6d1327632,testRefusedNearbyRequestOnMainScannerIsNotTaken).req-key with an empty or no value also keeps the URI unrewritten (6f45cef19, ported from an Android finding).e8cb89ae9).SendOptionsViewpasses the check on its own navigation path, which wasn't verified on a device.0c1486abd,6451b2820,testUserScanTakesOverFromADecodingNearbyRequest,testMainScannerQrTakesOverFromADecodingNearbyRequest). Not verified on a device.other__bluetooth_enableandother__nfc_read_buttonare in all 14 non-English locales, ported from an Android finding (d1d638977).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 throughchangeQuickpaySettingand shows the same PIN check, instead of writing the setting directly. Not driven on a device.ac7649a33,testBluetoothRequestCannotRouteWhileAnNfcReadIsOpen,testFailedNfcReadReleasesTheScanLock). Not driven on a device.testNearbyPaymentsFollowARestoredBackup).testNfcReadCannotRouteAfterItsSendSheetCloses,testNfcReadCannotRouteAfterTheSendSheetMovesOn). Not driven on a device.testNfcReadCannotRouteAfterLeavingAndReturningToTheScanner). Not driven on a device.ScannedPaymentRequestTestsandScannerManagerTestspass, 36 tests. Each new test fails without its fix.Review round (QA review of 594cbab)
amount=0.01&AMOUNT=0.02) is left as is, so the scanner rejects it instead of paying the bare invoice (023fd6550).amountdiffers from the invoice amount, or whose invoice has no amount, is rejected; a matching amount still unwraps (f4856ecde, ported from Android).lnurlp:, LNURL inside a unified URI and BOLT12 offers are refused before decoding, so discovery alone contacts no server (d10feb1bc).f63fde7f1).506d240a6).218ec0acc)..ai/validate-r19.sh). None was driven on a device.Review round (QA review of 218ec0a)
lnsb@example.com) is refused (b0dfab34a).amount,label,messageorpopkeeps the URI; unknown optional keys may repeat again. A repeatedlightningis valid BIP 321 but is kept as unsupported (1121e28c8).amountmust match the BIP grammar as a whole before it is compared with the invoice (56dc8da2e). Core gets the same checks in fix: check bip 321 amounts against the bip bitkit-core#225.ef5754ff0).f4ee7e400).06b18de2a, ported from Android)..ai/validate-r20.sh); 242 tests across 19 classes pass. None was driven on a device.Review round (QA review of 06b18de)
0e6b02caf).lightningvalue still keeps the URI (1121e28c8rule refined infda8a0a64)..ai/validate-r22.sh); 277 of 278 tests across 16 classes pass.ShopPaymentRequestTests.testSignupScannerRoutesRequireApprovalfails the same way without these commits, at its precondition that no Pubky identity is stored, which points at the local simulator keychain. None was driven on a device.Review round (QA review of 7edd6c6)
dcf446d81).bitcoin:request with anyreq-key is refused before decoding (Bluetooth) or as an unreadable tag (NFC); QR scans wait for the core bump (c2ac1bf0c).7edd6c6d4rewrites them..ai/validate-r23.sh); 279 of 280 tests across 16 classes pass, with the same keychain-dependentShopPaymentRequestTestsfailure as before. None was driven on a device.Review round (ported from bitkit-android#1883)
75b782155). This also covers camera QR scans.39499de10). A start allowed only for recovery never sends; if the payment's record is gone by the time it runs, the normal review opens (d563538e3, from Greptile). Thereq-check removes every wrapper the app or decoder strips (bitkit://, Lightning schemes, repeated) before looking for abitcoin:request (6f925e7ca, from piotr on bitkit-android#1883). Since bitkit-core deletes everybitkit://in a deep link, not only a leading one, the check now does the same, so…&bitkit://req-pop=xis refused (752726a81, from piotr on bitkit-android#1883). Master is merged in (dfcc91211). Two new tests are updated to master's QuickPay API (reserveBound(enabled:),onConfirm(SendRoute)), since CI's merge build could not compile them (ba88a7b1a, from piotr).Review round (pwltr on ba88a7b)
d2dabd5ab).727343d1d).bitkit://: thereq-check repeats the deletion until nothing changes (661559d58, from piotr on bitkit-android#1883).masterfor camera and paste scans: Scan lock outlives the scanner visit while an LNURL request is pending #1400.cc9933ac8).Review round (ovi, pwltr, piotr on cc9933a)
b4fb84402), and Bluetooth stops while the photo picker is open (d8497d69b).bitkit://scope: thereq-check deletesbitkit://only while the text starts with it, as bitkit-core does (32f2086de, from piotr on bitkit-android#1883).amount=keeps an addressless URI instead of unwrapping it (0c639f7d1).f30fe8390, ported from ovi on bitkit-android#1883).b38dbf16e). Flattened nested test closures that crashed SwiftFormat on Linux.InitializingWalletViewTests.testSlowRetryWaitsForRunningNodeBeforeCompleting(frommaster) failed once in CI..ai/validate-r30.sh). Nothing was run on a device.Review round (ovi, pwltr on b38dbf1)
488067711).LightningService.send(beforeSubmission:)on both rails, after their waits; a refused payment releases its reservation and opens the review (14033b42b).116e838af).AppErrorand is matched there too (6f31acaf8).332874c0c).c2d6456c2,08fedc7ae,8e4659c9e). Added tests for QuickPay suppression and NFC error toasts (fd1e78296).6eafe921d).bitkit://(ported from ovi on bitkit-android#1883): deleted only in lowercase, like the decoder (0a0d2eb8b).04fe5fb56).45f719ff6)..ai/validate-r31.sh). Nothing was run on a device. Each fix has a test that fails without it (.ai/validate-r29.sh,.ai/validate-r29b.sh). Nothing was run on a device. Alightning:-wrappedbitcoin:request with areq-key is refused over NFC like an unwrapped one (059f1cb41, from Greptile on bitkit-android#1883).testQuickpayChosenBeforeALockWaitsForReviewfails without the fix; 298 of 298 tests across 16 classes pass (.ai/validate-r24.sh). Not driven on a device.Master merge (7e9881e, 54d7c2f)
QuickPayPaymentCoordinator.init, both changes stay: the branch'ssubmitwith its check right before submission, and master'sneedsUpdateToSendrecheck.showingSpendingOnboarding.testASendStoppedBeforeSubmissionIsNotHeldWhileSparkCannotList; it fails when the stop leaves a Spark record). A Spark retry with a readable list is covered bytestASendStoppedBeforeSubmissionLeavesNoHold.Review round (pwltr, Greptile on 54d7c2f)
?or&no longer hides a nested Lightning address or areq-key from them (6e2de6c).testDelimiterFollowedByACombiningMarkStillSplitsTheQuery, new inputs intestNearbyAllowlistAcceptsPaymentSchemesOnlyandtestNearbyRequestWithARequiredParameterIsRefused, andtestRequestIsNotOfferedWhileEditCoversTheQr. ScannerManager, ScannedPaymentRequest, ReceiveNearbyOffer and ReceiveTabs tests pass (70 tests).POS request formats
lightning:<uppercase BOLT11>as one long-format NDEF URI record (header0xC1, identifier code0x00). Bitkit decodes it as is. Tests cover it with a real 447-character signet invoice, a 465-byte message laid out like Square's.bitcoin:?lightning=<BOLT11>. bitkit-core v0.8.0-rc15 rejects that form, so requests read over NFC or Bluetooth are rewritten tolightning:<invoice>before decoding. feat: decode BIP 321 URIs without an address bitkit-core#218 fixes this on coremaster, 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-core: abitcoin:URI withlightning:inside a value is decoded as Lightning and fails: Scanner decodes a bitcoin: URI as Lightning when a value contains lightning: bitkit-core#227nearby: choosing or confirming the recipient when several Bluetooth receivers are in range: Let the payer choose or confirm the recipient of a Bluetooth request #1401Device checks from review (Receive advertising under Edit and sheets, QA-suggested cases): Device checks for nearby payments after #1302 #1426
nearby: Receive and USDT keep advertising while Show Details, the Share sheet or the Paykit picker hides the QR, and the NFC error-toast tests: Nearby: stop Receive advertising while details or a sheet hide the QR #1428scanner: a camera or paste scan on Send that is still decoding routes after Enter Manually, as onmaster: Send scanner: a late camera or paste scan routes after Enter Manually #1424scanner: a setup or approval sheet (LNURL, BTCPay, Pubky) queued by a scan before the app locks opens after unlock, as onmaster: Scanner: a setup sheet queued before the app locks opens after unlock #1425scanner: the scan lock outlives a scanner visit while an LNURL request is pending, as onmasterfor camera and paste scans: Scan lock outlives the scanner visit while an LNURL request is pending #1400Required BIP 321 keys (
req-…) on a scanned QR code with an address open Send, as on master. NFC and Bluetooth refuse them in this PR; coremasterrefuses them for every source (feat: decode BIP 321 URIs without an address bitkit-core#218), so the core bump fixes QR: Remove the BIP 321 rewrite after the bitkit-core bump #1344.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 (
lnurlwemulation 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
bluetooth-connectedicon; the design's plain Bluetooth glyph is not in the asset catalog yet.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.
QA Notes
Setup
to.bitkit*App IDs in the Apple Developer portal.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.master:./build_ios.sh. It writesdist/ios/BitkitCore.xcframework.bitkit-corepackage with the same name.BITKIT_CORE_LOCAL=1 open -a Xcode Bitkit.xcodeproj. Core'sPackage.swiftthen uses the local xcframework instead of the rc15 release binary. Without the variable, Xcode builds themasterSwift bindings against the rc15 binary.What changes with core
master:bitcoin:?lightning=<BOLT11>in any case, open the Lightning send flow. On rc15 they show an invalid-address error.bitcoin:URIs with anyreq-parameter,req-popincluded, are rejected.Journeys
N/A — not drivable; see Manual Tests. NFC and Bluetooth are not in the Capabilities table.
Manual Tests
lightning:<bolt11>tag (above the QuickPay threshold) → Send confirm opens with the invoice — NFC not in Capabilitiesbitcoin:<address>?amount=…&lightning=<bolt11>tag → unified request opens as a QR scan would — NFC not in CapabilitiesLNURL1…orlightning:LNURL1…) → LNURL pay amount screen. A LUD-17lnurlp://…tag fails the same way its QR code does on master (fix: Error decoding some Lightning and LNURL schemes bitkit-core#70) — NFC not in Capabilitiesethereum:<address>@42161(USDT enabled) → USDT send flow — NFC not in Capabilitiespubkyauth://…or an LNURL-withdraw) → the iPhone scanner shows the unreadable-code toast, opens nothing, and keeps scanning — Bluetooth not in CapabilitiesAutomated Checks
NdefPayloadParserTests.swift: URI prefix codes, UTF-8/UTF-16 Text records, absolute URIs, ignored records, duplicates, and conflicting or empty tagsNearbyProtocolTests.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 sourceScannerManagerTests.swift:lightning:) are refused and reported as not takenNearbyProtocolTests.swift: the advertiser serves each reading phone the request it started with, clears snapshots on stop, and never starts without Bluetooth permissionEvidence
11599905d: iPhone 17 simulator (iOS 26), Xcode 26.xcodebuild test -scheme Bitkitwith 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.11599905d: each fix was checked with the targeted classes on the iPhone 17 simulator, and each new test fails without its fix. Atd9a0b2a80,ScannerManagerTestsandScannedPaymentRequestTestspass (36 tests), as doAddressTypeSettingsTestsandQuickpaySettingsTests(37 tests). The full suite for the current head runs in CI (Run Tests).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.5b510e670: CI unit selection 3247 tests, 1 skipped, 0 failures.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:
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
claude-opus-5-5(reasoning:Not exposed)claude-opus-5-5(reasoning:Not exposed)claude-opus-5-5(reasoning:Not exposed)Metadata note: the session exposes the model ID but not a reasoning-effort setting.
🤖 Generated with Claude Code