diff options
| author | Adam Soltys <[email protected]> | 2024-11-17 00:20:22 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2024-11-17 00:20:22 -0800 |
| commit | 0acff5707d6838c14defef2bf0d08a7281a44a21 (patch) | |
| tree | 9e16243af6c430e24afb930c3aaaef736b9bbc80 | |
| parent | 76c0a2a00eaa4f6b77cb34290e207c78fea971f8 (diff) | |
| download | coinos-server-0acff5707d6838c14defef2bf0d08a7281a44a21.tar.gz coinos-server-0acff5707d6838c14defef2bf0d08a7281a44a21.zip | |
handle blank offers
| -rw-r--r-- | index.ts | 12 | ||||
| -rw-r--r-- | routes/payments.ts | 7 |
2 files changed, 10 insertions, 9 deletions
@@ -1,12 +1,12 @@ import app from "$lib/app"; -import { auth, admin, optional } from "$lib/auth"; +import { admin, auth, optional } from "$lib/auth"; import { listenForLightning } from "$lib/lightning"; import { getLocations } from "$lib/locations"; +import nwc from "$lib/nwc"; import { catchUp, check } from "$lib/payments"; import { getFx } from "$lib/rates"; import { sendHeartbeat } from "$lib/sockets"; -import nwc from "$lib/nwc"; import ecash from "$routes/ecash"; import email from "$routes/email"; @@ -67,7 +67,7 @@ app.post("/send", auth, payments.internal); app.post("/gateway", payments.gateway); app.post("/replace", auth, payments.replace); app.get("/decode/:bolt11", payments.decode); -app.get("/offer/:offer", payments.offer); +app.post("/fetchinvoice", payments.fetchinvoice); app.get("/encode", lnurl.encode); app.get("/decode", lnurl.decode); @@ -134,12 +134,12 @@ app.post("/echo", (req, res) => { res.send(req.body); }); -let host: string = process.env["HOST"] || "0.0.0.0"; -let port: number = parseInt(process.env["PORT"]) || 3119; +const host: string = process.env["HOST"] || "0.0.0.0"; +const port: number = parseInt(process.env["PORT"]) || 3119; app.listen({ host, port }); -let logerr = (e: Error) => +const logerr = (e: Error) => // (e && // e.message && // (e.message.includes("Invalid") || diff --git a/routes/payments.ts b/routes/payments.ts index dfd9ad36..c8fd07dd 100644 --- a/routes/payments.ts +++ b/routes/payments.ts @@ -202,6 +202,7 @@ export default { res.send({ alias, amount, ourfee }); } catch (e) { + console.log(e); err("problem parsing", e.message); bail(res, e.message); } @@ -548,8 +549,8 @@ export default { res.send(await ln.decode(bolt11)); }, - async offer(req, res) { - const { offer } = req.params; - res.send(await ln.fetchinvoice(offer)); + async fetchinvoice(req, res) { + const { amount, offer } = req.body; + res.send(await ln.fetchinvoice(offer, amount ? amount * 1000 : null)); }, }; |
