aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-03-05 20:46:37 +0000
committerAdam Soltys <[email protected]>2025-03-05 20:46:37 +0000
commit118386e0691a0c80a0d8c19ab40bd3abf6859b84 (patch)
treeb67ed419680743a860a1bae16af1aab4fff2f759
parentb01b24f6a1007bc8a3b41d9aeb7060e7aedaac1c (diff)
downloadcoinos-server-118386e0691a0c80a0d8c19ab40bd3abf6859b84.tar.gz
coinos-server-118386e0691a0c80a0d8c19ab40bd3abf6859b84.zip
fix payment_hash lookup
-rw-r--r--lib/nwc.ts11
1 files changed, 7 insertions, 4 deletions
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) {}
}