diff options
| author | Adam Soltys <[email protected]> | 2026-03-13 10:13:34 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-03-13 10:13:34 -0700 |
| commit | fa5188d7e4781e90d1f315274f840f60db326f7e (patch) | |
| tree | 6961757c2723efa2cc13334a0d7d3740a3ce7f7a | |
| parent | 69d17aea7e0cfdd6429fdbb07c2a1f5c7497e798 (diff) | |
| download | coinos-server-fa5188d7e4781e90d1f315274f840f60db326f7e.tar.gz coinos-server-fa5188d7e4781e90d1f315274f840f60db326f7e.zip | |
use bytes for nostr tools
| -rwxr-xr-x | bun.lockb | bin | 233820 -> 233820 bytes | |||
| -rw-r--r-- | lib/nostr.ts | 8 | ||||
| -rw-r--r-- | routes/nostr.ts | 1 |
3 files changed, 5 insertions, 4 deletions
| Binary files 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); |
