aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/user.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2020-05-07 20:15:56 -0700
committerAdam Soltys <[email protected]>2020-05-07 20:58:24 -0700
commit47aa48402a0d34dd8ab11f0f315393fcc4f5c61b (patch)
tree2e907e64628d26c4707660e854e9bc87b332ff08 /routes/lightning/user.js
parent2f0f9e640ead76518f7f8013b16704da89421ee4 (diff)
downloadcoinos-server-47aa48402a0d34dd8ab11f0f315393fcc4f5c61b.tar.gz
coinos-server-47aa48402a0d34dd8ab11f0f315393fcc4f5c61b.zip
c-lightning support
Diffstat (limited to 'routes/lightning/user.js')
-rw-r--r--routes/lightning/user.js52
1 files changed, 0 insertions, 52 deletions
diff --git a/routes/lightning/user.js b/routes/lightning/user.js
deleted file mode 100644
index 41bd507f..00000000
--- a/routes/lightning/user.js
+++ /dev/null
@@ -1,52 +0,0 @@
-const bolt11 = require("bolt11");
-
-module.exports = async (req, res) => {
- let { payuser, amount } = req.body;
-
- let user = await db.User.findOne({
- where: {
- username: payuser
- }
- });
-
- const account = await db.Account.findOne({
- where: {
- user_id: user.id,
- asset: config.liquid.btcasset
- }
- });
-
- l.info("paying user", req.user.username, payuser);
-
- if (!user) {
- return res.status(500).send("Couldn't find the user you're trying to pay");
- }
- let err = m => res.status(500).send(m);
-
- let invoice;
- try {
- invoice = await lnb.addInvoice({ value: amount });
- } catch (e) {
- return err(e.message);
- }
-
- let hash = invoice.payment_request;
-
- await db.Payment.create({
- user_id: user.id,
- account_id: account.id,
- hash,
- amount,
- rate: app.get("rates")[req.user.currency],
- currency: req.user.currency,
- tip: 0,
- confirmed: true,
- received: false,
- network: "LNBTC"
- });
-
- req.url = "/lightning/send";
- let payreq = bolt11.decode(hash);
- req.body.payreq = hash;
- return app._router.handle(req, res);
-};