aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lnurl.ts
diff options
context:
space:
mode:
Diffstat (limited to 'routes/lnurl.ts')
-rw-r--r--routes/lnurl.ts16
1 files changed, 12 insertions, 4 deletions
diff --git a/routes/lnurl.ts b/routes/lnurl.ts
index e5b3e60c..18785164 100644
--- a/routes/lnurl.ts
+++ b/routes/lnurl.ts
@@ -46,7 +46,8 @@ export default {
bech32.fromWords(bech32.decode(text, 20000).words),
).toString();
- res.send(await got(url).json());
+ const r = await got(url).json();
+ res.send(r);
} catch (e) {
bail(res, e.message);
}
@@ -156,11 +157,18 @@ export default {
try {
const user = await getUser(username);
const iid = await db.lIndex(`${user.id}:invoices`, 0);
- const invoice = await getInvoice(iid);
+ let invoice = await getInvoice(iid);
const fiveMinutes = 1000 * 60 * 5;
const paid = invoice.received >= invoice.amount;
const expired = Date.now() - invoice.created > fiveMinutes;
- if (paid || expired) fail("No active invoice");
+ if (paid || expired || !invoice.own) {
+ invoice = await generate({
+ invoice: {
+ type: PaymentType.lightning,
+ },
+ user,
+ });
+ }
const { id: uid } = user;
@@ -175,7 +183,7 @@ export default {
res.send({
allowsNostr: true,
minSendable: invoice.amount * 1000,
- maxSendable: invoice.amount * 1000,
+ maxSendable: invoice.amount ? invoice.amount * 1000 : undefined,
metadata,
nostrPubkey: serverPubkey,
commentAllowed: 512,