diff options
| author | Adam Soltys <[email protected]> | 2022-09-06 09:18:19 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2022-09-06 09:18:19 -0700 |
| commit | 8a080ef9a198799e7ee31cf81f92afd5495e4074 (patch) | |
| tree | 8da36c843846f47918a5acadd95da30d8d63bcc6 /routes/payments.js | |
| parent | 412df5f844de11b3fc71bb7ffaf9c8e1d9f19d65 (diff) | |
| download | coinos-server-8a080ef9a198799e7ee31cf81f92afd5495e4074.tar.gz coinos-server-8a080ef9a198799e7ee31cf81f92afd5495e4074.zip | |
missing imports
Diffstat (limited to 'routes/payments.js')
| -rw-r--r-- | routes/payments.js | 155 |
1 files changed, 77 insertions, 78 deletions
diff --git a/routes/payments.js b/routes/payments.js index d8518da4..4939394f 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -56,7 +56,6 @@ app.get("/except", adminAuth, (req, res) => { }); if (config.lna) { - console.log("LIGHTNING ROUTES") app.post("/lightning/channel", lnRoutes.channel); app.post("/lightning/invoice", lnRoutes.invoice); app.post("/lightning/query", auth, lnRoutes.query); @@ -68,80 +67,80 @@ if (config.lna) { // app.post("/lightning/channelRequest", channelRequest) // } } -// -// if (config.bitcoin) { -// app.post("/bitcoin/broadcast", optionalAuth, btcRoutes.broadcast); -// app.get("/bitcoin/generate", auth, btcRoutes.generate); -// app.post("/bitcoin/sweep", auth, btcRoutes.sweep); -// app.post("/bitcoin/fee", auth, btcRoutes.fee); -// app.post("/bitcoin/send", auth, btcRoutes.send); -// import("./bitcoin/receive"); -// -// setTimeout(async () => { -// try { -// const address = await bc.getNewAddress(); -// const { hdkeypath } = await bc.getAddressInfo(address); -// const parts = hdkeypath.split("/"); -// store.bcAddressIndex = parts[parts.length - 1].replace("'", ""); -// } catch (e) { -// console.error(e); -// } -// }, 50); -// } -// -// if (config.liquid) { -// app.post("/liquid/broadcast", optionalAuth, lqRoutes.broadcast); -// app.get("/liquid/generate", auth, lqRoutes.generate); -// // app.post("/liquid/fee", auth, lqRoutes.fee); -// app.post("/liquid/send", auth, lqRoutes.send); -// // app.post("/taxi", auth, lqRoutes.taxi); -// import("./liquid/receive"); -// -// setTimeout(async () => { -// try { -// const address = await lq.getNewAddress(); -// const { hdkeypath } = await lq.getAddressInfo(address); -// const parts = hdkeypath.split("/"); -// store.lqAddressIndex = parts[parts.length - 1].slice(0, -1); -// } catch (e) { -// warn("Problem getting liquid address index", e.message); -// } -// }, 50); -// } -// -// app.get("/payments", auth, async (req, res) => { -// if (!req.user.account_id) return res.send([]); -// let payments = await db.Payment.findAll({ -// where: { -// account_id: req.user.account_id -// }, -// order: [["id", "DESC"]], -// include: { -// model: db.Account, -// as: "account" -// } -// }); -// -// res.send(payments); -// }); -// -// app.get("/payment/:redeemcode", async (req, res) => { -// try { -// const { redeemcode } = req.params; -// let payment = await db.Payment.findOne({ -// where: { -// redeemcode -// }, -// include: { -// model: db.Account, -// as: "account" -// } -// }); -// -// if (!payment) fail("invalid code"); -// -// res.send(payment); -// } catch (e) { -// res.code(500).send(e.message); -// } -// }); + +if (config.bitcoin) { + app.post("/bitcoin/broadcast", optionalAuth, btcRoutes.broadcast); + app.get("/bitcoin/generate", auth, btcRoutes.generate); + app.post("/bitcoin/sweep", auth, btcRoutes.sweep); + app.post("/bitcoin/fee", auth, btcRoutes.fee); + app.post("/bitcoin/send", auth, btcRoutes.send); + import("./bitcoin/receive"); + + setTimeout(async () => { + try { + const address = await bc.getNewAddress(); + const { hdkeypath } = await bc.getAddressInfo(address); + const parts = hdkeypath.split("/"); + store.bcAddressIndex = parts[parts.length - 1].replace("'", ""); + } catch (e) { + console.error(e); + } + }, 50); +} + +if (config.liquid) { + app.post("/liquid/broadcast", optionalAuth, lqRoutes.broadcast); + app.get("/liquid/generate", auth, lqRoutes.generate); + // app.post("/liquid/fee", auth, lqRoutes.fee); + app.post("/liquid/send", auth, lqRoutes.send); + // app.post("/taxi", auth, lqRoutes.taxi); + import("./liquid/receive"); + + setTimeout(async () => { + try { + const address = await lq.getNewAddress(); + const { hdkeypath } = await lq.getAddressInfo(address); + const parts = hdkeypath.split("/"); + store.lqAddressIndex = parts[parts.length - 1].slice(0, -1); + } catch (e) { + warn("Problem getting liquid address index", e.message); + } + }, 50); +} + +app.get("/payments", auth, async (req, res) => { + if (!req.user.account_id) return res.send([]); + let payments = await db.Payment.findAll({ + where: { + account_id: req.user.account_id + }, + order: [["id", "DESC"]], + include: { + model: db.Account, + as: "account" + } + }); + + res.send(payments); +}); + +app.get("/payment/:redeemcode", async (req, res) => { + try { + const { redeemcode } = req.params; + let payment = await db.Payment.findOne({ + where: { + redeemcode + }, + include: { + model: db.Account, + as: "account" + } + }); + + if (!payment) fail("invalid code"); + + res.send(payment); + } catch (e) { + res.code(500).send(e.message); + } +}); |
