aboutsummaryrefslogtreecommitdiffstats
path: root/lib/nwc.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/nwc.ts')
-rw-r--r--lib/nwc.ts19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/nwc.ts b/lib/nwc.ts
index e889dfdf..2b2649a6 100644
--- a/lib/nwc.ts
+++ b/lib/nwc.ts
@@ -71,12 +71,6 @@ let handle = (method, params, user) =>
let invoice = await getInvoice(pr);
let recipient = await g(`user:${invoice.uid}`);
- if (invoice.memo.includes("9734")) {
- try {
- await handleZap(invoice);
- } catch (e) {}
- }
-
let { id: preimage } = await sendInternal({
amount,
invoice,
@@ -84,6 +78,19 @@ let handle = (method, params, user) =>
sender: user,
});
+ if (invoice.memo.includes("9734")) {
+ let { invoices } = await ln.listinvoices({ invstring: pr });
+ let inv = invoices[0];
+ inv.payment_preimage = preimage;
+ inv.paid_at = Math.floor(Date.now() / 1000);
+ try {
+ await handleZap(inv);
+ } catch (e) {
+ console.log("zap receipt failed", e);
+ }
+ }
+
+
return result({ preimage });
} else {
await sendLightning({