aboutsummaryrefslogtreecommitdiffstats
path: root/routes/bitcoin
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2021-12-16 22:05:36 -0500
committerAdam Soltys <[email protected]>2021-12-16 22:05:43 -0500
commit667302c91ceb1c1477782a6262d8d618ccd133e6 (patch)
treec51f0f21b2ea3c3cf51fe56b9890514cfbf3a543 /routes/bitcoin
parent14d870dec052c4ae279933983d56ab6a0149bc1e (diff)
downloadcoinos-server-667302c91ceb1c1477782a6262d8d618ccd133e6.tar.gz
coinos-server-667302c91ceb1c1477782a6262d8d618ccd133e6.zip
check for payment existence
Diffstat (limited to 'routes/bitcoin')
-rw-r--r--routes/bitcoin/receive.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/routes/bitcoin/receive.js b/routes/bitcoin/receive.js
index 5d8e21e7..e74f9394 100644
--- a/routes/bitcoin/receive.js
+++ b/routes/bitcoin/receive.js
@@ -68,6 +68,15 @@ 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;
@@ -104,7 +113,7 @@ zmqRawTx.on("message", async (topic, message, sequence) => {
}
let fee = totalInputs - totalOutputs;
- let payment = await db.Payment.create({
+ payment = await db.Payment.create({
account_id: account.id,
user_id: user.id,
hash,