improve autowithdraw recent failure check

This commit is contained in:
k00b 2024-08-18 14:06:17 -05:00
parent 11ddbe3983
commit 9932a782b2
1 changed files with 5 additions and 7 deletions

View File

@ -27,13 +27,11 @@ export async function autoWithdraw ({ data: { id }, models, lnd }) {
SELECT EXISTS(
SELECT *
FROM "Withdrawl"
WHERE "userId" = ${id} AND "autoWithdraw"
AND (status IS NULL
OR (
status <> 'CONFIRMED' AND
now() < created_at + interval '1 hour' AND
"msatsFeePaying" >= ${maxFeeMsats}
))
WHERE "userId" = ${id}
AND "autoWithdraw"
AND status IS DISTINCT FROM 'CONFIRMED'
AND now() < created_at + interval '1 hour'
AND "msatsFeePaying" >= ${maxFeeMsats}
)`
if (pendingOrFailed.exists) return