Repository navigation
feat: nfc and bluetooth nearby payments - #1883
Conversation
Payment scanners read requests from NFC tags (reader mode) and from nearby Bitkit wallets over Bluetooth LE. The Receive screen offers its request as an emulated NFC Forum Type 4 tag and over a BLE GATT service while it is on screen. Adds the TapPay (NFC) intro sheet, the scanner source states from Figma and a Nearby payments setting. Protocol in docs/nearby-payments.md. Refs #1740 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Regtest APKDownload bitkit-dev-debug universal APK (expires in 30 days). |
- Accept only bitcoin:, lightning: invoice/offer and ethereum: requests over Bluetooth; skip the device otherwise. - Stop offering and listening while the app is locked. - Show the Scan to pay panel on every payment scanner when the camera is denied. - Android 9-11: report location services off for scanning, and advertise without the location permission. - Recreate the scanner/advertiser when Bluetooth or location is switched. - Keep scanning after a delivered request, retry failed scans, and ignore callbacks from stale read sessions. - Register the NDEF tag AID only while Receive is shown and present no tag when nothing is published; owner tokens for the emitter and reader mode. - Translations, journeys, and repo conventions (nowMillis, Duration, Context.bluetoothManager, narrow lint suppressions, log wording). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Square Register serves lightning:<uppercase BOLT11> as a long-format NDEF URI record; Numo serves BIP 321 without an address. Add a real 447-char signet fixture and tests for record decoding, byte-exact encoding, chunked tag reads and the Bluetooth allowlist. bitkit-core rejects bitcoin:?lightning=<invoice> (synonymdev/bitkit-core#212), so requests read over NFC or Bluetooth are rewritten to lightning:<invoice>. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # app/src/main/java/to/bitkit/ui/settings/SettingsScreen.kt
[High impact] The PR appears safe to merge; no new blocking issue was established. SummaryAdds NFC and Bluetooth payment reads, nearby requests on Receive, scanner controls, and a one-time NFC introduction.
No new actionable issue was established. This review did not run builds, tests, or device checks. Diagram%%{init: {'theme': 'neutral'}}%%
flowchart TD
Receive[Visible Receive request] --> NFC[NFC tag service]
Receive --> BLE[Bluetooth advertiser]
NFC --> NfcCheck[Rewrite and reject required parameters]
BLE --> BleCheck[Rewrite and check payment-only request]
NfcCheck --> Scan[Shared scan flow]
BleCheck --> Review[Payment review]
Scan --> Eligible{QuickPay allowed?}
Eligible -->|No| Review
Eligible -->|Yes| Lock[Check wallet lock before sending]
Lock -->|Allowed| Pay[Submit payment]
Lock -->|Stopped| Review
Reviews (26) · Last reviewed commit: "docs: list the requests bluetooth accept..." · Reviewed by Greptile |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
talosmachina
left a comment
There was a problem hiding this comment.
1 finding (1 P1). Adds NFC reading on the payment scanners, HCE Type 4 tag emulation on Receive, and a BLE GATT request exchange between Bitkit phones. Reviewed 4d5af8435, oversized tier (65 files, about 3,000 lines): I read the security-relevant paths in full (the NFC and Bluetooth transport, the request filter and rewrite, the QuickPay suppression plumbing into AppViewModel, the manifest and HCE service) and did not review the UI, sheet, string and resource changes.
- P1: the Bluetooth payment-only filter is applied before the
bitcoin:?lightning=rewrite, so LNURL auth, withdraw and channel requests from any nearby advertiser reach their sheets.
Build: not built here. This review answers in public, where no packages token is available for the Gradle build, so CI is the gate. At the time of review build reported failure because its upstream jobs were cancelled (BUILD_RESULT: cancelled), and build-and-test, compose-ui / ui-tests and lint were still pending, so CI says nothing yet either way.
What I checked, and 6 candidates I ruled out
Read in full: NearbyScanner.kt, NearbyAdvertiser.kt, NearbyProtocol.kt, NearbyRequestFilter.kt, NfcPaymentUri.kt, NdefCodec.kt, Type4TagEmulator.kt, NfcTagEmitter.kt, NfcRepeatGuard.kt, NdefTagService.kt, NfcEffects.kt, NearbyEffects.kt, NearbyScanSources.kt, the AppViewModel diff and the launchScan/handleScan/handleDecodedScan path, MainActivity diff, manifest and ndef_tag_service.xml.
Ruled out
- HCE serving while locked or off-screen:
requireDeviceUnlock="true", the AID is registered only while Receive is resumed,offerPaymentNearbydrops the URI whileLocalIsAppLocked, and the emulator answers SELECT with 6A82 when nothing is published. - Stale publisher clearing a newer request:
NfcTagEmitter.clearis token-checked with compare-and-set;NfcTagEmitterTestcovers it. - NDEF parser out-of-bounds on a hostile tag: every read is inside
runCatchingindecodeTexts, and a negative long length is rejected. - BLE read overflow or wrong reassembly: length capped at 4,096 bytes by
requestLength,decoderejects a size mismatch, each session has an 8 s timeout. - QuickPay on a Bluetooth read:
isNearbyreachessuppressQuickPayon all three scanner routes (SendRecipientScreen,QrScanningSheet,SendSheetQR route); the USDT scanner goes to its own recipient path, which has no QuickPay. - Channel-wait skip paying through the wrong rail:
waitForUsableChannelsnow skips only whencanSendWithSpark(amount)is true, and the followingcanSendcheck is unchanged. - Cold reader: the P1 stood (traced the same chain to
onScanLnurlAuth).
Merge confidence: 3/5, the oversized tier caps it there, and the open P1 on the Bluetooth filter would hold it at 3 on its own.
Reviewer model: claude-opus-5-5, xiaomi/mimo-v2.6-pro (cold reader)
Reasoning effort: Not exposed (the run metadata carries no effort setting for either)
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 Resolved in d8a0dae (merge of
After the merge, the full unit suite passes (6,566 tests), detekt is clean, and |
There was a problem hiding this comment.
Verdict: ⛔️ Request changes. QuickPay authorization can expire while an LDK send is still queued.
The PR moved to d8a0dae after this run; these results are for 70bd2a7.
Findings:
- HIGH
QuickPayRepo.kt:405. The new guard runs before LDK queues the native send. Wallet sync shares that serial queue and can block it, so the wallet can lock before the queued send begins. Check authorization at the native submission boundary and unwind the unsent operation and its reservation if authorization expired. Keep tracking already submitted payments. - MEDIUM
AppViewModel.kt:8357. The fallback validates the amount once from a cached spending limit. QuickPay can reach this screen before LDK publishes the limit, including when Spark already covers the payment. The one-time false stays in Confirm after sync and keeps Swipe to Pay disabled. This also overwrites the true flag that fixed LNURL-pay already set. Use the normal manual preparation path or update validation when the payment's spending limit changes. - LOW
NfcPaymentUri.kt:92. The guard removes mixed-case occurrences of the Bitkit scheme when peeling a wrapper. The shipped decoder's replacement is case-sensitive. An optional query key can therefore be mistaken for a required key and a payable NFC request rejected. Mirror the decoder's case handling when normalizing Bitkit wrappers.
QA for 70bd2a7:
Check: Check QuickPay and nearby request regressions ✅ The pinned build passed the NFC, nearby-request, QuickPay repository, QuickPay view-model and Send unit suites.
Handle an addressless Lightning request from an NFC launch ✅ A valid NFC launch intent opened Bitcoin Amount. Adding an empty amount showed Decoding Error and left Home visible.
The launched Android activity received a synthetic NFC intent.
Review a fixed Lightning invoice after the wallet locks ⏭️ The PR advanced before the recorded lock and unlock case. The pinned unit tests covered authorization and the funded fallback.
Review an under-limit Lightning request received over Bluetooth ⏭️ The PR advanced during wallet setup. The payer channel was funded, and the earlier review records this Bluetooth flow.
Physical NFC tag reads, TapPay on NFC hardware, Square Register and Android–iPhone transport require devices with the corresponding hardware.
Earlier on-device evidence
- Settings, Bluetooth lock and permissions. Settings and Bluetooth
- Scanner permissions and Android 11 Location settings. Scanner permissions
- Funded Bitcoin Amount and Lightning confirmation. Prior review
Reviewed the six-commit delta and the earlier QuickPay and NFC findings. The LDK queue, cold-balance fallback and mixed-case NFC findings come from source review. 535efc4..70bd2a7
The iOS twin carries the same wrapper, empty-amount and QuickPay preparation fixes. The LDK queue finding is specific to Android. synonymdev/bitkit-ios#1302
Inline notes:
app/src/main/java/to/bitkit/repositories/QuickPayRepo.kt:405: HIGH — Keep QuickPay authorization current while the LDK send is queued
The new guard runs before LDK queues the native send. Wallet sync shares that serial queue and can block it, so the wallet can lock before the queued send begins. Check authorization at the native submission boundary and unwind the unsent operation and its reservation if authorization expired. Keep tracking already submitted payments.
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt:8357: MEDIUM — Revalidate the QuickPay fallback when spendable balance becomes available
The fallback validates the amount once from a cached spending limit. QuickPay can reach this screen before LDK publishes the limit, including when Spark already covers the payment. The one-time false stays in Confirm after sync and keeps Swipe to Pay disabled. This also overwrites the true flag that fixed LNURL-pay already set. Use the normal manual preparation path or update validation when the payment's spending limit changes.
Reviewed by gpt-6.2-sol-high
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: full PR at cafc812e1, re-reviewed after the comparison base changed from 5fa540e to 2c70a74 and target-branch changes touch reviewed files.
4 actionable findings — resolve or provide an evidence-backed rebuttal.
A tag tap while Bitkit is already open does not hold NFC, so a later discovery of that tag starts another scan. The Bluetooth filter also accepts bitcoin: with no address and a BOLT11-shaped value that fails a checksum, and both go through the scan path that resets send state and closes the sheet. A QuickPay lock abort on the node queue records an LDK send hash before the payment is refused, which blocks a later Spark payment of that invoice until the node can list payments.
Compared with bitkit-ios#1302 at 0a0d2eb8, scanner acceptance only. iOS checks a BOLT11 checksum; this filter checks bech32 shape. iOS also accepts a bitcoin: URI with an empty query. iOS NFC reads are user-started, so the foreground intent path was not compared as the same flow. This is not a review of the iOS PR.
Device testing: not performed in this review. Unit tests were read and not run. A focused issue search on synonymdev/bitkit-android returned no matching issue.
Suggested additional test cases
- Android, wallet already unlocked on the home screen: tap a payment tag and keep the phones together through a brief field drop. Expected: one payment flow, and the sheet does not open again.
- Android, Send scanner open: a nearby device advertises
bitcoin:andlightning:plus a BOLT11-shaped string with a bad checksum. Expected: the scanner stays open and the current send is unchanged. - Android, QuickPay on, channels can pay, lock the wallet while the node send is still queued, background the app so the node is not runnable, then unlock and swipe the same invoice while Spark can pay. Expected: the swipe is not refused as an earlier node send.
Earlier findings reconciled at this revision: 1 still present, 4 verified fixed, 2 tracked separately outside this PR.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base 2c70a74 and head cafc812, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt are the same blobs. No changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The Receive code this PR adds only selects the existing invoice for a nearby offer and never writes an amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), tracked by the same open issue #1971. Between merge base 2c70a74 and head cafc812, the files that reset the Receive amount are unchanged. The PR's Receive changes only read the existing invoice for nearby offering. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Findings
- [MEDIUM] Hold NFC after a tag tap while the app is already open — inline at
app/src/main/java/to/bitkit/ui/MainActivity.kt:326. - [MEDIUM] Refuse a bitcoin URI that has no address over Bluetooth — inline at
app/src/main/java/to/bitkit/nearby/NearbyRequestFilter.kt:31. - [MEDIUM] Reject a nearby BOLT11 value whose checksum fails — inline at
app/src/main/java/to/bitkit/nearby/NearbyRequestFilter.kt:11. - [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — inline at
app/src/main/java/to/bitkit/repositories/LightningRepo.kt:1797.
Existing concerns
- [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — The discussion #1883 (comment) is marked resolved. Its latest reply, #1883 (comment), moves the design choice to open issue #2000 and keeps the current scanner behavior in this PR. At cafc812 an enabled adapter still counts as active NFC, except while nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled and stops polling while the camera is open would still show an NFC status and would still have no in-scanner tap action. The Pixel 11 observation remains the author's. This PR still introduces the status claim relative to 2c70a74, so the concern stays open and is tracked by #2000. There is no material new defect evidence. This check is source inspection.
Reviewer model: grok-4.7
Reasoning effort: xhigh
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict: 💬 Comment. Two earlier findings remain open at 6a97430. Device QA carries forward to the new head.
The PR moved to fa0ebe8 after this run; these results are for 6a97430.
Findings:
- MEDIUM
LightningRepo.kt:1835. At6a97430, a stopped QuickPay attempt can leave a new LDK hash when an earlier attempt's persisted hash is already gone but its in-memory generation remains. The new hash can block a manual Spark retry while LDK cannot list payments. Cleanup can also briefly remove a concurrent LDK send's persisted hash because removal and restoration are separate writes. The author reverted this cleanup infa0ebe8, which leaves the original retry refusal. Existing LDK thread · Revert explanation - MEDIUM
NearbyRequestFilter.kt:43. A nonempty address with an invalid checksum passes the filter when it consists of letters and digits. The decoder then rejects it after the scan has reset Send. Validate the Bitcoin address locally before handing the request to the scanner. Existing Bluetooth address thread
QA for 6a97430:
Check: Verify nearby parsing, QuickPay authorization and LDK send records ✅ The regtest APK built and the focused NFC, nearby, Lightning, QuickPay and Send unit suites passed.
Open a payment with mixed-case NFC metadata ⏭️ The head advanced before the foreground NFC-intent check.
Review a fixed Lightning invoice after the wallet locks ⏭️ The head advanced before the queued LDK send and manual fallback could be driven.
Review an under-limit Bluetooth Lightning request ⏭️ The head advanced before the Bluetooth payment could be rerun through the new filter.
Ignore nonpayment Bluetooth requests ⏭️ The head advanced before the Bluetooth filter could be checked on a device.
Physical NFC reads, the TapPay introduction and NFC setting on an NFC-capable phone, Square Register and Android–iPhone transport require hardware. Earlier Android results cover the unchanged Nearby payments setting, scanner permission UI and Android 11 Location settings. Earlier physical cross-platform checks are partial. Android settings and Bluetooth · Scanner permissions · Physical Android and iPhone tests
Reviewed d8a0dae..6a97430 and prior open threads. Source review confirmed the LDK submission guard, fixed-invoice amount handling, NFC wrapper handling and Bluetooth BOLT11 checksum check. Delta
The twin uses the same nearby wire format and BOLT11 checksum rule. The Android delta adds its submission check at the LDK boundary. synonymdev/bitkit-ios#1302
Reviewed by gpt-6.2-sol-high
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
Verdict: 💬 Comment. The address check at 7dcc947 dropped valid uppercase SegWit requests. The next commit addresses the casing issue in code. Device QA carries forward to dcabb9d.
The PR moved to dcabb9d after this run; these results are for 7dcc947.
Findings:
- MEDIUM
NearbyRequestFilter.kt:47. The new Bluetooth filter passes the original address to bitkit-core 0.8.0-rc15, whose address validator recognizes lowercase SegWit prefixes only. The payment decoder normalizes those prefixes and their addresses before validation. As a result, a valid uppercase SegWit URI is dropped before Send opens. The unit test for 7dcc947 mocks uppercase validation as successful. The invalid-checksum rejection holds, and dcabb9d applies the decoder's normalization while preserving Base58 case. Pinned decoder test · Follow-up
The earlier LDK retry concern remains. A QuickPay attempt stopped before native submission keeps its send hash. A manual Spark retry can be refused until LDK can list its payments. The author retained the hash to protect payment deduplication and tracked the shared bookkeeping in #2011. Existing LDK thread
QA for 7dcc947:
Check: Nearby parsing, NFC and QuickPay regressions ✅ The regtest APK built and the focused NFC, nearby, Lightning, QuickPay and Send unit suites passed.
Open valid Bluetooth Bitcoin requests and ignore invalid addresses ⏭️ The PR advanced before the lowercase, uppercase and bad-checksum device controls ran.
Review an under-limit Bluetooth Lightning request ⏭️ The PR advanced before the funded Bluetooth review ran.
Ignore nonpayment Bluetooth requests ⏭️ The PR advanced before the Bluetooth rejection case ran.
Open a payment with mixed-case NFC metadata ⏭️ The PR advanced before the simulated NFC intent ran.
Review a fixed Lightning invoice after the wallet locks ⏭️ The PR advanced before the queued LDK send and manual fallback ran.
Physical tag reads, NFC card emulation, the NFC intro and setting, Square Register and cross-platform transport require hardware. Previous reports cover the unchanged Nearby payments setting and scanner permission UI, including Android 11 Location settings. Prior Android QA · Scanner permissions · Partial hardware results
Reviewed the contiguous delta from fa0ebe8 to 7dcc947 and the prior open review thread. Address validation was checked in source against the pinned native library. Delta
The twin shares the Bluetooth wire format and delegates Bitcoin address parsing to the decoder. The added preflight at 7dcc947 is Android-specific. synonymdev/bitkit-ios#1302
Reviewed by gpt-6.2-sol-high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: changes since cafc812, including affected code paths, at dcabb9d. Baseline: previous review. The merge base is unchanged and the previous head is an ancestor of this one. The current PR diff was re-inventoried. Coverage of files unchanged since the baseline is inherited, not freshly re-read.
No new actionable code findings.
The update tightens the Bluetooth request filter. It replaces the BOLT11 regex with a bech32 checksum check, and it requires a bitcoin: URI to carry an address that bitkit-core validates for this wallet's network. Bech32 addresses are normalized to lowercase and base58 addresses keep their case. It also moves isStoppedAtSubmission into Errors.kt with no change in behaviour and adds a LightningRepo test showing that a send stopped at submission keeps an earlier send's hash. The commits that changed LightningRepo itself were reverted, so it matches the baseline.
Validation:
- Checksum probe: a
kotlincscript ran the PR'sisBolt11Invoiceagainst the real signet fixture invoice, a mainnet BOLT11 spec vector and its uppercase form. All were accepted, and a corrupted vector was rejected. This is a focused probe, not the unit suite or an app build. - Decoder comparison: bitkit-core v0.8.0-rc15, the version the app pins, was checked. Its scanner normalizes bech32 and base58 addresses the same way and validates them with the same
validate_address. The app scanner applies the samevalidateBitcoinAddressandNetworkValidationHelpercheck. So the filter refuses no address that the scanner would accept, and a regtest wallet still accepts testnet-prefix addresses. - Address-less URIs: a
bitcoin:URI without an address is still rewritten tolightning:or refused, as at the baseline.
Parity: the iOS twin #1302 at 8e4659c checks BOLT11 values but does not validate the on-chain address in its nearby filter. iOS shows an unsupported-request error for a refused request, while Android ignores it and keeps scanning, so this is a deliberate platform difference and not a defect on this PR.
Limitations: for this head, the unit and Compose UI CI jobs were still pending. The failed build check came from a cancelled run that a newer run superseded, so it is not evidence about this code. Unit tests were not run locally.
Device testing: not performed in this review.
Suggested additional test cases:
- Android, regtest build, Bluetooth nearby on: on a second device, advertise a
bitcoin:URI with a mainnet address. Expected: the scanner ignores it, Send is not reset, and scanning continues. - Android: advertise
BITCOIN:<UPPERCASE BCRT1 ADDRESS>?LIGHTNING=<UPPERCASE BOLT11>. Expected: the normal review opens with the Lightning request. - Android: advertise
lightning:with a BOLT11 invoice whose last character is changed. Expected: it is ignored and scanning continues.
Earlier findings reconciled at this revision: 2 still present, 5 verified fixed, 1 not substantiated, 2 tracked separately outside this PR.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base 2c70a74 and head dcabb9d, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt have no diff, and no changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The PR's Receive code only selects the existing invoice for a nearby offer and writes no amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), and the same open issue #1971 tracks it. Between merge base 2c70a74 and head dcabb9d, the files that reset the Receive amount are unchanged. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Existing concerns
- [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — Mechanism still present at dcabb9d. An enabled adapter still counts as active NFC reading unless nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled but stops polling while the camera is open (the author's Pixel 11 observation) would still show an NFC status and has no in-scanner way to release the camera for a tap. Thread #1883 (comment) is marked resolved; its latest reply (#1883 (comment)) moves the design decision to open issue #2000 and keeps the current scanner behaviour in this PR. Because this PR introduces the status claim, the concern stays open and is tracked by #2000. No scanner or NfcEffects file changed since the previously reviewed head cafc812, so there is no material new evidence; reference it as an existing concern rather than re-publishing inline. Source inspection only; the hardware observation is the author's.
- [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — Mechanism still present at dcabb9d. The author's cleanup attempts (3ae50d7, 6a97430) were reverted in fa0ebe8, and LightningRepo.kt is unchanged since cafc812. A QuickPay node send stopped at submission on the LDK queue keeps its persisted LDK send hash. A later Spark payment of the same invoice is refused with NodeNotStarted while the node cannot list payments, and works again once a listing clears the hash. No funds move twice; the consequence is a refused retry with a workable recovery, so MEDIUM is kept. Thread #1883 (comment) is unresolved. The author declined the change: removing the record can erase a real earlier or concurrent node send of the same invoice, because admitSend lets repeat node sends through and ldkSendsInFlight is shared, so Spark could pay twice. The author tracks that shared bookkeeping gap in open issue #2011. ovi-reviewer acknowledged the revert and that the original retry refusal remains. The finding's original 'expected' remedy (unconditionally remove the hash) is therefore not safe as written; a correct fix needs per-attempt ownership of the record, which depends on #2011. The new LightningRepoTest case guards the double-payment side, not this refusal. There is no material new defect evidence; reference the existing thread rather than re-publishing inline.
Reviewer model: claude-opus-5-5
Reasoning effort: high
|
@jvsena42 please resolve conflicts. |
# Conflicts: # app/src/main/java/to/bitkit/repositories/LightningRepo.kt
|
@piotr-iohk Resolved in bca0fa0 (merge of After the merge, the full unit suite passes (6,594 tests), detekt is clean, and |
There was a problem hiding this comment.
Verdict:
The PR moved to bca0fa0 after this run; these results are for dcabb9d.
Findings:
No new findings. The Bluetooth preflight now accepts uppercase SegWit and refuses addresses for an incompatible network before changing the Send screen. Address-validation thread
The earlier manual Spark retry can still be refused while LDK cannot list its payments. The shared send bookkeeping is tracked in #2011. Existing LDK thread
QA for dcabb9d:
Tested with the pinned bitkit-core on regtest Android 15 emulators. A debug-only peer supplied the Bluetooth payload controls.
Check: Nearby parsing, NFC and QuickPay regressions ✅ The pinned regtest APK built and the focused NFC, Bluetooth, Lightning and QuickPay suites passed.
Open valid Bluetooth Bitcoin requests and ignore invalid addresses ✅ Lowercase and uppercase SegWit requests opened Bitcoin Amount. The Bluetooth scanner logged and ignored the bad checksum and wrong-network requests while Send stayed open.
Review an under-limit Bluetooth Lightning request ✅ With QuickPay enabled at $5, the 1,000-sat standalone and uppercase unified Bluetooth requests opened Swipe To Pay. The scanner logged and ignored the bad invoice checksum.
Ignore nonpayment Bluetooth requests ✅ The Bluetooth scanner logged and ignored plain text without leaving Send. A valid Bitcoin request then opened Bitcoin Amount.
Open a payment with mixed-case NFC metadata ✅ A simulated NFC launch with mixed-case optional metadata opened Bitcoin Amount. An unsupported required parameter showed Unable To Read NFC and left Home visible.
Review a fixed Lightning invoice after the wallet locks ⏭️ The PR advanced before the held LDK send and manual fallback could be exercised.
Physical tag reads, card emulation, the TapPay intro, Square Register, and the remaining Android–iPhone transport cases need compatible hardware. The existing reports cover the unchanged settings and scanner-permission journeys, Android 11 Location settings, and Bluetooth advertising when disabled or locked. Android QA · Scanner permissions · Physical-device results
Reviewed 7dcc947..dcabb9d and the open LDK thread. Base58 case preservation was checked in the pinned decoder and filter source. Independent QA review
The iOS twin shares the Bluetooth wire format and validates Bitcoin addresses during decoding. Android checks address validity before handing the request to Send. synonymdev/bitkit-ios#1302
Reviewed by gpt-6.2-sol-high
piotr-iohk
left a comment
There was a problem hiding this comment.
QA review
Scope: full PR at bca0fa0, re-reviewed after the comparison base changed (2c70a74 → ddd0718) and target-branch edits touched LightningRepo, LightningService, Errors, and LightningRepoTest.
No new actionable code findings.
At this revision an NFC read uses the same scan path as a QR code, including QuickPay. A Bluetooth read is limited to a payable bitcoin URI, a BOLT11 invoice, or an ethereum URI, and it opens review. A scan that crosses the lock opens review. The node send checks the lock again on the LDK queue before submission. Receive offers the request on screen and stops while the app is locked or offline.
Compared the shared nearby contract with bitkit-ios#1302 at 6eafe92. This is not a review of that PR. The service UUID, 512-byte chunks, addressless bitcoin:?lightning= rewrite, req- refusal, and Bluetooth QuickPay suppression match. Android's Bluetooth filter also requires a bitcoin address on the wallet's network; iOS leaves the address to the scanner. Android closes and replaces the GATT server when the offered URI changes; iOS keeps the server and snapshots the request when the payer reads meta. A payer does not receive a mix of two requests on either side.
Device testing was not performed in this review. The author reports just compile, just test, and just lint on 28639c4e7, and device runs on earlier builds (case 15 on 2336ef1ca, against bitkit-core master). Those results are not this head. This review read the unit tests and did not run them.
Recommended before device testing: Repeat cases 1, 1a, 5, and 15 on this head. Their recorded results are from earlier builds, and this revision merges newer master changes into the Lightning send and channel-wait path.
Ready for device testing of the remaining PR cases: 1b, 2–4, 6–14, J1, and J2. Cross-platform Bluetooth and NFC (7, 8) and Square Register (11) are still unchecked.
Suggested additional test cases
- Android, QuickPay on, spending balance covers the invoice. Tap an NFC request so QuickPay starts, then lock the app before it finishes. The payment stays in the wallet and the swipe review opens.
- Android, wallet locked on the PIN screen. Tap a nearby Receive phone or a lightning tag, then unlock. The request opens the review and QuickPay does not pay it.
Earlier findings reconciled at this revision: 2 still present, 2 tracked separately outside this PR.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base ddd0718 and head bca0fa0, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt are the same blobs. No changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The PR's Receive code only selects the existing invoice for a nearby offer and writes no amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), and the same open issue #1971 tracks it. Between merge base ddd0718 and head bca0fa0, the files that reset the Receive amount are unchanged. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Existing concerns
- [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply moves the design choice to open issue #2000 and keeps the current scanner behavior in this PR. At bca0fa0 an enabled adapter still counts as active NFC, except while nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled and stops polling while the camera is open would still show an NFC status and would still have no in-scanner tap action. The Pixel 11 observation remains the author's. The scanner and NfcEffects files are unchanged since dcabb9d, so there is no material new defect evidence. This stays an existing open concern of this PR, tracked by #2000. This check is source inspection.
- [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply, #1883 (comment), says the revert in fa0ebe8 leaves the original retry refusal while the node cannot list payments. At bca0fa0 a QuickPay node send still writes the LDK send hash before lightningService.send. A false isAuthorizedAtSubmission throws PaymentStoppedAtSubmission on the LDK queue before bolt11Payment().send. The failure path releases that attempt's in-flight count and does not remove the hash. QuickPay falls back to review with isMarkedDispatched true and leaves the cache hash in place. A later Spark payment of the same invoice throws NodeNotStarted while the node cannot list payments, until a listing that shows no send removes the hash. The master merge in this head changes ldkSendsInFlight from a set to a per-key count, which closed #2011. That count is released when the stopped send returns. The persisted hash is still one record per invoice and is still kept. Issue #2011 covers the in-flight count, a different mechanism, and its closure does not remove this hash. The author's decline of unconditional removal still matches LightningRepoTest, which expects an earlier send's hash to stay. No funds move twice. The consequence remains a refused Spark retry with a workable recovery, so MEDIUM stays. There is no material new defect evidence, so reference the existing discussion rather than re-publishing it inline. This check is source inspection.
Reviewer model: grok-4.7
Reasoning effort: xhigh
|
Device run on
Findings:
🤖 Generated with Claude Code |
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 bca0fa0, including the new Bluetooth acceptance paragraph and the filter path it describes, at 7ebf6ef. Baseline: previous QA review. Unchanged nearby-payment behavior remains covered by that baseline.
No new actionable code findings.
The added paragraph in docs/nearby-payments.md matches nearbyPaymentRequest: a payable bitcoin: URI is passed on only when every lightning parameter is a BOLT11 invoice, a lightning: value is passed on only when it is a BOLT11 invoice, and an ethereum: URI is passed on. LNURL, Lightning addresses, and BOLT12 offers are not handed to the scanner. NearbyRequestFilterTest already asserts those accept and refuse cases. git diff --check on the documentation delta passed. Unit tests were not run.
Compared with bitkit-ios#1302 at 3c26e983: Docs/nearby-payments.md has the same paragraph, and ScannerManager.isNearbyPaymentRequest uses the same category rules. That check covered this acceptance contract only, not the rest of the iOS pull request.
Device testing: not performed in this review.
Suggested additional test cases
- Android, Send scanner open, with a nearby peer advertising an LNURL-pay request, a Lightning address, or a BOLT12 offer on the nearby service. The scanner should stay on the scan screen. Manual case 2 expects an LNURL NFC tag to open Send, and manual case 12 covers a
pubkyauth://advertisement.
Earlier findings reconciled at this revision: 2 still present, 2 tracked separately outside this PR.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. Android issue #1971 is still open. The reported reset of a saved Bitcoin Receive amount after the app is backgrounded and reopened runs through code this PR does not change. Between merge base ddd0718 and head 7ebf6ef, WalletRepo.kt, ReceiveSheet.kt, WalletViewModel.kt and LightningNodeService.kt are the same blobs. No changed line touches bip21AmountSats, clearBip21State or refreshReceiveState. The PR's Receive code only selects the existing invoice for a nearby offer and writes no amount. The Galaxy S22 and mainnet 3.1.1 (197) results are Piotr's historical observations. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Tracked separately (outside this PR; unresolved): Bitcoin Receive loses its saved amount after background and foreground. This is the same external report as L2, from the same comment #1883 (comment), and the same open issue #1971 tracks it. Between merge base ddd0718 and head 7ebf6ef, the files that reset the Receive amount are unchanged. L2 is tracked separately rather than open, so this item is not marked duplicate. No current-device result is claimed. This is not a runtime verification or merge-readiness declaration.
Existing concerns
- [MEDIUM] Provide an NFC scan action on phones that suspend polling while the camera is open — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply, #1883 (comment), moves the design choice to open issue #2000 and keeps the current scanner behavior in this PR. At 7ebf6ef an enabled adapter still counts as active NFC, except while nearby reading is paused, and the only NFC control is shown when the adapter is off. A phone that keeps the adapter enabled and stops polling while the camera is open would still show an NFC status and would still have no in-scanner tap action. The Pixel 11 observation remains the author's. NearbyScanSources.kt and NfcEffects.kt are the same blobs as at bca0fa0, and the only commit since that head is docs/nearby-payments.md, so there is no material new defect evidence. This stays an existing open concern of this PR, tracked by #2000. This check is source inspection.
- [MEDIUM] Drop the LDK send hash when QuickPay stops before submission — The discussion #1883 (comment) is marked resolved by jvsena42. Its latest reply, #1883 (comment), says the revert in fa0ebe8 leaves the original retry refusal while the node cannot list payments. At 7ebf6ef a QuickPay node send still writes the LDK send hash before lightningService.send. A false isAuthorizedAtSubmission throws PaymentStoppedAtSubmission on the LDK queue before bolt11Payment().send. The failure path releases that attempt's in-flight count and leaves the hash in place. QuickPay falls back to review with isMarkedDispatched true and leaves the cache hash in place. A later Spark payment of the same invoice throws NodeNotStarted while the node cannot list payments, until a listing that shows no send removes the hash. Issue #2011, closed on 2026-11-24, covers the in-flight count, a different mechanism, and its closure does not remove this hash. The author's decline of unconditional removal still matches LightningRepoTest, which expects an earlier send's hash to stay. No funds move twice. The consequence remains a refused Spark retry with a workable recovery, so MEDIUM stays. LightningRepo.kt, QuickPayRepo.kt and LightningService.kt are unchanged since bca0fa0, so there is no material new defect evidence. Reference the existing discussion rather than re-publishing it inline. This check is source inspection.
Reviewer model: grok-4.7
Reasoning effort: xhigh
There was a problem hiding this comment.
Verdict: ✅ Approve
Findings: None new in the reviewed delta.
QA for 7ebf6ef:
Built with the pinned dependencies and tested on regtest Android 15 emulators. The locked launch used the unchanged APK; the queued-send and crafted Bluetooth checks used the debug-only hooks below.
Check: Lightning retry and nearby payment regressions ✅ The APK built and the focused Spark, Lightning, Send, QuickPay, nearby and NFC suites passed.
Review a payment received while the wallet is locked ✅ An NFC launch intent received on the PIN screen stayed unpaid after unlock opened review, then settled after the swipe and PIN.
This injects Android's NFC launch intent; it does not exercise a physical tag. The receiver confirmed the 1,000-sat invoice was unpaid until manual confirmation.
Review a fixed Lightning invoice after the wallet locks ✅ Locking while QuickPay waited on the LDK queue stopped submission; the original invoice settled after manual confirmation.
A debug hook held the real send immediately before its authorization check. After the lock, the check refused submission, unlocking opened Swipe To Pay, and the receiver confirmed settlement only after the swipe and PIN.
Test hook, not pushed
diff --git a/app/src/main/java/to/bitkit/services/LightningService.kt b/app/src/main/java/to/bitkit/services/LightningService.kt
index aff3b3246..4cc96c0e7 100644
--- a/app/src/main/java/to/bitkit/services/LightningService.kt
+++ b/app/src/main/java/to/bitkit/services/LightningService.kt
@@ -1195,6 +1195,15 @@ class LightningService internal constructor(
return ServiceQueue.LDK.background(ldkQueue) {
keychain.requireWalletRestoreComplete()
ensurePaymentDeadline(paymentDeadlineAt)
+ if (to.bitkit.BuildConfig.DEBUG) { // test hook
+ val hold = java.io.File(Env.logDir.parentFile, "review-hold-ldk") // test hook
+ if (hold.isFile) { // test hook
+ Logger.info("QA LDK queued payment waiting before authorization", context = TAG) // test hook
+ kotlinx.coroutines.withTimeout(120_000) { // test hook
+ while (hold.isFile) kotlinx.coroutines.delay(100) // test hook
+ } // test hook
+ } // test hook
+ } // test hook
if (!isAuthorizedAtSubmission()) throw ServiceError.PaymentStoppedAtSubmission()
runCatching {
val routeParameters = maxTotalRoutingFeeMsat?.let(::routeParametersWithFeeCap)Keep scanning after unsupported Bluetooth requests ✅ LNURL-pay, a Lightning address and BOLT12 offers left Send scanning; a valid Bitcoin request then opened Amount.
Tested bare and lightning:-wrapped LNURL-pay and BOLT12 payloads. App logs confirmed each exact payload arrived over GATT and was rejected by the payment filter. The peer's debug hook supplied the crafted payload; its visible QR still shows its native Bitcoin request. Left: peer; right: payer.
LNURL-pay variants and Lightning address:
BOLT12 variants and Bitcoin control:
Test hooks, not pushed
The peer overrides only the advertised URI. The payer logs receipt immediately before the unchanged filter. The earlier LDK hold is present but inactive in these builds.
diff --git a/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt b/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt
index f30277257..a9fbd56ba 100644
--- a/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt
+++ b/app/src/main/java/to/bitkit/ui/shared/effects/NearbyEffects.kt
@@ -224,6 +224,12 @@ fun offerPaymentNearby(request: String?): Boolean {
val canAdvertise = isNearbyEnabled && bluetoothState == BluetoothState.ON && !advertiseFailed
NfcEmitterEffect(uri = uri.takeIf { emitsNfc }, onFailed = { emitFailed = true })
- NearbyAdvertiseEffect(uri = uri.takeIf { canAdvertise }, onFailed = { advertiseFailed = true })
+ val reviewUri = if (to.bitkit.BuildConfig.DEBUG) { // test hook
+ val context = LocalContext.current // test hook
+ remember(uri) { // test hook
+ java.io.File(context.filesDir, "review-nearby-uri").takeIf { it.isFile }?.readText() // test hook
+ } // test hook
+ } else null // test hook
+ NearbyAdvertiseEffect(uri = (reviewUri ?: uri).takeIf { canAdvertise && uri != null }, onFailed = { advertiseFailed = true })
return uri != null && (emitsNfc || canAdvertise)
}
diff --git a/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt b/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt
index d7abee300..0c3dca456 100644
--- a/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt
+++ b/app/src/main/java/to/bitkit/nearby/NearbyScanner.kt
@@ -121,6 +121,7 @@ class NearbyScanner(
if (session !== finished) return
session?.close()
session = null
+ if (to.bitkit.BuildConfig.DEBUG) Logger.info("QA nearby received: $request", context = TAG) // test hook
val payment = request?.let(::nearbyPaymentRequest)
if (request != null && payment == null) {
Logger.warn("Ignored nearby request that is not a payment", context = TAG)Carried evidence from unchanged code:
- Physical-device results cover cases 1, 1a, 1b, 2–5 and 15 at bca0fa0 with pinned bitkit-core. Only documentation changed afterward.
- Earlier Android QA and scanner QA cover the unchanged settings, permissions, Bluetooth lock/disable gates and Android 11 Location path.
- Previous filter tests cover invalid addresses/checksums and uppercase requests. VSS recovery tests cover the merged recovery change.
Not driven here: physical NFC and fresh NFC-device eligibility, Square Register, and the remaining Android–iPhone radio cases require compatible hardware.
Reviewed dcabb9d..7ebf6ef, including the master merge and prior open feedback. Spark restart/storage races and VSS recovery were checked by source and regression tests rather than these device cases.
Twin: synonymdev/bitkit-ios#1302. The nearby protocol documents match at 62b07d3; physical cross-platform interoperability was not retested.
Reviewed by gpt-6.1-sol-high
Closes #1740
Twin: synonymdev/bitkit-ios#1302
This PR adds NFC and Bluetooth nearby payments. Payment scanners read requests from NFC tags, payment terminals and nearby Bitkit wallets. The Receive screen offers its request to nearby phones. The protocol is in
docs/nearby-payments.mdand is shared with iOS.Platform support
Description
lightning:, BIP21bitcoin:(withlightning=), LNURL, and USDTethereum:.NdefTagService(host card emulation) serves the current request as a read-only NFC Forum Type 4 tag (categoryother, device unlock required). It also covers the USDT receive screen.D2760000850101is registered for the service only while Receive is shown, and the service is the preferred one meanwhile.bitcoin:with an address (everylightning=part must be a BOLT11 invoice), alightning:BOLT11 invoice, and USDTethereum:. Invoices are checked locally (network prefix, amount and bech32 shape) before decoding. LNURL and Lightning addresses are refused before decoding, because decoding contacts their server before the user picked the request. BOLT12 offers are refused because core rc15 does not decode them. Anything else the scanner understands (Pubky auth, LNURL auth/withdraw/channel, wallet connection setups, contact keys) is ignored, and that device is skipped.NFC,BLUETOOTH_ADVERTISE, optionalnfcandnfc.hcefeatures, and the HCE service.Device test fixes
Testing on two phones found two problems, both fixed:
NfcRepeatGuardnow holds reader mode, with a callback that ignores tags, untilNfcAdapter.ignorereports that the tag has left the field. It then hands reader mode back to a scan screen that is still open. It engages after a scanner read, and when a tag tap launches or resumes the app (a22544e97).2336ef1ca).Review round (from bitkit-ios#1302)
A
bitcoin:?…URI with a required (req-) parameter is no longer rewritten tolightning:<invoice>, since the rewrite dropped that parameter. The scanner then refuses it. Test:NfcPaymentUriTest"request with a required parameter is kept"; it fails without the fix (4d5af8435).Wrapped login requests over Bluetooth: a request read over Bluetooth is now rewritten before the payment-only filter.
bitcoin:?lightning=<LNURL-auth>therefore can no longer reach the login sheet (82f44a4d8). Tests are inNearbyRequestFilterTest; the wrapped-request test fails without the fix.Stale request on Receive: Receive offers a request over NFC and Bluetooth only while its QR shows one. While the invoice updates, or after an update fails, nothing is offered, so the previous invoice can't be paid (
d88da7fad). Test:ReceiveInvoiceUtilsTest"nearby offers only the request the QR shows"; it fails without the fix.No Bluetooth advertising: a phone that can't advertise over Bluetooth counts as having no Bluetooth for Receive, so it no longer claims "Scan or tap to pay" when NFC is off (
b373d5ba0). An advertising start that fails at run time now drops the label too, until the request or the Bluetooth state changes (baeab2d1f). A late failure from an advertiser that already stopped is ignored (965ff980c). Not driven on a device.Button labels: the camera, Bluetooth and NFC source buttons have localized TalkBack labels (
49538ae06).Blocked permission: after the nearby-devices permission is denied for good, the Bluetooth button opens the app's settings (
c37460c77).Device check on the Pixel 11: the Bluetooth button reads "Enable Bluetooth". The first tap showed the permission dialog, which I denied; the second showed it again, which I denied for good. The third tap opened App info.
nearby-permission-settings-trimmed.mp4
Empty required parameters: a
req-key with an empty or no value (&req-foo=,&req-foo) also keeps the URI unrewritten (c06c3b7e1). TheNfcPaymentUriTestcases fail without the fix.Send E2E regression: the channel wait is skipped only while the node is not running yet and Spark covers the amount (
943e052ec). Skipping it with a running node also skipped publishing current channels. After a payment, the send limit then stayed too high, and thesendE2E's amount-exceeded check failed. The launch case still skips the wait. Test: "lightning scan waits for a running node even when spark covers the amount"; it fails without the fix.No 15 s wait when Spark pays: when Spark covers a Lightning payment, a running node now only publishes its current channels and doesn't wait for a usable one (
71680fc61). Before, it could wait up to 15 s when channels existed but none were usable.Enter Manually: a nearby request still decoding on the recipient screen is cancelled when the user taps Enter Manually, so it can't route over the address being typed (
f67cde893, ported from an iOS finding). The test fails without the fix.NFC launch: a tag that launches Bitkit gets the same
bitcoin:?lightning=rewrite as a scanner read, so the shipped core no longer rejects Numo's form (34f255940).Closed Receive: the tag emulator stops serving a selected request once Receive stops offering it, instead of serving it until the reader disconnects (
4f16c11ce).Duplicate Bluetooth read: a second delivery of the same request no longer drops the handle of the read still decoding, so Enter Manually still cancels it (
a88e203cd).Contacts: opening Contacts from the Send recipient screen drops a nearby read that is still decoding, as Enter Manually does (
869b45f3a).NFC after leaving the scanner: a tag read that finishes after the scanner screen closed is dropped instead of opening a payment (
5ca051cfb).Master merge (
d9c4ede2c): master now asks for the payment PIN before QuickPay settings are raised (QuickPaySettingsViewModel). The TapPay (NFC) intro sheet's QuickPay toggle now goes through that view model and shows the same PIN check, instead of writing the setting directly. Not driven on a device.NFC read after pause: each NFC reader activation now has a number, and pausing the reader ends that activation. A tag read that started before the scanner paused is dropped, even if it finishes after a later resume. Before this fix, it could still open a payment over Contacts during the 300 ms exit transition (
24180fd39). Each activation also registers its own callback, so a callback Android calls after reader mode was disabled carries a closed activation and is dropped (79e9f719f). Tests:NfcReadDispatcherTest"drops a read from a reader that paused or closed" and "drops a read from an earlier activation after the reader resumed"; they fail without the fix. Not driven on a device.Rejected Bluetooth request: a phone whose request was rejected without leaving the scanner (an expired invoice, or a non-USDT request on the USDT scanner) is read again after 10 s, as on iOS. Before, it was ignored until the scanner closed (
a3496bf06). Not driven on a device.Translated button labels:
other__bluetooth_enableandother__nfc_enableare in all 15 locales (483562df5).NFC read on Enter Manually: an NFC read on the Send recipient screen that is still decoding is dropped when the user taps Enter Manually, as a Bluetooth read already was (
3a21060c6).Merged
masteragain (9e09c6bea): the conflicts were translated strings, and both sides were kept.Merged
masteragain (4f8552895). The only conflict wasSettingsScreen.kt, wheremasterremoved the contact and public payments rows; this branch now adds only the nearby payments row there.Review round (QA review of 965ff98)
0ccac8562).4098e7803).adbcb2bc8).ba4d982e4).lno=(fe7e30a96).bitcoin:<address>?lightning=LNURL1…is refused over Bluetooth before decoding, which would fetch it (32e1fb55b).amountthe invoice does not carry, is no longer unwrapped, so the scanner rejects it (933f9ae3b,7263458b0,2431c1b68).84a88d0b9).5d8e5e88a).registerAidsForServiceclears the published request and drops NFC from the tap label (35fef0d1e).7d2391f6d).88ff9a895)..ai/validate-r19.sh). None was driven on a device.Review round (QA review of 2431c1b)
abc4ca5ff).cb0d92dfb).3efaa561b).lightning=value must be BOLT11-shaped (30fb75ce2), and the check is a local shape check, solnsb@example.comis refused before decoding (f14fb29e8).amount,label,messageorpopis rejected; unknown optional keys may repeat again (f949c6fef). A repeatedlightningis valid BIP 321 but is not unwrapped.amountmust match the BIP grammar as a whole (fdd56de0c). Core gets the same amount checks in fix: check bip 321 amounts against the bip bitkit-core#225.973f81db1).be7306340).a7298dff6), and the lock check runs again right before QuickPay starts (a9e2d7ebc).b646b95d5). A test covers a contact scanned from Send's scanner (6832a63de).bitcoin:request with anyreq-key is refused before decoding over Bluetooth, and gets "Unable To Read NFC" over NFC, including a tap that opens Bitkit (b9af9cd77). Ported from bitkit-ios#1302.70e40e8d3). Thereq-refusal applies only tobitcoin:URIs, so an LNURL-pay HTTPS URL with its ownreq-query still decodes (233f7f3f1).bitkit://(piotr): bitkit-core deletes everybitkit://in a deep link, so…&bitkit://req-pop=xor…&rebitkit://q-pop=xturned into areq-popkey after the check. Thereq-check now deletes everybitkit://first (3915f555e). It deletesbitkit://only while the text starts with it, as the decoder does, so a payablebitcoin:URI withbitkit://inside a key is not refused (535efc4ec,2a4511728).13f995124,cfead7f57). The review it falls back to now has its amount validated, so Swipe to Pay works for a fixed invoice (3084ff39a; the same dead end exists onmasterafter a cap rejection).req-check trims like the decoder, which also removes U+0085 (70bd2a709).592203d9d). The fallback review marks a fixed amount valid like the fixed LNURL-pay path, so it works before the spending limit is published (f0a9f3f19).bitkit://(ovi): deleted only in lowercase, like the decoder, so payable requests are not refused (cafc812e1).master(d8a0dae8d).bitcoin:URI must name a valid address for this wallet's network, validated like the decoder (92d42f93c,7dcc9470c,dcabb9d04), and nearby BOLT11 invoices must pass the bech32 checksum (23ec7a17d).fa0ebe8ca).amount=on an addressless request keeps the URI instead of unwrapping it (c7e0f5dea)..ai/validate-r20.sh,.ai/validate-r20b.sh,.ai/validate-r21.sh,.ai/validate-r23.sh,.ai/validate-r24.sh,.ai/validate-r25.sh,.ai/validate-r26.sh,.ai/validate-r27.sh). The full unit suite (6,248 tests), detekt and lint pass. None was driven on a device.POS request formats
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 #1935.Out of Scope
nearby: choosing or confirming the recipient when several Bluetooth receivers are in range: Let the payer choose or confirm the recipient of a Bluetooth request #2005scanner: 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 #2029nfc: being read by Bolt Card terminals (Blink, BTCPay, LNbits TPoS, Swiss Bitcoin Pay, Wallet of Satoshi merchant mode). They read anlnurlwcard and pull the payment, which needs a server-side LNURL-withdraw relay for a self-custodial wallet.nfc: USDT over NFC terminals. None exist on any chain, Arbitrum included. A USDTethereum:request read from another Bitkit is supported.nearby: requesting the Nearby devices permission from Receive. Receive advertises only once the permission was granted from the scanner, because the design has no Receive permission state.settings: the design's "QRs + NFC" QuickPay row value. The row keeps On/Off.scanner: required BIP 321 keys (req-…) on a scanned QR code with an address open Send, as onmaster. NFC and Bluetooth refuse them in this PR (b9af9cd77); 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 #1935.nfc: LUD-17lnurlp://tags fail the same way their QR codes do onmaster: fix: Error decoding some Lightning and LNURL schemes bitkit-core#70.nfc: an in-scanner NFC action for phones that stop NFC polling while the camera is open (Pixel 11). Needs a design decision: Scanner: NFC reading on phones that stop polling while the camera is open #2000.Design
NFC compatibility (research, Nov 2026):
lightning:Type 4 taglightning:/bitcoin:/LNURL tagslnurlwcardPreview
Screenshots are from an emulator, which has no NFC hardware. For these captures only, the NFC availability checks were forced on in a local build. That override is not in this branch. The Bluetooth states are real.
QA Notes
Setup
devDebug) from this branch on two NFC-capable Android phones, a third phone or a tag writer for static tags, and an iPhone running feat: nfc and bluetooth nearby payments bitkit-ios#1302 for the cross-platform cases.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_android.sh && cd bindings/android && ./gradlew publishToMavenLocal -Pversion=0.8.0-master-51276ae.bitkit-coreversion ingradle/libs.versions.tomlto0.8.0-master-51276ae. Don't commit it../gradlew assembleDevDebug -PuseMavenLocal=bitkit-core.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
nearby-payments-toggle.xml— Settings shows Nearby payments on by default, and the choice persistsscanner-nearby-states.xml— the Send scanner shows Scan to pay when the camera is denied, a Bluetooth button and "Scanning QR" without the Nearby devices permission, then "Scanning QR & Bluetooth"NFC and Bluetooth between devices are not in the Capabilities table; see Manual Tests.
Manual Tests
lightning:tag, abitcoin:?lightning=tag and an LNURL-pay tag from the main scanner → each opens the matching send flow — NFC tagspubkyauth://URI from a test build) → B's scanner ignores it and opens nothing — Bluetooth between devicesAutomated Checks
NdefCodecTest.kt— URI/Text/absolute-URI records, prefix codes, long records, malformed input, and single-request selectionType4TagEmulatorTest.kt— the Type 4 APDU read sequence, chunked reads, no tag while nothing is published, read-only, and errorsNfcPaymentUriTest.kt— schemes added to bare invoices and addressesNearbyProtocolTest.kt— UUIDs, meta encoding, chunking and reassembly, offset reads, and limitsNfcTimedSheetTest.kt— shows once and only with NFC, and marks both intros seenNearbyRequestFilterTest.kt— Bluetooth accepts bitcoin, BOLT11 lightning and ethereum requests, and refuses offers, auth, LNURL (also inside a unified URI), setup and contact payloadsNfcTagEmitterTest.kt— an older publisher cannot clear a newer requestAppViewModelSendFlowTest.kt— new timed sheet dependency, and a Lightning scan skips the channel wait when Spark covers the amount but waits otherwiseAppViewModelSendFlowTest.kt— Enter Manually and Contacts drop an NFC or Bluetooth read still decoding, including after a duplicate Bluetooth deliveryNfcReadDispatcherTest.kt— duplicate reads within 3 s are dropped, and a read from a paused, closed or earlier reader activation is ignoredEvidence
On
bca0fa0ba(PR head), physical phones, 2026-11-25. RegtestdevDebugbuilt from the branch as is (bitkit-core v0.8.0-rc15), installed over the existing Spark-funded wallets on a Pixel 11 (Android 17) and a Xiaomi 22031116BG (Android 13, UI in Portuguese). The Xiaomi pays or reads, the Pixel receives. The Xiaomi is on the left in each video, the Pixel on the right. Tags were written with NFC Tools on the Xiaomi. For the NFC cases the Xiaomi's Bluetooth was off, so only NFC could deliver the request (with it on, the Bluetooth read wins; see case 5). Times are from Bitkit's log on the Xiaomi.Case 1, QuickPay off: the tap read the Pixel's ₿ 1,000 invoice at 09:53:11.9 and opened the review. Not paid.
case1-nfc-review.mp4
Case 1a, QuickPay on, under the $5 threshold: read at 09:49:12.6,
Using QuickPay for '1000' satsat 13.5, Spark paymentCOMPLETEDat 17.8. No review.case1a-nfc-quickpay.mp4
Case 1b, over the threshold: a ₿ 10,000 ($5.89) invoice opened the review. The log has no QuickPay line. Not paid.
case1b-nfc-over-threshold.mp4
Case 2, tags from the main scanner (
Starting scan from 'scanner sheet'):lightning:<invoice>(415 bytes) opened the review for the ₿ 1,000 invoice.case2-tag-lightning.mp4
bitcoin:?lightning=<invoice>decoded asLightning(...)with the same invoice and opened the review.case2-tag-bitcoin-lightning.mp4
lightning:LNURL1…, served by a local LNURL-pay test server on the LAN: Bitkit fetched it and opened the LNURL-pay amount screen with the server's limits. The server can't issue invoices, so no payment was attempted.case2-tag-lnurl-pay.mp4
Case 3, USDT: with USDT turned on for both wallets, the Xiaomi's USDT send scanner tapped the Pixel's USDT Receive. It moved to the amount step, and the recipient field holds the Pixel's address
0x9D63AC78F2735B1966aBFBd8208be6C3647b4F9a(Arbitrum One). Neither wallet holds USDT, so the send was not completed.case3-usdt-nfc.mp4
Case 4, tags without a payment request:
Erased tag: toast "Incapaz de Ler o NFC / Esta tag não contém uma solicitação de pagamento que a Bitkit possa usar." (the Portuguese "Unable To Read NFC"). The scanner stays open. Bitkit logs nothing for this path.
case4-tag-empty.mp4
https://example.com:Failed to decode scan data: 'https://example.com'and the scanner's decoding toast "Incapaz de Ler o QR / A Bitkit não consegue ler este código QR." The toast says "QR" even though the value came from an NFC tag.case4-tag-non-payment.mp4
Case 5, Bluetooth: the Xiaomi's Send screen read the Pixel's ₿ 1,000 request about 2 s after opening (
Read nearby requestat 09:46:46.4), without a tap.Skipping QuickPay for '1000' sats: suppressed for this scan (... read from a nearby device), so the review opened. Swipe to pay completed and the Pixel showed Received Instant Bitcoin.case5-bluetooth.mp4
Bitkit in the background (case 15 and a tag): the Xiaomi was on its home screen with Bitkit in the background and QuickPay on. Both taps showed Android's app chooser once (Bitkit Regtest and Blink). After Bitkit was picked, it got one
Starting scan from 'deeplink'and QuickPay paid.Tap on the Pixel's Receive: request at 10:11:54.5, QuickPay at 10:12:04.0,
COMPLETEDat 10:12:10.9.bg1-nfc-tap-background.mp4
Tap on a
lightning:tag (the Pixel only supplied the invoice, so its side is a still): request at 10:15:39.2, QuickPay at 10:15:49.1,COMPLETEDat 10:15:56.9.bg2-tag-background.mp4
QuickPay started about 10 s after Bitkit got the request, not the 1.9 s recorded below on
2336ef1ca. The LDK node had stopped in the background.AppViewModel.kt:6776(if (!open && isQuickPayOn && channelsAreSettling()) waitForUsableChannels(walletGeneration)) calls the channel wait without an amount.channelsAreSettling()is true while the node is not running, so QuickPay waits for the node to start (Waiting for node to load channels before sending payment), even when Spark covers the amount. The comment there says this is on purpose, to know whether the payment needs the Spark update. Follow-up: QuickPay waits ~10 s for the LDK node when opened from the background, even when Spark covers the amount #2028.Earlier builds:
On two physical phones, a Pixel 11 (Android 17) and a Xiaomi 22031116BG (Android 13), running regtest
devDebugbuilt against bitkit-coremaster(51276ae). Both wallets were funded on Spark through Lightspark's regtest faucet. The Xiaomi is on the left in each video, the Pixel on the right.Case 1a, NFC with QuickPay: the Pixel offers a ₿ 1,000 request and the Xiaomi's scanner reads it. QuickPay pays in about 9 s from the tap.
nfc-quickpay-side-by-side.mp4
Case 5, Bluetooth: the Xiaomi finds the Pixel's ₿ 1,000 request about 8 s after the nearby-devices permission is granted. It opens the review, because QuickPay is suppressed for requests read over Bluetooth. Swipe to pay completes in 4.4 s.
bluetooth-side-by-side.mp4
Case 15 and the repeat guard, on
2336ef1ca: the video shows three taps:nfc-repeat-guard-side-by-side.mp4
Case 1, with review: run with the Pixel paying, with its camera denied (see the Pixel 11 note). The tap opened the review for ₿ 25, and the payment completed.
On
bca0fa0ba(after the latestmastermerge):androidTestcompiles. Android Lint was last run on28639c4e7.Read nearby request, thenHandling decoded scan data).On
40b2a250b:devDebug:dumpsys bluetooth_manager.Read nearby requestand thenHandling decoded scan data: OnChain(... lightning=lnbcrt1...). That covers case 5's transport, but not a completed payment, because B had no funds.Pixel 11: NFC reading stops while the camera is open
On a Pixel 11 (Android 17, build CD1A.261005.003), the system switches NFC polling off while the camera is in use. The scan screen shows the camera, so on this phone it cannot read an NFC payment request.
setReaderMode ... to.bitkit.dev, flags: 15,tech_mask = 0f). About 0.1 s after the QR camera opens, the system sets reader mode again (uid=1000, packageName: android, flags: 4096,tech_mask = 00), which disables polling. Polling comes back only when Bitkit leaves the scan screen. Reproduced three times.tech_mask = 0f) and a tap reads the request and opens the payment.Gaps
3e377fbf9, and its findings were addressed in28639c4e7. One finding was not taken: it flagged thatshowsTapToPaycomes aftermodifierinReceiveQrView, but AGENTS.md requiresmodifierto be the first optional parameter.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 the reasoning setting.
🤖 Generated with Claude Code