From 5576f07a5a29bc8f2cb0695f5e12b4603b2771f9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 25 Mar 2022 23:47:57 -0400 Subject: wait for 2 confs before reporting unconfirmed txns --- lib/sync.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/sync.js b/lib/sync.js index dda83eab..10e857b3 100644 --- a/lib/sync.js +++ b/lib/sync.js @@ -173,12 +173,13 @@ const sync = async () => { missed = transactions.filter( tx => tx.category === "receive" && - tx.confirmations > 0 && + tx.confirmations > 2 && hashes.includes(tx.txid) ); for (let i = 0; i < missed.length; i++) { let p = unconfirmed.find(p => p.hash === missed[i].txid); + /* p.confirmed = 1; await db.transaction(async transaction => { @@ -190,8 +191,9 @@ const sync = async () => { emit(p.user.username, "account", p.account); emit(p.user.username, "payment", p); + */ - l.info("confirmed tx", p.user_id, p.hash, p.address); + l.info("unconfirmed tx", p.user_id, p.hash, p.address); } unaccounted = []; @@ -286,10 +288,11 @@ const sync = async () => { } catch (e) { l.error("sync check failed", e.message, e.stack); } + + setTimeout(sync, 300000); }; setTimeout(sync, 5000); -setInterval(sync, 300000); app.get( "/conversions", -- cgit v1.2.3