diff options
| author | Adam Soltys <[email protected]> | 2025-06-23 08:48:52 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-06-23 08:50:12 -0700 |
| commit | 6aa385b4bcfe5a97bbf21263126f61adcd3bc606 (patch) | |
| tree | 68a65dc4c92e8df1823dcba7047d9680546f9678 /routes/lnurl.ts | |
| parent | e92f232d7194626d9182a5eaeff3d42d67fbb53f (diff) | |
| download | coinos-server-6aa385b4bcfe5a97bbf21263126f61adcd3bc606.tar.gz coinos-server-6aa385b4bcfe5a97bbf21263126f61adcd3bc606.zip | |
mark self-generated invoices
Diffstat (limited to 'routes/lnurl.ts')
| -rw-r--r-- | routes/lnurl.ts | 16 |
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, |
