From 58e7f32f48c2fb094196f44f4c59a8975e5f93a9 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Mon, 2 Mar 2026 12:01:53 -0800 Subject: delay startup routines --- index.ts | 2 ++ lib/ark.ts | 10 ++++++---- lib/payments.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/index.ts b/index.ts index bbb6aae7..9e41e240 100644 --- a/index.ts +++ b/index.ts @@ -260,6 +260,8 @@ Bun.serve({ hostname: host_, }); +console.log(`coinos server listening on ${host_}:${port}`); + const logerr = (e: Error) => console.log(e); process.on("unhandledRejection", logerr); process.on("uncaughtException", logerr); diff --git a/lib/ark.ts b/lib/ark.ts index e3de6c86..9736b419 100644 --- a/lib/ark.ts +++ b/lib/ark.ts @@ -89,7 +89,7 @@ export const refreshArkWallet = async (force = false) => { for (const utxo of sorted) { try { const txid = await withTimeout( - ramps.onboard(info.fees, [utxo], undefined, () => {}), + ramps.onboard(info.fees, [utxo], undefined, (event) => l("ark onboard event:", JSON.stringify(event, (_, v) => typeof v === "bigint" ? v.toString() : v))), 60_000, "ark onboard", ); @@ -97,7 +97,8 @@ export const refreshArkWallet = async (force = false) => { failedBoardingOutpoints.clear(); break; } catch (e: any) { - failedBoardingOutpoints.add(outpointKey(utxo)); + if (!/not enough intent confirmations/i.test(e.message)) + failedBoardingOutpoints.add(outpointKey(utxo)); warn("ark onboard failed:", utxo.value, "sats:", e.message); } } @@ -109,8 +110,9 @@ export const refreshArkWallet = async (force = false) => { } }; -// Initial check after 30s startup delay; ongoing checks triggered by ZMQ blocks -setTimeout(refreshArkWallet, 30_000); +// Initial check after 60s startup delay; retry every 60s to catch ark rounds +setTimeout(refreshArkWallet, 60_000); +setInterval(() => refreshArkWallet(), 60_000); // Log ark wallet balances every 60s setInterval(async () => { diff --git a/lib/payments.ts b/lib/payments.ts index 66f536bc..dbebfa39 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -1451,4 +1451,4 @@ const freezeCheck = async () => { setTimeout(freezeCheck, 10000); }; -freezeCheck(); +setTimeout(freezeCheck, 10_000); -- cgit v1.2.3