aboutsummaryrefslogtreecommitdiffstats
path: root/routes/liquid/broadcast.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2023-01-08 21:05:34 -0800
committerAdam Soltys <[email protected]>2023-01-08 21:05:34 -0800
commitdce07aa93b3c2f47aca0c24cea6adde9ec37f1a7 (patch)
tree6c6b8930ebe9c2cc5b8d1f759e61260f509fdd7a /routes/liquid/broadcast.js
parentf7b844883506a8072213245b9b8a2b988694e4f5 (diff)
downloadcoinos-server-dce07aa93b3c2f47aca0c24cea6adde9ec37f1a7.tar.gz
coinos-server-dce07aa93b3c2f47aca0c24cea6adde9ec37f1a7.zip
tech debt jubilee
Diffstat (limited to 'routes/liquid/broadcast.js')
-rw-r--r--routes/liquid/broadcast.js58
1 files changed, 0 insertions, 58 deletions
diff --git a/routes/liquid/broadcast.js b/routes/liquid/broadcast.js
deleted file mode 100644
index 820c0be1..00000000
--- a/routes/liquid/broadcast.js
+++ /dev/null
@@ -1,58 +0,0 @@
-import { emit } from "$lib/sockets";
-import store from "$lib/store";
-import { requirePin } from "$lib/utils";
-
-export default async (req, res) => {
- try {
- await requirePin(req);
-
- const { user } = req;
- let hash = await lq.sendRawTransaction(req.body.tx);
-
- if (user) {
- await db.transaction(async transaction => {
- let account = await db.Account.findOne({
- where: {
- id: user.account_id
- },
- lock: transaction.LOCK.UPDATE,
- transaction
- });
-
- let payment = await db.Payment.create(
- {
- ...req.body.payment,
- hash,
- amount: -req.body.payment.amount,
- tip: 0,
- account_id: account.id,
- user_id: user.id,
- rate: store.rates[user.currency],
- currency: user.currency,
- confirmed: true,
- received: false,
- network: "liquid"
- },
- { transaction }
- );
-
- await account.increment(
- { balance: payment.amount - payment.fee },
- { transaction }
- );
- await account.reload({ transaction });
-
- payment = payment.get({ plain: true });
- payment.account = account.get({ plain: true });
- emit(user.username, "payment", payment);
- emit(user.username, "account", payment.account);
- res.send(payment);
- });
- } else {
- res.send(hash);
- }
- } catch (e) {
- err("problem broadcasting liquid transaction", e);
- res.code(500).send(e.message);
- }
-};