From 084b62733b99bc3caaf4ac177e678929faf3151f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 5 Feb 2025 15:20:32 -0800 Subject: use real lightning payments for mint payments --- lib/nwc.ts | 38 ++++++++++++++++++++------------------ 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/lib/nwc.ts b/lib/nwc.ts index 73b7decd..4055a9f4 100644 --- a/lib/nwc.ts +++ b/lib/nwc.ts @@ -101,26 +101,28 @@ const handle = (method, params, user, ev) => const invoice = await getInvoice(pr); const recipient = await g(`user:${invoice.uid}`); - const { id: preimage } = await sendInternal({ - amount, - invoice, - recipient, - sender: user, - }); - - if (invoice.memo?.includes("9734")) { - const { invoices } = await ln.listinvoices({ invstring: pr }); - const inv = invoices[0]; - inv.payment_preimage = preimage; - inv.paid_at = Math.floor(Date.now() / 1000); - try { - await handleZap(inv, user.pubkey); - } catch (e) { - console.log("zap receipt failed", e); + if (recipient?.username !== "mint") { + const { id: preimage } = await sendInternal({ + amount, + invoice, + recipient, + sender: user, + }); + + if (invoice.memo?.includes("9734")) { + const { invoices } = await ln.listinvoices({ invstring: pr }); + const inv = invoices[0]; + inv.payment_preimage = preimage; + inv.paid_at = Math.floor(Date.now() / 1000); + try { + await handleZap(inv, user.pubkey); + } catch (e) { + console.log("zap receipt failed", e); + } } - } - return result({ preimage }); + return result({ preimage }); + } } await sendLightning({ amount, -- cgit v1.2.3