aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--routes/bitcoin/receive.js11
-rw-r--r--routes/bitcoin/send.js3
2 files changed, 3 insertions, 11 deletions
diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js
index e74f9394..5d8e21e7 100644
--- a/routes/bitcoin/receive.js
+++ b/routes/bitcoin/receive.js
@@ -68,15 +68,6 @@ zmqRawTx.on("message", async (topic, message, sequence) => {
if (!invoice) return;
- let payment = await db.Payment.findOne({
- where: {
- invoice_id: invoice.id
- },
- order: [["id", "DESC"]],
- });
-
- if (payment) return;
-
const currency = invoice ? invoice.currency : user.currency;
const rate = invoice ? invoice.rate : app.get("rates")[user.currency];
const tip = invoice ? invoice.tip : 0;
@@ -113,7 +104,7 @@ zmqRawTx.on("message", async (topic, message, sequence) => {
}
let fee = totalInputs - totalOutputs;
- payment = await db.Payment.create({
+ let payment = await db.Payment.create({
account_id: account.id,
user_id: user.id,
hash,
diff --git a/routes/bitcoin/send.js b/routes/bitcoin/send.js
index fe2b2862..9d64bb59 100644
--- a/routes/bitcoin/send.js
+++ b/routes/bitcoin/send.js
@@ -54,7 +54,7 @@ module.exports = ah(async (req, res) => {
if (total > account.balance) {
l.error("amount exceeds balance", amount, fee, account.balance);
- throw new Error("Insufficient funds");
+ throw new Error("low balance");
}
await account.decrement({ balance: total }, { transaction });
@@ -92,6 +92,7 @@ module.exports = ah(async (req, res) => {
payments.push(params.hash);
l.info("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);
return res.status(500).send(e.message);
}