From 703564c452f3549adc2c23c62ff11d5e713b681e Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 26 Dec 2024 22:36:12 +0000 Subject: bolt12 replay --- lib/payments.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/payments.ts') diff --git a/lib/payments.ts b/lib/payments.ts index c9d1c74c..0797721b 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -67,7 +67,7 @@ export const debit = async ({ let iid; if (invoice) { - if (invoice.received >= amount) fail("Invoice already paid"); + if (invoice.received >= amount && invoice.type !== types.bolt12) fail("Invoice already paid"); ({ id: iid } = invoice); ref = invoice.uid; @@ -151,7 +151,15 @@ export const credit = async ({ }) => { amount = parseInt(amount) || 0; - const inv = await getInvoice(hash); + let inv; + if (type === types.bolt12) { + let { invoices } = await ln.listinvoices({ invstring: hash }); + let { local_offer_id } = invoices[0]; + inv = await getInvoice(local_offer_id); + } else { + inv = await getInvoice(hash); + } + if (!inv) { await db.sAdd("missing", ref.split(":")[0]); return; -- cgit v1.2.3