Skip to content

fix: Handle null error value in NWC response deserialization#334

Merged
frnandu merged 1 commit intorelaystr:masterfrom
anipy1:fix/nwc-error-null-handling
Dec 9, 2025
Merged

fix: Handle null error value in NWC response deserialization#334
frnandu merged 1 commit intorelaystr:masterfrom
anipy1:fix/nwc-error-null-handling

Conversation

@anipy1
Copy link
Contributor

@anipy1 anipy1 commented Dec 9, 2025

The deserializeError method in NwcResponse was attempting to cast the error field to a Map<String, dynamic> without checking if it was null. This caused connection failures when NWC wallet providers (like Rizful) send responses with error: null in their JSON payloads.

Example of problematic response format:

{
  "result_type": "get_balance",
  "result": {"balance": 100000},
  "error": null
}

When this response was processed, the code would try to cast null to Map<String, dynamic>, causing a runtime error and preventing successful wallet connections.

This bug was discovered during testing of my app Nostrpay with the Rizful wallet provider. Users reported connection failures when attempting to connect their Rizful wallet through NWC. The issue was reported in this Stacker.news discussion.

I just added a null check before attempting to cast the error field to a Map.

@frnandu frnandu merged commit 6f1712e into relaystr:master Dec 9, 2025
@frnandu frnandu added this to the 0.7 milestone Dec 22, 2025
@frnandu frnandu changed the title Fix: Handle null error value in NWC response deserialization fix: Handle null error value in NWC response deserialization Jan 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants