From 575c89643ff140b3c9f11a409888162deb95dd32 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 2 Feb 2026 09:50:20 +0000 Subject: [PATCH] fix(zap): only send comment to LNURL callback if server accepts it The comment in the zap request event (kind 9734 content) is always included as that's part of the Nostr protocol. However, the LNURL callback `comment` parameter should only be sent if the server's `commentAllowed` field is > 0. Previously, the comment was always sent to the LNURL callback regardless of the server's comment support, which could cause issues with servers that don't accept comments. https://claude.ai/code/session_01KTcAyKHVaqg4QKKXQxUzum --- src/components/ZapWindow.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/ZapWindow.tsx b/src/components/ZapWindow.tsx index 380f12b..cd458b7 100644 --- a/src/components/ZapWindow.tsx +++ b/src/components/ZapWindow.tsx @@ -352,11 +352,16 @@ export function ZapWindow({ const comment = serialized.text; const emojiTags = serialized.emojiTags; - // Validate comment length if provided - if (comment && lnurlData.commentAllowed) { - if (comment.length > lnurlData.commentAllowed) { + // Check if LNURL server accepts comments (commentAllowed > 0) + // The comment always goes in the zap request event (kind 9734 content) + // But only goes to the LNURL callback if the server accepts it + const commentAllowedLength = lnurlData.commentAllowed ?? 0; + + // Validate comment length for LNURL callback if server accepts comments + if (comment && commentAllowedLength > 0) { + if (comment.length > commentAllowedLength) { throw new Error( - `Comment too long. Maximum ${lnurlData.commentAllowed} characters.`, + `Comment too long for payment. Maximum ${commentAllowedLength} characters.`, ); } } @@ -385,11 +390,12 @@ export function ZapWindow({ const serializedZapRequest = serializeZapRequest(zapRequest); // Step 4: Fetch invoice from LNURL callback + // Only include comment in LNURL callback if server accepts it (commentAllowed > 0) const invoiceResponse = await fetchInvoiceFromCallback( lnurlData.callback, amountMillisats, serializedZapRequest, - comment || undefined, + commentAllowedLength > 0 ? comment || undefined : undefined, ); const invoiceText = invoiceResponse.pr;