diff options
| author | Adam Soltys <[email protected]> | 2025-09-18 14:42:13 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-09-18 14:42:13 -0700 |
| commit | 8c7fa95d44aabd38fadc3ef955d835ad3379ec6c (patch) | |
| tree | c5c3b9f5490acd944656438d31355081835098d3 /lib/lightning.ts | |
| parent | d2db386e53296babe4e4068ca8d68b3c052e0efb (diff) | |
| download | coinos-server-8c7fa95d44aabd38fadc3ef955d835ad3379ec6c.tar.gz coinos-server-8c7fa95d44aabd38fadc3ef955d835ad3379ec6c.zip | |
sendinvoice support
Diffstat (limited to 'lib/lightning.ts')
| -rw-r--r-- | lib/lightning.ts | 10 |
1 files changed, 6 insertions, 4 deletions
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); |
