From 93d494bc5d149458ea50a8d7017e155b2e1936ab Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Wed, 18 Dec 2024 13:44:00 -0800 Subject: printer endpoint --- lib/invoices.ts | 19 +++++++++++-------- lib/payments.ts | 1 + 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'lib') diff --git a/lib/invoices.ts b/lib/invoices.ts index 5e59fd83..3259c46b 100644 --- a/lib/invoices.ts +++ b/lib/invoices.ts @@ -14,7 +14,6 @@ const lq = rpc(config.liquid); export const generate = async ({ invoice, user }) => { let { bolt11, - bolt12, aid, currency, expiry, @@ -73,13 +72,6 @@ export const generate = async ({ invoice, user }) => { if (r.payee !== nodeid) fail("invalid invoice"); amount = Math.round(r.amount_msat / 1000); r.bolt11 = bolt11; - } else if (bolt12) { - r = await ln.offer({ - amount_msat: amount ? `${amount + tip}sat` : "any", - label: id, - description: memo || "", - absolute_expiry: expiry, - }); } else { expiry ||= 60 * 60 * 24 * 30; r = await ln.invoice({ @@ -94,6 +86,17 @@ export const generate = async ({ invoice, user }) => { hash = r.bolt11; text = r.bolt11; + } else if (type === types.bolt12) { + const r = await ln.offer({ + amount: amount ? `${amount + tip}sat` : "any", + label: id, + description: memo || "", + absolute_expiry: expiry, + }); + + console.log("R", r); + hash = r.bolt12; + text = r.bolt12; } else if (type === types.bitcoin) { hash = await bc.getNewAddress(); text = bip21(hash, invoice); diff --git a/lib/payments.ts b/lib/payments.ts index af838758..3cc5a501 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -38,6 +38,7 @@ export const types = { liquid: "liquid", ecash: "ecash", reconcile: "reconcile", + bolt12: "bolt12", }; export const debit = async ({ -- cgit v1.2.3