aboutsummaryrefslogtreecommitdiffstats
path: root/routes/bitcoin/send.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2022-09-02 15:06:43 -0700
committerAdam Soltys <[email protected]>2022-09-02 15:06:43 -0700
commitd1cc66d1a02b75f90fbf0c05910777c76228259a (patch)
tree7b93dc6a2fc0ec9d03676d6b4093fedf9733f128 /routes/bitcoin/send.js
parent3161dd7ee95b6c7d70f8341298dd4fab84cda8b0 (diff)
downloadcoinos-server-d1cc66d1a02b75f90fbf0c05910777c76228259a.tar.gz
coinos-server-d1cc66d1a02b75f90fbf0c05910777c76228259a.zip
es6 migration
Diffstat (limited to 'routes/bitcoin/send.js')
-rw-r--r--routes/bitcoin/send.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js
index d8406075..6b991519 100644
--- a/routes/bitcoin/send.js
+++ b/routes/bitcoin/send.js
@@ -1,3 +1,5 @@
+import { rates } from "../../lib/store.js";
+import { addresses } from "../../lib/store.js";
import config from "../../config/index.js";
const btc = config.liquid.btcasset;
import {
@@ -74,10 +76,10 @@ export default async (req, res) => {
}
if (total > account.balance) {
- l.error("amount exceeds balance", amount, fee, account.balance);
+ err("amount exceeds balance", amount, fee, account.balance);
throw new Error("low balance");
} else if (total + conversionFee > account.balance) {
- l.error(
+ err(
"total (after conversion fee) exceeds balance",
amount,
fee,
@@ -121,7 +123,7 @@ export default async (req, res) => {
memo: "Bitcoin conversion fee",
account_id: receiverAccount.id,
user_id: receiverAccount.user_id,
- rate: app.get("rates")[receiverAccount.user.currency],
+ rate: rates[receiverAccount.user.currency],
currency: receiverAccount.user.currency,
confirmed: true,
received: true,
@@ -139,7 +141,7 @@ export default async (req, res) => {
memo,
account_id: account.id,
user_id: user.id,
- rate: app.get("rates")[user.currency],
+ rate: rates[user.currency],
currency: user.currency,
address,
confirmed: true,
@@ -164,13 +166,13 @@ export default async (req, res) => {
res.send(payment);
payments.push(params.hash);
- l.info("sent bitcoin", user.username, total);
+ l("sent bitcoin", user.username, total);
});
} catch (e) {
if (e.message.includes("Insufficient"))
e.message =
"The coinos server hot wallet has insufficient funds to complete the payment, try again later";
- l.error("error sending bitcoin", e.message);
+ err("error sending bitcoin", e.message);
console.log(e);
return res.status(500).send(e.message);
}