From 118386e0691a0c80a0d8c19ab40bd3abf6859b84 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 5 Mar 2025 20:46:37 +0000 Subject: fix payment_hash lookup --- lib/nwc.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib') diff --git a/lib/nwc.ts b/lib/nwc.ts index c9419043..3b04eecf 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -367,10 +367,13 @@ const handle = (method, params, ev, app, user) => let payment_hash = p.payment_hash || pid; if (p.type === "lightning") { try { - ({ payment_hash } = - p.amount > 0 - ? await ln.listinvoices({ invstring: p.hash }) - : await ln.listpays({ bolt11: p.hash })); + if(p.amount > 0) { + const { invoices } = await ln.listinvoices({ invstring: p.hash }); + payment_hash ||= invoices[0].payment_hash; + } else { + const { pays } = await ln.listpays({ bolt11: p.hash }); + payment_hash ||= pays[0].payment_hash; + } } catch (e) {} } -- cgit v1.2.3