diff options
| author | Adam Soltys <[email protected]> | 2025-07-19 22:55:10 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-19 22:55:10 -0700 |
| commit | 59fe8d2e24085239b15ca282c182d5c7cd1ce4de (patch) | |
| tree | baddfa93846a775e93f9253ef36ac63a4dfabc3e /routes | |
| parent | d7290476c1722b1f6d8de4cec11c75e979e893eb (diff) | |
| download | coinos-server-59fe8d2e24085239b15ca282c182d5c7cd1ce4de.tar.gz coinos-server-59fe8d2e24085239b15ca282c182d5c7cd1ce4de.zip | |
respect null tips
Diffstat (limited to 'routes')
| -rw-r--r-- | routes/lnurl.ts | 17 |
1 files changed, 15 insertions, 2 deletions
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, }, |
