From 97b3842692c81d15e2338d52b83da4d35931d7b1 Mon Sep 17 00:00:00 2001 From: Alejandro Date: Mon, 19 Jan 2026 20:14:50 +0100 Subject: [PATCH] fix: convert NIP-10 chat zap amounts to sats (#161) * fix: convert NIP-10 chat zap amounts to sats The NIP-10 adapter was storing zap amounts in millisats instead of sats, which was inconsistent with: - The MessageMetadata type definition (zapAmount documented as "Amount in sats") - Other chat adapters like NIP-53 which correctly convert to sats - UI expectations for displaying zap amounts This fix adds the millisat-to-sat conversion (Math.floor(amount / 1000)) matching the implementation in the NIP-53 adapter. Without this fix, zap amounts would display 1000x larger than intended (e.g., a 1000 sat zap would show as 1,000,000). * chore: update TypeScript build info --------- Co-authored-by: Claude --- src/lib/chat/adapters/nip-10-adapter.ts | 5 ++++- tsconfig.node.tsbuildinfo | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/chat/adapters/nip-10-adapter.ts b/src/lib/chat/adapters/nip-10-adapter.ts index e746809..07b8959 100644 --- a/src/lib/chat/adapters/nip-10-adapter.ts +++ b/src/lib/chat/adapters/nip-10-adapter.ts @@ -909,6 +909,9 @@ export class Nip10Adapter extends ChatProtocolAdapter { const sender = getZapSender(zapReceipt); const recipient = getZapRecipient(zapReceipt); + // Convert from msats to sats + const amountInSats = amount ? Math.floor(amount / 1000) : 0; + // Find what event is being zapped (e-tag in zap receipt) const eTag = zapReceipt.tags.find((t) => t[0] === "e"); const replyTo = eTag?.[1]; @@ -935,7 +938,7 @@ export class Nip10Adapter extends ChatProtocolAdapter { replyTo, protocol: "nip-10", metadata: { - zapAmount: amount, + zapAmount: amountInSats, zapRecipient: recipient, }, event: zapReceipt, diff --git a/tsconfig.node.tsbuildinfo b/tsconfig.node.tsbuildinfo index 75ea001..5e39d3d 100644 --- a/tsconfig.node.tsbuildinfo +++ b/tsconfig.node.tsbuildinfo @@ -1 +1 @@ -{"root":["./vite.config.ts"],"version":"5.6.3"} \ No newline at end of file +{"root":["./vite.config.ts"],"errors":true,"version":"5.9.3"} \ No newline at end of file