From af568c46cb3da198ea8614d21616bac3951f3262 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sun, 22 Mar 2026 15:41:08 +0000 Subject: verify ark amounts --- lib/ark.ts | 5 +++-- lib/payments.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/ark.ts b/lib/ark.ts index 3c2a3087..a37197e8 100644 --- a/lib/ark.ts +++ b/lib/ark.ts @@ -230,7 +230,7 @@ let cachedArkBalance: any = null; export const getArkBalance = () => cachedArkBalance; -export const verifyArkVtxo = async (hash: string) => { +export const verifyArkVtxo = async (hash: string): Promise<{ found: boolean; amount: number }> => { const { bech32m } = await import("@scure/base"); const serverAddr = await getArkAddress(); const decoded = bech32m.decode(serverAddr, 1023); @@ -240,5 +240,6 @@ export const verifyArkVtxo = async (hash: string) => { `${config.ark.arkServerUrl}/v1/indexer/vtxos?scripts=5120${vtxoHex}&spendable_only=true`, ); const { vtxos } = await r.json() as any; - return vtxos?.some((v: any) => v.outpoint?.txid === hash) ?? false; + const vtxo = vtxos?.find((v: any) => v.outpoint?.txid === hash); + return { found: !!vtxo, amount: vtxo?.amount ?? 0 }; }; diff --git a/lib/payments.ts b/lib/payments.ts index 78f20684..b82ea767 100644 --- a/lib/payments.ts +++ b/lib/payments.ts @@ -88,7 +88,7 @@ export const getUserRate = async (user) => { }; export const acquireArkLock = async (hash) => { - const locked = await db.set(`arklock:${hash}`, "1", { NX: true, EX: 60 }); + const locked = await db.set(`arklock:${hash}`, "1", { NX: true }); if (!locked) fail("Already processed"); }; -- cgit v1.2.3