fix(nostr): do not drop NIP-57 receipts when relays tag is missing - #3227
Closed
HaydernCenterpoint wants to merge 3 commits into
Closed
fix(nostr): do not drop NIP-57 receipts when relays tag is missing#3227HaydernCenterpoint wants to merge 3 commits into
HaydernCenterpoint wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change directly addresses the reported runtime exception with a minimal, well-scoped defensive fallback and low regression risk.
Pull request overview
This PR fixes a crash in the NIP-57 receipt publishing worker so zap receipts (kind 9735) are still published even when the originating zap request omits the optional relays tag, aligning behavior with NIP-57 Appendix D being advisory.
Changes:
- Import
DEFAULT_CROSSPOSTING_RELAYSinto the NIP-57 worker. - Make relay extraction defensive: use the request’s
relaystag when present, otherwise fall back toDEFAULT_CROSSPOSTING_RELAYS(and filter out falsy entries).
File summaries
| File | Description |
|---|---|
worker/nostr.js |
Prevents a .slice(1) crash when the zap request has no relays tag by defaulting to DEFAULT_CROSSPOSTING_RELAYS, ensuring receipts still publish. |
Review details
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This comment was marked as low quality.
This comment was marked as low quality.
This comment was marked as low quality.
This comment was marked as low quality.
This comment was marked as low quality.
This comment was marked as low quality.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #3218.
worker/nostr.jsthrewTypeError: Cannot read properties of undefined (reading 'slice')when a NIP-57 zap request had norelaystag.pay.jsdoes not require the tag (NIP-57 Appendix D is advisory), so those notes reach the worker; the catch logsfailed to publish NIP-57 receiptand the kind 9735 receipt is lost after a settled payment. Proxied (payInBolt11.nostrNote) and direct-receive (externalTransaction.nostrNote) paths both hit this.Fix:
relaysForNip57Receiptuses the request's relays when present, otherwiseDEFAULT_CROSSPOSTING_RELAYS. Empty/malformed tags also fall back. Jest coverage inlib/nip57-relays.spec.js.Did not change
pay.jsto reject missing relays — that would fail after some wallets already paid. Happy to add fail-fast validation in a follow-up if you prefer.Screenshots
N/A (server-side worker)
Additional Context
Competing #3219 (same issue, closed 2026-09-07) did not include tests. This PR extracts a helper so the fallback is unit-tested without LND.
Please apply
difficulty:*on #3218. Proposingdifficulty:easy(100k sats) rather than good-first-issue: small diff, but it sits on the paid-receipt path.Lint Check / Tests / ShellCheck are
action_requiredfor this first-time fork PR — please approve workflows.Checklist
Are your changes backward compatible? Please answer below:
Yes. Tag present → same relays as before. Tag missing → receipts publish instead of throwing.
On a scale of 1-10 how well and how have you QA'd this change and any features it might affect? Please answer below:
7/10. Reproduced the original
.slicethrow in node. Jest cases for present / missing / empty / malformed tags. No full LND/DB integration run.For frontend changes: Tested on mobile, light and dark mode? Please answer below:
N/A.
Did you introduce any new environment variables? If so, call them out explicitly here:
No.
Did you use AI for this? If so, how much did it assist you?
Yes. An AI assistant helped read the worker path, extract the helper, and write the Jest file. I verified the crash, the fallback, and that
DEFAULT_CROSSPOSTING_RELAYSis the existing crosspost default.