From 93963de28ddded14c7810b20e9c0d6ce51a98735 Mon Sep 17 00:00:00 2001 From: Jure <44338+hoornet@users.noreply.github.com> Date: Fri, 13 Mar 2026 11:17:45 +0100 Subject: [PATCH] Fix sent zaps: query kind 9735 receipts with #P tag instead of ephemeral kind 9734 --- src/components/zap/ZapHistoryView.tsx | 13 ++++--------- src/lib/nostr/client.ts | 3 ++- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/src/components/zap/ZapHistoryView.tsx b/src/components/zap/ZapHistoryView.tsx index 3cd181b..dc5aa8d 100644 --- a/src/components/zap/ZapHistoryView.tsx +++ b/src/components/zap/ZapHistoryView.tsx @@ -32,13 +32,6 @@ function parseReceipt(receipt: NDKEvent): { amount: number | null; senderPubkey: return { amount, senderPubkey, comment, noteId }; } -function parseRequest(zapReq: NDKEvent): { amount: number | null; recipientPubkey: string | null; comment: string; noteId: string | null } { - const recipientPubkey = zapReq.tags.find((t) => t[0] === "p")?.[1] ?? null; - const noteId = zapReq.tags.find((t) => t[0] === "e")?.[1] ?? null; - const amountTag = zapReq.tags.find((t) => t[0] === "amount"); - const amount = amountTag?.[1] ? Math.round(parseInt(amountTag[1]) / 1000) : null; - return { amount, recipientPubkey, comment: zapReq.content ?? "", noteId }; -} // ── Row component ──────────────────────────────────────────────────────────── @@ -154,7 +147,7 @@ export function ZapHistoryView() { return sum + (amount ?? 0); }, 0); const totalSent = sent.reduce((sum, e) => { - const { amount } = parseRequest(e); + const { amount } = parseReceipt(e); return sum + (amount ?? 0); }, 0); @@ -221,7 +214,9 @@ export function ZapHistoryView() { /> ); } else { - const { amount, recipientPubkey, comment } = parseRequest(event); + // Sent zaps are also kind 9735 receipts; the recipient is in the lowercase "p" tag + const recipientPubkey = event.tags.find((t) => t[0] === "p")?.[1] ?? null; + const { amount, comment } = parseReceipt(event); return ( { const instance = getNDK(); - const filter: NDKFilter = { kinds: [NDKKind.ZapRequest], authors: [pubkey], limit }; + // Zap receipts (kind 9735) with uppercase P tag = the sender's pubkey + const filter: NDKFilter = { kinds: [NDKKind.Zap], "#P": [pubkey], limit }; const events = await instance.fetchEvents(filter, { cacheUsage: NDKSubscriptionCacheUsage.ONLY_RELAY, });