From 38a6dddedb44fddf9441b8f08596044bbb911115 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Mon, 2 Feb 2026 11:04:59 +0100 Subject: [PATCH] Fix LNURL comment handling to respect server capabilities (#237) * 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 * fix(zap): silently skip comment in LNURL callback if too long Instead of throwing an error when the comment exceeds the server's commentAllowed limit, simply don't include it in the LNURL callback. The comment is still preserved in the zap request event (kind 9734). https://claude.ai/code/session_01KTcAyKHVaqg4QKKXQxUzum --------- Co-authored-by: Claude --- src/components/ZapWindow.tsx | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/components/ZapWindow.tsx b/src/components/ZapWindow.tsx index 380f12b..002a23b 100644 --- a/src/components/ZapWindow.tsx +++ b/src/components/ZapWindow.tsx @@ -352,14 +352,12 @@ 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) { - throw new Error( - `Comment too long. Maximum ${lnurlData.commentAllowed} characters.`, - ); - } - } + // 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 and it fits + const commentAllowedLength = lnurlData.commentAllowed ?? 0; + const canIncludeCommentInCallback = + commentAllowedLength > 0 && comment.length <= commentAllowedLength; // Step 3: Create and sign zap request event (kind 9734) // If zapping anonymously, create a throwaway signer @@ -385,11 +383,12 @@ export function ZapWindow({ const serializedZapRequest = serializeZapRequest(zapRequest); // Step 4: Fetch invoice from LNURL callback + // Only include comment if server accepts it and it fits within the limit const invoiceResponse = await fetchInvoiceFromCallback( lnurlData.callback, amountMillisats, serializedZapRequest, - comment || undefined, + canIncludeCommentInCallback ? comment || undefined : undefined, ); const invoiceText = invoiceResponse.pr;