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).
This commit is contained in:
Claude
2026-01-19 19:09:01 +00:00
parent 8f008ddd39
commit 1251fef230

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,