aboutsummaryrefslogtreecommitdiffstats
path: root/routes/lightning/user.js
diff options
context:
space:
mode:
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);
-};