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 <noreply@anthropic.com>
This commit is contained in:
Alejandro
2026-01-19 20:14:50 +01:00
committed by GitHub
parent ca58a4e7c3
commit 97b3842692
2 changed files with 5 additions and 2 deletions

View File

@@ -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,

View File

@@ -1 +1 @@
{"root":["./vite.config.ts"],"version":"5.6.3"}
{"root":["./vite.config.ts"],"errors":true,"version":"5.9.3"}