diff options
| author | Adam Soltys <[email protected]> | 2020-03-11 15:10:40 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-03-11 15:10:40 -0700 |
| commit | c0888fab024cc9f7c99812bfabf9d7774312dbf7 (patch) | |
| tree | cad95683af97432f6092a2c2bae10fbb7a588db5 /routes/payments.js | |
| parent | bf2b51f0c2ae9b8f0f330dde6411e45fc0da8a25 (diff) | |
| download | coinos-server-c0888fab024cc9f7c99812bfabf9d7774312dbf7.tar.gz coinos-server-c0888fab024cc9f7c99812bfabf9d7774312dbf7.zip | |
refactor
Diffstat (limited to 'routes/payments.js')
| -rw-r--r-- | routes/payments.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/routes/payments.js b/routes/payments.js new file mode 100644 index 00000000..d5038b08 --- /dev/null +++ b/routes/payments.js @@ -0,0 +1,40 @@ +const BitcoinCore = require("bitcoin-core"); +const createLnrpc = require("../lib/createLnrpc"); + +(async () => { + bc = new BitcoinCore(config.bitcoin); + lq = new BitcoinCore(config.liquid); + + lna = await createLnrpc(config.lna); + lnb = await createLnrpc(config.lnb); + + seen = []; + addresses = {}; + await db.User.findAll({ + attributes: ["username", "address", "liquid"] + }).map(u => { + addresses[u.address] = u.username; + if (u.liquid) addresses[u.liquid] = u.username; + }); + + app.post("/lightning/invoice", auth, require("./lightning/invoice")); + app.post("/lightning/query", auth, require("./lightning/query")); + app.post("/lightning/send", auth, require("./lightning/send")); + app.post("/lightning/user", auth, require("./lightning/user")); + + app.post("/bitcoin/send", auth, require("./bitcoin/send")); + app.post("/bitcoin/fee", auth, require("./bitcoin/fee")); + + app.post("/liquid/send", auth, require("./liquid/send")); + app.post("/liquid/fee", auth, require("./liquid/fee")); + + app.get("/payments", auth, async (req, res) => { + const payments = await db.Payment.findAll({ + where: { user_id: req.user.id }, + order: [["id", "DESC"]] + }); + + emit(req.user.username, "payments", payments); + res.send(payments); + }); +})(); |
