mirror of
https://github.com/purrgrammer/grimoire.git
synced 2026-06-05 10:11:12 +02:00
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
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user