diff options
| author | Adam Soltys <[email protected]> | 2025-07-19 08:42:13 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2025-07-19 08:42:13 -0700 |
| commit | d7290476c1722b1f6d8de4cec11c75e979e893eb (patch) | |
| tree | 8bc6b87e8b04f84121bd1ac269faf8baa489a91b | |
| parent | b3b12c6cfff01160c974cca6545a8998e6e9b3af (diff) | |
| download | coinos-server-d7290476c1722b1f6d8de4cec11c75e979e893eb.tar.gz coinos-server-d7290476c1722b1f6d8de4cec11c75e979e893eb.zip | |
record prompt setting for lnurl invoices
| -rw-r--r-- | routes/lnurl.ts | 53 |
1 files changed, 4 insertions, 49 deletions
diff --git a/routes/lnurl.ts b/routes/lnurl.ts index b1b7b8f0..4be33ef1 100644 --- a/routes/lnurl.ts +++ b/routes/lnurl.ts @@ -103,6 +103,7 @@ export default { const iid = await g(`lnurl:${id}:invoice`); const uid = await g(`lnurl:${id}`); const user = await getUser(uid); + if (!user) fail("user not found"); let { username } = user; username = username.replace(/\s/g, "").toLowerCase(); @@ -176,13 +177,15 @@ export default { } } - if (!invoice) + if (!invoice) { invoice = await generate({ invoice: { + prompt: user.prompt, type: PaymentType.lightning, }, user, }); + } const { id: uid } = user; @@ -213,52 +216,4 @@ export default { bail(res, e.message); } }, - - // async withdraw(req, res) { - // try { - // const { pr, k1: id } = req.query; - // const invoice = await getInvoice(pr); - // const { amount_msat } = await ln.decode(pr); - // const amount = Math.ceil(amount_msat / 1000); - // await db.debit(`fund:${id}`, "", amount, 0, 0, 0); - // let p; - // if (invoice) { - // const { hash } = invoice; - // p = await credit({ - // hash, - // amount, - // memo: id, - // ref: id, - // type: PaymentType.fund, - // }); - // } else { - // await ln.xpay({ - // invstring: pr.replace(/\s/g, "").toLowerCase(), - // maxfee: 0, - // retry_for: 10, - // }); - // const rates = await g("rates"); - // p = { - // id: v4(), - // amount: -amount, - // hash: pr, - // confirmed: true, - // rate: rates.USD, - // currency: "USD", - // type: PaymentType.fund, - // ref: id, - // created: Date.now(), - // }; - // await s(`payment:${p.id}`, p); - // await s(`payment:${pr}`, p); - // } - // - // await db.lPush(`fund:${id}:payments`, p.id); - // res.send({ status: "OK" }); - // } catch (e) { - // console.log(e); - // warn("lnurlw failed", e.message); - // res.send({ status: "ERROR", reason: "Withdrawal failed" }); - // } - // }, }; |
