diff options
| author | Adam Soltys <[email protected]> | 2020-05-14 20:45:18 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2020-05-14 20:45:18 -0700 |
| commit | b45deffeda2f616453b8284dcfb78d65a48b858e (patch) | |
| tree | 96a6f250eb9404082891737f4925b8c4d1775fb7 /routes/payments.js | |
| parent | a9a061656668965fbf627ae73165d361d8ca9183 (diff) | |
| download | coinos-server-b45deffeda2f616453b8284dcfb78d65a48b858e.tar.gz coinos-server-b45deffeda2f616453b8284dcfb78d65a48b858e.zip | |
support opt-in to the different networks
Diffstat (limited to 'routes/payments.js')
| -rw-r--r-- | routes/payments.js | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/routes/payments.js b/routes/payments.js index 02e0c88f..81d7540b 100644 --- a/routes/payments.js +++ b/routes/payments.js @@ -4,25 +4,13 @@ const { Op } = require("sequelize"); const { join } = require("path"); (async () => { - bc = new BitcoinCore(config.bitcoin); - lq = new BitcoinCore(config.liquid); - - if (config.lna.clightning) { - const lnapath = join(require('os').homedir(), '.lightningreg/regtest') - const lnbpath = join(require('os').homedir(), '.lightningregb/regtest') - lna = require('clightning-client')(lnapath); - lnb = require('clightning-client')(lnbpath); - } else { - lna = lnd(config.lna); - lnb = lnd(config.lnb); - } - seen = []; addresses = {}; + await db.User.findAll({ attributes: ["username", "address", "liquid"] }).map(u => { - addresses[u.address] = u.username; + if (u.address) addresses[u.address] = u.username; if (u.liquid) addresses[u.liquid] = u.username; }); @@ -32,18 +20,36 @@ const { join } = require("path"); app.post("/send", auth, require("./send")); - app.post("/lightning/invoice", auth, require("./lightning/invoice")); - app.post("/lightning/query", auth, require("./lightning/query")); - app.post("/lightning/send", auth, require("./lightning/send")); - require("./lightning/receive"); + if (config.lna) { + if (config.lna.clightning) { + const lnapath = join(require('os').homedir(), '.lightningreg/regtest') + const lnbpath = join(require('os').homedir(), '.lightningregb/regtest') + lna = require('clightning-client')(lnapath); + lnb = require('clightning-client')(lnbpath); + } else { + lna = lnd(config.lna); + lnb = lnd(config.lnb); + } - app.post("/bitcoin/fee", auth, require("./bitcoin/fee")); - app.post("/bitcoin/send", auth, require("./bitcoin/send")); - require("./bitcoin/receive"); + app.post("/lightning/invoice", auth, require("./lightning/invoice")); + app.post("/lightning/query", auth, require("./lightning/query")); + app.post("/lightning/send", auth, require("./lightning/send")); + require("./lightning/receive"); + } + + if (config.bitcoin) { + bc = new BitcoinCore(config.bitcoin); + app.post("/bitcoin/fee", auth, require("./bitcoin/fee")); + app.post("/bitcoin/send", auth, require("./bitcoin/send")); + require("./bitcoin/receive"); + } - app.post("/liquid/fee", auth, require("./liquid/fee")); - app.post("/liquid/send", auth, require("./liquid/send")); - require("./liquid/receive"); + if (config.liquid) { + lq = new BitcoinCore(config.liquid); + app.post("/liquid/fee", auth, require("./liquid/fee")); + app.post("/liquid/send", auth, require("./liquid/send")); + require("./liquid/receive"); + } app.get("/payments", auth, async (req, res) => { const payments = await db.Payment.findAll({ |
