Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
dabddbc
feat: read payment requests over NFC
jvsena42 Nov 12, 2026
881969c
feat: offer and read payment requests over Bluetooth
jvsena42 Nov 12, 2026
5b510e6
fix: shorten nearby payments subtitle and update changelog
jvsena42 Nov 12, 2026
ad40016
docs: sync nearby payments spec platform table
jvsena42 Nov 12, 2026
1159990
fix: address nearby payments review findings
jvsena42 Nov 12, 2026
2577326
test: add Square and Numo NFC regression tests
jvsena42 Nov 12, 2026
7bcf5b7
chore: merge master into feat/nfc-payments
jvsena42 Nov 16, 2026
0eeb163
fix: keep bip 321 uris with required params unrewritten
jvsena42 Nov 16, 2026
34cd05b
fix: drop nearby requests once their scanner closes
jvsena42 Nov 16, 2026
ebcfe41
fix: name the scanner source buttons for voiceover
jvsena42 Nov 16, 2026
6d13276
fix: keep scanning when a nearby request opens nothing
jvsena42 Nov 16, 2026
6f45cef
fix: keep bip 321 uris with empty required params
jvsena42 Nov 16, 2026
e8cb89a
fix: drop nearby requests once the send sheet moves on
jvsena42 Nov 16, 2026
0c1486a
fix: let a user scan take over from a decoding nearby request
jvsena42 Nov 17, 2026
6451b28
fix: restore quickpay when a user scan takes over from bluetooth
jvsena42 Nov 17, 2026
d1d6389
chore: translate scanner bluetooth and nfc button labels
jvsena42 Nov 17, 2026
23f0c20
Merge remote-tracking branch 'origin/master' into feat/nfc-payments
jvsena42 Nov 17, 2026
ac7649a
fix: hold the scan lock while an nfc read is open
jvsena42 Nov 17, 2026
346f7e0
fix: reload nearby payments setting after settings restore
jvsena42 Nov 17, 2026
d9a0b2a
fix: drop an nfc request once the send sheet moves on
jvsena42 Nov 17, 2026
594cbab
fix: drop a scan once its scanner visit ends
jvsena42 Nov 17, 2026
023fd65
fix: reject an nfc request that repeats a parameter
jvsena42 Nov 20, 2026
f4856ec
fix: reject an nfc request whose amount the invoice lacks
jvsena42 Nov 20, 2026
d10feb1
fix: refuse lnurl and offers from nearby devices
jvsena42 Nov 20, 2026
f63fde7
fix: drop a bluetooth request once its scanner stops
jvsena42 Nov 20, 2026
506d240
fix: pause the send scanner behind the connection screen
jvsena42 Nov 20, 2026
218ec0a
fix: advertise only the receive request on screen
jvsena42 Nov 20, 2026
1121e28
fix: allow repeated optional bip 321 extensions
jvsena42 Nov 23, 2026
56dc8da
fix: require a well-formed amount before unwrapping an invoice
jvsena42 Nov 23, 2026
b0dfab3
fix: check a bluetooth invoice locally before decoding it
jvsena42 Nov 23, 2026
ef5754f
fix: stop the usdt advertiser behind the connection screen
jvsena42 Nov 23, 2026
f4ee7e4
fix: drop a revoked bluetooth delivery before its error
jvsena42 Nov 23, 2026
06b18de
fix: drop a scan still decoding when the app locks
jvsena42 Nov 23, 2026
0e6b02c
fix: drop a scanner route still opening when the app locks
jvsena42 Nov 23, 2026
fda8a0a
fix: skip repeated bolt12 offers beside one invoice
jvsena42 Nov 23, 2026
7edd6c6
style: avoid constructs that crash linux swiftformat
jvsena42 Nov 23, 2026
dcf446d
fix: let a lock cancel only the scan's own route
jvsena42 Nov 23, 2026
c2ac1bf
fix: refuse a nearby request with a required parameter
jvsena42 Nov 23, 2026
9c52854
refactor: record a scan's route without wrapping it in a closure
jvsena42 Nov 23, 2026
75b7821
fix: review a quickpay chosen before the app locked
jvsena42 Nov 23, 2026
059f1cb
fix: check a wrapped bitcoin request for required parameters
jvsena42 Nov 23, 2026
39499de
fix: keep a rescanned quickpay in progress on recovery after a lock
jvsena42 Nov 23, 2026
d563538
fix: send nothing from a quickpay allowed only for recovery
jvsena42 Nov 23, 2026
32b9168
style: compute the recovery-only flag before the quickpay call
jvsena42 Nov 23, 2026
6f925e7
fix: check a request behind every wrapper for required parameters
jvsena42 Nov 23, 2026
752726a
fix: refuse a req- key behind an inner bitkit:// scheme
jvsena42 Nov 23, 2026
dfcc912
chore: merge master into feat/nfc-payments
jvsena42 Nov 23, 2026
ba88a7b
test: match quickpay test calls to master's api
jvsena42 Nov 23, 2026
661559d
fix: repeat the bitkit:// deletion as the decoder does
jvsena42 Nov 23, 2026
d2dabd5
fix: hold nearby requests while a picked photo loads
jvsena42 Nov 23, 2026
727343d
fix: keep nfc and nearby reads off in node setup scanner
jvsena42 Nov 23, 2026
cc9933a
test: drop the duplicate last data uuid assertion
jvsena42 Nov 23, 2026
b4fb844
fix: let a picked photo take over a decoding nearby request
jvsena42 Nov 24, 2026
d8497d6
fix: pause bluetooth while the photo picker is open
jvsena42 Nov 24, 2026
32f2086
fix: delete bitkit:// only while the request starts with it
jvsena42 Nov 24, 2026
0c639f7
fix: keep a bip 321 request with an empty amount
jvsena42 Nov 24, 2026
f30fe83
fix: review quickpay if the app locked before it was sent
jvsena42 Nov 24, 2026
b38dbf1
test: drop ndef tests that repeat the zero-prefix case
jvsena42 Nov 24, 2026
4880677
fix: tie a picked photo to its scanner visit
jvsena42 Nov 24, 2026
14033b4
fix: check the app lock when quickpay submits
jvsena42 Nov 24, 2026
116e838
fix: hold bluetooth until every picked photo finishes
jvsena42 Nov 24, 2026
6f31aca
fix: match a submission stop wrapped by the ldk queue
jvsena42 Nov 24, 2026
332874c
style: flatten submission check closures for swiftformat
jvsena42 Nov 24, 2026
45f719f
fix: route a stopped quickpay through its current screen
jvsena42 Nov 24, 2026
04fe5fb
fix: route a stopped quickpay to the screen a rescan attached
jvsena42 Nov 24, 2026
0a0d2eb
fix: delete only lowercase bitkit:// like the decoder
jvsena42 Nov 24, 2026
c2d6456
fix: drop a camera or paste scan that outlasts a pin lock
jvsena42 Nov 24, 2026
fd1e782
test: cover quickpay suppression and nfc read error toasts
jvsena42 Nov 24, 2026
08fedc7
fix: drop an enter manually lookup that outlasts a pin lock
jvsena42 Nov 24, 2026
8e4659c
fix: skip the error toast of a lookup dropped by a pin lock
jvsena42 Nov 24, 2026
6eafe92
fix: drop an nfc read error once its scanner visit ended
jvsena42 Nov 24, 2026
7e9881e
Merge remote-tracking branch 'origin/master' into feat/nfc-payments
jvsena42 Nov 25, 2026
54d7c2f
test: cover a stopped send while spark can't list on the node path
jvsena42 Nov 25, 2026
6e2de6c
fix: split nearby request queries on the decoder's delimiters
jvsena42 Nov 25, 2026
62b07d3
fix: advertise a receive request only while its qr is shown
jvsena42 Nov 25, 2026
3c26e98
fix: stop receive advertising under its sheets and after swipe back
jvsena42 Nov 25, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Bitkit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@
INFOPLIST_FILE = Bitkit/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Bitkit;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Bitkit uses Bluetooth to connect to your hardware wallet for signing transactions.";
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Bitkit uses Bluetooth to connect to your hardware wallet and to exchange payment requests with phones nearby.";
INFOPLIST_KEY_NSCameraUsageDescription = "Bitkit needs access to the camera to scan QR codes";
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
Expand Down Expand Up @@ -1075,7 +1075,7 @@
INFOPLIST_FILE = Bitkit/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = Bitkit;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Bitkit uses Bluetooth to connect to your hardware wallet for signing transactions.";
INFOPLIST_KEY_NSBluetoothAlwaysUsageDescription = "Bitkit uses Bluetooth to connect to your hardware wallet and to exchange payment requests with phones nearby.";
INFOPLIST_KEY_NSCameraUsageDescription = "Bitkit needs access to the camera to scan QR codes";
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphoneos*]" = YES;
"INFOPLIST_KEY_UIApplicationSceneManifest_Generation[sdk=iphonesimulator*]" = YES;
Expand Down
2 changes: 2 additions & 0 deletions Bitkit/AppScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1500,6 +1500,8 @@ struct AppScene: View {
if settings.pinEnabled {
// If PIN is enabled, lock the app when the app goes to the background
incomingPaymentRequestPreparation?.suspendForAppLock(sheets: sheets)
scannerManager.invalidateScansForAppLock()
app.noteAppLocked()
isPinVerified = false
}
hwWalletManager.onAppBackgrounded()
Expand Down
21 changes: 21 additions & 0 deletions Bitkit/Assets.xcassets/Illustrations/nfc.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "nfc.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions Bitkit/Bitkit.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
<dict>
<key>aps-environment</key>
<string>development</string>
<key>com.apple.developer.nfc.readersession.formats</key>
<array>
<string>TAG</string>
</array>
<key>com.apple.developer.aps-environment</key>
<string>development</string>
<key>com.apple.security.app-sandbox</key>
Expand Down
231 changes: 222 additions & 9 deletions Bitkit/Components/Scanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,17 @@ private final class QRCodeScannerViewController: UIViewController, AVCaptureVide
private struct ScannerCornerButtons: View {
@Binding var isTorchOn: Bool
let onImageSelection: (PhotosPickerItem?) async -> Void
/// True while the photo picker is open.
@Binding var isPickingPhoto: Bool

@State private var selectedItem: PhotosPickerItem?

var body: some View {
GeometryReader { _ in
HStack {
PhotosPicker(selection: $selectedItem, matching: .images) {
Button {
isPickingPhoto = true
} label: {
Image("picture")
.resizable()
.aspectRatio(contentMode: .fit)
Expand All @@ -205,6 +209,7 @@ private struct ScannerCornerButtons: View {
.background(Color.white16)
.clipShape(Circle())
}
.photosPicker(isPresented: $isPickingPhoto, selection: $selectedItem, matching: .images)
.onChange(of: selectedItem) { _, item in
Task { await onImageSelection(item) }
}
Expand All @@ -223,17 +228,146 @@ private struct ScannerCornerButtons: View {
}
}

// MARK: - Scanner Sources

/// Which nearby sources a payment scanner is listening to, for its status pill.
struct ScannerSources: Equatable {
var nfc: Bool
var bluetooth: Bool

var statusKey: String {
switch (nfc, bluetooth) {
case (true, true): "other__scan_status_qr_nfc_bluetooth"
case (true, false): "other__scan_status_qr_nfc"
case (false, true): "other__scan_status_qr_bluetooth"
case (false, false): "other__scan_status_qr"
}
}
}

// MARK: - Scanner Status Overlay Component

/// Status pill at the bottom of the camera preview, with buttons for sources that still need the user.
///
/// iOS cannot detect NFC tags passively, so the NFC button (or the pill, when no buttons are shown) starts
/// an NFC read through the system sheet. The Bluetooth button asks for Bluetooth permission.
private struct ScannerStatusOverlay: View {
let isNfcAvailable: Bool
let showsBluetoothButton: Bool
let isBluetoothScanning: Bool
let onNfcRead: (() async -> Void)?
let onBluetooth: () -> Void

private var showsButtons: Bool {
showsBluetoothButton
}

private var sources: ScannerSources {
ScannerSources(nfc: isNfcAvailable && !showsButtons, bluetooth: isBluetoothScanning)
}

var body: some View {
VStack(spacing: 8) {
if showsButtons {
HStack(spacing: 8) {
ScannerSourceButton(icon: "bluetooth-connected", label: t("other__bluetooth_enable"), testID: "ScannerBluetoothButton") {
onBluetooth()
}
if isNfcAvailable, let onNfcRead {
ScannerSourceButton(icon: "broadcast", label: t("other__nfc_read_button"), testID: "ScannerNfcButton") {
Task { await onNfcRead() }
}
}
}
}

Button {
guard sources.nfc, let onNfcRead else { return }
Task { await onNfcRead() }
} label: {
HStack(spacing: 8) {
Image(sources.nfc || sources.bluetooth ? "broadcast" : "scan")
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
.foregroundColor(.white64)
CaptionMText(t(sources.statusKey), textColor: .white64)
}
.frame(maxWidth: .infinity)
.padding(.horizontal, 16)
.padding(.vertical, 12)
.background(Color.black50)
.clipShape(Capsule())
}
.buttonStyle(.plain)
.accessibilityIdentifier("ScannerStatus")
}
.padding(16)
.frame(maxHeight: .infinity, alignment: .bottom)
}
}

private struct ScannerSourceButton: View {
let icon: String
/// Spoken by VoiceOver, since the button shows only an icon.
let label: String
let testID: String
let action: () -> Void

var body: some View {
Button(action: action) {
Image(icon)
.resizable()
.aspectRatio(contentMode: .fit)
.frame(width: 16, height: 16)
.foregroundColor(.textPrimary)
.frame(maxWidth: .infinity)
.frame(height: 40)
.background(Color.gray5)
.clipShape(Capsule())
}
.buttonStyle(.plain)
.accessibilityLabel(label)
.accessibilityIdentifier(testID)
}
}

// MARK: - Scanner Component

struct Scanner: View {
var accentColor: Color = .brandAccent
var permissionDescription: String = t("other__camera_no_text")
@Environment(CameraManager.self) private var cameraManager
@Environment(\.scenePhase) private var scenePhase

let onScan: (QRCodePayload) async -> Void
let onImageSelection: (PhotosPickerItem?) async -> Void
/// Starts an NFC read; nil hides the NFC control (non-payment scanners, devices without NFC).
var onNfcRead: (() async -> Void)?
/// Receives a request read over Bluetooth from a nearby phone, with a check that turns false once scanning stops
/// (scanner hidden, paused, or the app inactive), and returns whether it was taken; nil turns Bluetooth scanning off.
var onNearbyRequest: ((String, @escaping () -> Bool) async -> Bool)?
/// Pauses Bluetooth scanning while something covers the scanner (for example the payment sheet it opened).
var isNearbyPaused = false

@State private var isTorchOn = false
/// The photo picker covers the scanner too: a Bluetooth request must not open Send behind it.
@State private var isPickingPhoto = false
@State private var nearby = NearbyPaymentScanner()

private var isPaymentScanner: Bool {
onNfcRead != nil || onNearbyRequest != nil
}

private var needsBluetoothPermission: Bool {
onNearbyRequest != nil && !nearby.isAuthorized
}

private var bluetoothPermissionAction: (() -> Void)? {
guard needsBluetoothPermission else { return nil }
let nearby = nearby
return { nearby.requestAuthorization() }
}

var body: some View {
ZStack {
Expand All @@ -254,7 +388,27 @@ struct Scanner: View {
isTorchOn: $isTorchOn,
onImageSelection: { item in
await onImageSelection(item)
}
},
isPickingPhoto: $isPickingPhoto
)

if isPaymentScanner {
ScannerStatusOverlay(
isNfcAvailable: onNfcRead != nil,
showsBluetoothButton: needsBluetoothPermission,
isBluetoothScanning: nearby.isScanning,
onNfcRead: onNfcRead,
onBluetooth: { nearby.requestAuthorization() }
)
}
} else if isPaymentScanner {
ScannerPermissionRequest(
accentColor: accentColor,
title: t("other__scan_to_pay_title"),
description: t("other__scan_to_pay_text"),
onRequestPermission: cameraManager.requestPermission,
onBluetooth: bluetoothPermissionAction,
onNfcRead: onNfcRead
)
} else {
ScannerPermissionRequest(
Expand All @@ -267,28 +421,87 @@ struct Scanner: View {
.cornerRadius(16)
.contentShape(Rectangle())
.onAppear {
startNearbyScanning()
guard !cameraManager.hasPermission else { return }
cameraManager.requestPermissionIfNeeded()
}
.onDisappear {
nearby.stop()
}
.onChange(of: scenePhase) { _, phase in
if phase == .active {
startNearbyScanning()
} else {
nearby.stop()
}
}
.onChange(of: isNearbyHeld) { _, isPaused in
if isPaused {
nearby.stop()
} else {
startNearbyScanning()
}
}
}

private var isNearbyHeld: Bool {
isNearbyPaused || isPickingPhoto
}

private func startNearbyScanning() {
guard let onNearbyRequest, !isNearbyHeld, scenePhase == .active else { return }
nearby.start(onRequest: onNearbyRequest)
}
}

struct ScannerPermissionRequest: View {
var accentColor: Color = .brandAccent
var title: String = t("other__camera_no_title")
var description: String = t("other__camera_no_text")
let onRequestPermission: () -> Void
/// Payment scanners also offer Bluetooth and NFC, which work without the camera.
var onBluetooth: (() -> Void)?
var onNfcRead: (() async -> Void)?

private var showsSourceButtons: Bool {
onBluetooth != nil || onNfcRead != nil
}

var body: some View {
VStack(spacing: 0) {
DisplayText(t("other__camera_no_title"), accentColor: accentColor)
VStack(alignment: showsSourceButtons ? .leading : .center, spacing: 0) {
DisplayText(title, accentColor: accentColor)
.padding(.bottom, 8)
BodyMText(description)
.padding(.bottom, 32)
CustomButton(
title: t("other__camera_no_button"),
icon: Image("camera").foregroundColor(.textPrimary)
) {
onRequestPermission()
if showsSourceButtons {
HStack(spacing: 8) {
ScannerSourceButton(
icon: "camera",
label: t("other__camera_no_button"),
testID: "ScannerCameraButton",
action: onRequestPermission
)
if let onBluetooth {
ScannerSourceButton(
icon: "bluetooth-connected",
label: t("other__bluetooth_enable"),
testID: "ScannerBluetoothButton",
action: onBluetooth
)
}
if let onNfcRead {
ScannerSourceButton(icon: "broadcast", label: t("other__nfc_read_button"), testID: "ScannerNfcButton") {
Task { await onNfcRead() }
}
}
}
} else {
CustomButton(
title: t("other__camera_no_button"),
icon: Image("camera").foregroundColor(.textPrimary)
) {
onRequestPermission()
}
}
}
.padding(.horizontal, 32)
Expand Down
10 changes: 8 additions & 2 deletions Bitkit/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,15 @@
<true/>
</dict>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Bitkit uses Bluetooth to connect to your hardware wallet for signing transactions.</string>
<string>Bitkit uses Bluetooth to connect to your hardware wallet and to exchange payment requests with phones nearby.</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Bitkit uses Bluetooth to connect to your hardware wallet for signing transactions.</string>
<string>Bitkit uses Bluetooth to connect to your hardware wallet and to exchange payment requests with phones nearby.</string>
<key>NFCReaderUsageDescription</key>
<string>Bitkit uses NFC to read payment requests from payment terminals and other phones.</string>
<key>com.apple.developer.nfc.readersession.iso7816.select-identifiers</key>
<array>
<string>D2760000850101</string>
</array>
<key>NSFaceIDUsageDescription</key>
<string>Bitkit uses Face ID to securely authenticate access to your wallet and protect your Bitcoin.</string>
<key>UIAppFonts</key>
Expand Down
9 changes: 9 additions & 0 deletions Bitkit/MainNavView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,15 @@ struct MainNavView: View {
) {
config in QuickpaySheet(config: config)
}
.sheet(
item: $sheets.nfcIntroSheetItem,
onDismiss: {
sheets.hideSheetIfActive(.nfcIntro, reason: "NFC intro sheet dismissed")
app.hasSeenNfcIntro = true
}
) {
config in NfcIntroSheet(config: config)
}
.sheet(
item: $sheets.sendSheetItem,
onDismiss: {
Expand Down
Loading
Loading