diff options
| author | Adam Soltys <[email protected]> | 2025-02-12 13:37:24 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-02-12 13:37:24 -0800 |
| commit | 3c41b9e4ca4d988e6a7631366421f94edf7bbb97 (patch) | |
| tree | b9b62f773b5765626d9629ca7242d61c90836aae | |
| parent | 7e8a215826a2bc83728cf9c017e5960aac38c0b0 (diff) | |
| download | coinos-server-3c41b9e4ca4d988e6a7631366421f94edf7bbb97.tar.gz coinos-server-3c41b9e4ca4d988e6a7631366421f94edf7bbb97.zip | |
catch payment errors
| -rw-r--r-- | lib/nwc.ts | 17 |
1 files changed, 10 insertions, 7 deletions
@@ -5,10 +5,10 @@ import { err, l } from "$lib/logging"; import { handleZap, serverPubkey, serverSecret } from "$lib/nostr"; import { sendInternal, sendKeysend, sendLightning } from "$lib/payments"; import { fail, getInvoice, sleep } from "$lib/utils"; +import { hexToBytes } from "@noble/hashes/utils"; import { Relay } from "nostr"; import { finalizeEvent, nip04 } from "nostr-tools"; import type { UnsignedEvent } from "nostr-tools"; -import { hexToBytes } from "@noble/hashes/utils"; const result = (result) => ({ result }); const error = (error) => ({ error }); @@ -330,12 +330,15 @@ const handle = (method, params, ev, app, user) => if (p.amount < 0 && type === "incoming") continue; if (p.amount > 0 && type === "outgoing") continue; - const { payment_hash } = - p.type === "lightning" - ? p.amount > 0 - ? await ln.listinvoices({ invstring: p.hash }) - : await ln.listpays({ bolt11: p.hash }) - : p.id; + let payment_hash; + try { + ({ payment_hash } = + p.type === "lightning" + ? p.amount > 0 + ? await ln.listinvoices({ invstring: p.hash }) + : await ln.listpays({ bolt11: p.hash }) + : p.id); + } catch (e) {} const created_at = Math.floor(p.created / 1000); |
