From 59fe8d2e24085239b15ca282c182d5c7cd1ce4de Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 19 Jul 2025 22:55:10 -0700 Subject: respect null tips --- routes/lnurl.ts | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'routes') diff --git a/routes/lnurl.ts b/routes/lnurl.ts index 4be33ef1..dc51e8fc 100644 --- a/routes/lnurl.ts +++ b/routes/lnurl.ts @@ -160,12 +160,13 @@ export default { }, async pay(req, res) { - const { username } = req.params; + const { amount, username } = req.params; try { const user = await getUser(username); const invoices = await db.lRange(`${user.id}:invoices`, 0, 10); let invoice; + for (const iid of invoices) { const i = await getInvoice(iid); const paid = i.amount > 0 && i.received >= i.amount; @@ -177,9 +178,21 @@ export default { } } - if (!invoice) { + if (invoice) { + if (amount?.startsWith("+")) { + const tip = invoice.amount * amount.split("+")[1]; + invoice = await generate({ + invoice: { + ...invoice, + tip, + }, + user, + }); + } + } else { invoice = await generate({ invoice: { + amount, prompt: user.prompt, type: PaymentType.lightning, }, -- cgit v1.2.3