From 8c7fa95d44aabd38fadc3ef955d835ad3379ec6c Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 18 Sep 2025 14:42:13 -0700 Subject: sendinvoice support --- lib/lightning.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'lib/lightning.ts') diff --git a/lib/lightning.ts b/lib/lightning.ts index 8f5f44bc..f8d0f6a4 100644 --- a/lib/lightning.ts +++ b/lib/lightning.ts @@ -27,7 +27,7 @@ export async function listenForLightning() { try { if (!preimage) return; - const invoice = await getInvoice(bolt11 ?? local_offer_id); + const invoice = await getInvoice(bolt11 ?? local_offer_id ?? bolt12); if (!invoice) return warn("received lightning with no invoice", bolt11); const p = await getPayment(bolt11 || bolt12); @@ -75,10 +75,10 @@ export async function replay(index) { try { if (!preimage) return; - const invoice = await getInvoice(bolt11 ?? local_offer_id); + const invoice = await getInvoice(bolt11 ?? local_offer_id ?? bolt12); if (!invoice) return warn("received lightning with no invoice", bolt11); - const p = await getPayment(bolt11 || bolt12); + let p = await getPayment(bolt11 || bolt12); if (p) return warn("already processed", bolt11 || bolt12); if (invoice?.memo) { @@ -93,13 +93,15 @@ export async function replay(index) { } } - await credit({ + p = await credit({ hash: bolt11 || bolt12, amount: received, memo: invoice.memo, ref: preimage, type: bolt12 ? PaymentType.bolt12 : PaymentType.lightning, }); + + return p; } catch (e) { console.log(e); err("problem receiving lightning payment", e.message); -- cgit v1.2.3