diff options
| author | Adam Soltys <[email protected]> | 2024-10-01 08:51:10 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-10-01 08:51:10 -0700 |
| commit | 1bba25c3952a5160d1a2ec977e18dff05baad442 (patch) | |
| tree | f722d43bf5be73ec287081bdb7d731f2d936040d | |
| parent | b0b0d2356e76c376c980a08493a6b28b9eeeec0a (diff) | |
| download | coinos-server-1bba25c3952a5160d1a2ec977e18dff05baad442.tar.gz coinos-server-1bba25c3952a5160d1a2ec977e18dff05baad442.zip | |
default opts
| -rw-r--r-- | lib/nostr.ts | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/nostr.ts b/lib/nostr.ts index 49d4d342..d6c9c643 100644 --- a/lib/nostr.ts +++ b/lib/nostr.ts @@ -1,9 +1,9 @@ import config from "$config"; import { l } from "$lib/logging"; -import { Relay, RelayPool, calculateId, signId, getPublicKey } from "nostr"; +import { Relay, RelayPool, getPublicKey } from "nostr"; import { g, s, db } from "$lib/db"; import { fail, wait } from "$lib/utils"; -import { nip19 } from "nostr-tools"; +import { nip19, finalizeEvent } from "nostr-tools"; import { emit } from "$lib/sockets"; import { hex } from "@scure/base"; @@ -188,8 +188,8 @@ let getUser = async (pubkey) => { ); }; -function send(ev, url, opts) { - let timeout = (opts && opts.timeout != null && opts.timeout) || 1000; +function send(ev, url, opts = { timeout: 1000 }) { + let { timeout } = opts; return new Promise((resolve, reject) => { let relay = Relay(url); @@ -216,8 +216,8 @@ function send(ev, url, opts) { } export async function handleZap(invoice) { - let { data: privkey } = nip19.decode(config.nostrKey); let pubkey = serverPubkey; + let sk = nip19.decode(config.nostrKey).data as Uint8Array; let zapreq = JSON.parse(invoice.description); if (!zapreq.tags || zapreq.tags.length === 0) { @@ -264,8 +264,7 @@ export async function handleZap(invoice) { tags.push(["preimage", invoice.payment_preimage]); let ev = { pubkey, kind, created_at, content, tags }; - ev.id = await calculateId(ev); - ev.sig = await signId(privkey, ev.id); + ev = await finalizeEvent(ev, sk); l("sending receipt"); |
