From fa5188d7e4781e90d1f315274f840f60db326f7e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 13 Mar 2026 10:13:34 -0700 Subject: use bytes for nostr tools --- bun.lockb | Bin 233820 -> 233820 bytes lib/nostr.ts | 8 ++++---- routes/nostr.ts | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bun.lockb b/bun.lockb index 2b8ac523..4f008120 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/lib/nostr.ts b/lib/nostr.ts index 1d4ab56f..69c4758a 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -3,7 +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 { bytesToHex, hexToBytes } 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"; @@ -20,8 +20,8 @@ export const serverSecret2 = bytesToHex( nip19.decode(config.nostrKey2).data as Uint8Array, ); -export const serverPubkey = getPublicKey(serverSecret); -export const serverPubkey2 = getPublicKey(serverSecret2); +export const serverPubkey = getPublicKey(hexToBytes(serverSecret)); +export const serverPubkey2 = getPublicKey(hexToBytes(serverSecret2)); const alwaysTrue: any = (t: Event) => { t[Symbol("verified")] = true; @@ -100,7 +100,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, serverSecret2); + const signed = await finalizeEvent(ev, hexToBytes(serverSecret2)); l("sending receipt"); diff --git a/routes/nostr.ts b/routes/nostr.ts index 9c61bf16..35ed6fce 100644 --- a/routes/nostr.ts +++ b/routes/nostr.ts @@ -35,6 +35,7 @@ export default { if (event) return res.send(event); event = await get({ ids: [id] }); + if (!event) return res.code(404).send("Not found"); if (!full) return res.send(event); const parts = parseContent(event); -- cgit v1.2.3