aboutsummaryrefslogtreecommitdiffstats
path: root/lib/payments.ts
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2024-12-26 22:36:12 +0000
committerAdam Soltys <[email protected]>2024-12-26 22:37:03 +0000
commit703564c452f3549adc2c23c62ff11d5e713b681e (patch)
treeb369f162feceed4ad452bd10eae6f9ed0716a2fd /lib/payments.ts
parentbe16090d086a05ed03fc8149581c49c717826535 (diff)
downloadcoinos-server-703564c452f3549adc2c23c62ff11d5e713b681e.tar.gz
coinos-server-703564c452f3549adc2c23c62ff11d5e713b681e.zip
bolt12 replay
Diffstat (limited to 'lib/payments.ts')
-rw-r--r--lib/payments.ts12
1 files changed, 10 insertions, 2 deletions
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;