Skip to content

fix: Zeus-to-Zeus NFC scan (update react-native-hce + empty NDEF guard)#3942

Open
myxmaster wants to merge 2 commits intoZeusLN:masterfrom
myxmaster:fix/nfc-hce-zeus-to-zeus-scan
Open

fix: Zeus-to-Zeus NFC scan (update react-native-hce + empty NDEF guard)#3942
myxmaster wants to merge 2 commits intoZeusLN:masterfrom
myxmaster:fix/nfc-hce-zeus-to-zeus-scan

Conversation

@myxmaster
Copy link
Copy Markdown
Collaborator

@myxmaster myxmaster commented Apr 3, 2026

Description

#3941 should be merged first.

  • react-native-hce 0.1.2 -> 0.3.0
  • Guard against empty NDEF in DiscoverTag handler in NFCUtils.ts
    • If tag.ndefMessage?.[0]?.payload is absent, close the Android modal, resolve with undefined, and unregister to abort the scan session explicitly.

Zeus-to-Zeus NFC scanning was broken in two ways:

  1. Broadcast side crashed with TypeError: Cannot read property 'Text' of undefined in NFCButton.tsx. Root cause: the react-native-hce 0.1.2 API was incompatible with how some NFC reader stacks negotiate the APDU session (CC read attempted multiple times -> HCE responded with CMD_ERROR -> empty NDEF on the scanner side).
  2. Scanner side crashed when tag.ndefMessage was empty -> ndefMessage[0].payload threw an unhandled TypeError in NFCUtils.ts.

This pull request is categorized as a:

  • New feature
  • Bug fix
  • Code refactor
  • Configuration change
  • Locales update
  • Quality assurance
  • Other

Checklist

  • I’ve run yarn run tsc and made sure my code compiles correctly
  • I’ve run yarn run lint and made sure my code didn’t contain any problematic patterns
  • I’ve run yarn run prettier and made sure my code is formatted correctly
  • I’ve run yarn run test and made sure all of the tests pass

Testing

If you modified or added a utility file, did you add new unit tests?

  • No, I’m a fool
  • Yes
  • N/A

I have tested this PR on the following platforms (please specify OS version and phone model/VM):

  • Android
  • iOS

I have tested this PR with the following types of nodes (please specify node version and API version where appropriate):

On-device

  • LDK Node
  • Embedded LND

Remote

  • LND (REST)
  • LND (Lightning Node Connect)
  • Core Lightning (CLNRest)
  • Nostr Wallet Connect
  • LndHub

Locales

  • I’ve added new locale text that requires translations
  • I’m aware that new translations should be made on the ZEUS Transfix page and not directly to this repo

Third Party Dependencies and Packages

  • Contributors will need to run yarn after this PR is merged in
  • 3rd party dependencies have been modified:
    • verify that package.json and yarn.lock have been properly updated
    • verify that dependencies are installed for both iOS and Android platforms

Other:

  • Changes were made that require an update to the README
  • Changes were made that require an update to onboarding

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates the NFC functionality, including upgrading the react-native-hce library, adding react-native-nfc-manager support, and refactoring NFC scanning logic into a reusable scanNfcTag utility. The review identified opportunities to simplify the nfcUtf8ArrayToStr function using the TextDecoder API, improve error handling in NfcManager.start(), and enhance the DiscoverTag listener for better UX and more robust NDEF decoding.

@myxmaster myxmaster force-pushed the fix/nfc-hce-zeus-to-zeus-scan branch from f090117 to 2181a0e Compare April 3, 2026 16:02
@myxmaster myxmaster force-pushed the fix/nfc-hce-zeus-to-zeus-scan branch from 2181a0e to bc2bba0 Compare April 3, 2026 16:53
@kaloudis kaloudis added Bug Something isn't working NFC labels Apr 4, 2026
@kaloudis kaloudis added this to the v13.1.0 milestone Apr 4, 2026
@myxmaster myxmaster force-pushed the fix/nfc-hce-zeus-to-zeus-scan branch from bc2bba0 to fe12fff Compare April 4, 2026 08:02
@myxmaster
Copy link
Copy Markdown
Collaborator Author

(rebased)

@myxmaster myxmaster force-pushed the fix/nfc-hce-zeus-to-zeus-scan branch from fe12fff to 42a2b66 Compare April 6, 2026 09:50
@myxmaster myxmaster force-pushed the fix/nfc-hce-zeus-to-zeus-scan branch from 42a2b66 to 1a998d2 Compare April 9, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working NFC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants