diff options
| author | Adam Soltys <[email protected]> | 2025-02-11 20:07:21 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-11 20:07:21 -0800 |
| commit | eb3c2aad4cef9b86294bc9a13a36da4918529209 (patch) | |
| tree | 33c58529ee50bf875620a5a33d97e8ab57b673ae /lib/nostr.ts | |
| parent | 004ac3ccbfb6a12227a81d6e0dc0beaf9a740827 (diff) | |
| download | coinos-server-eb3c2aad4cef9b86294bc9a13a36da4918529209.tar.gz coinos-server-eb3c2aad4cef9b86294bc9a13a36da4918529209.zip | |
nwc notifications
Diffstat (limited to 'lib/nostr.ts')
| -rw-r--r-- | lib/nostr.ts | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts index 9f5a2698..4c28ebc9 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -3,6 +3,7 @@ import { db, g, s } from "$lib/db"; import { l, warn } from "$lib/logging"; import { scan } from "$lib/strfry"; import { fail, fields, getUser, pick } from "$lib/utils"; +import { bytesToHex } from "@noble/hashes/utils"; import { finalizeEvent, getPublicKey, nip19, verifyEvent } from "nostr-tools"; import type { Event } from "nostr-tools"; import { AbstractSimplePool } from "nostr-tools/abstract-pool"; @@ -11,10 +12,12 @@ import { Relay } from "nostr-tools/relay"; export const EX = 60 * 60 * 24; const coinos = await Relay.connect(config.nostr); -export const serverPubkey = getPublicKey( +export const serverSecret = bytesToHex( nip19.decode(config.nostrKey).data as Uint8Array, ); +export const serverPubkey = getPublicKey(serverSecret); + const alwaysTrue: any = (t: Event) => { t[Symbol("verified")] = true; return true; @@ -40,7 +43,6 @@ export async function publish(ev, url = config.nostr) { export async function handleZap(invoice, sender = undefined) { try { const pubkey = serverPubkey; - const sk = nip19.decode(config.nostrKey).data as Uint8Array; const zapreq = JSON.parse(invoice.description); if (!zapreq.tags || zapreq.tags.length === 0) { @@ -93,7 +95,7 @@ export async function handleZap(invoice, sender = undefined) { tags.push(["preimage", invoice.payment_preimage]); const ev = { pubkey, kind, created_at, content, tags }; - const signed = await finalizeEvent(ev, sk); + const signed = await finalizeEvent(ev, serverSecret); l("sending receipt"); |
