From 3c41b9e4ca4d988e6a7631366421f94edf7bbb97 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 12 Feb 2025 13:37:24 -0800 Subject: catch payment errors --- lib/nwc.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/lib/nwc.ts b/lib/nwc.ts index ac9cf8a9..f5b8b11b 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -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); -- cgit v1.2.3