aboutsummaryrefslogtreecommitdiffstats
path: root/routes
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2025-07-19 22:55:10 -0700
committerAdam Soltys <[email protected]>2025-07-19 22:55:10 -0700
commit59fe8d2e24085239b15ca282c182d5c7cd1ce4de (patch)
treebaddfa93846a775e93f9253ef36ac63a4dfabc3e /routes
parentd7290476c1722b1f6d8de4cec11c75e979e893eb (diff)
downloadcoinos-server-59fe8d2e24085239b15ca282c182d5c7cd1ce4de.tar.gz
coinos-server-59fe8d2e24085239b15ca282c182d5c7cd1ce4de.zip
respect null tips
Diffstat (limited to 'routes')
-rw-r--r--routes/lnurl.ts17
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,
},