diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index c8cf4d903..60f27e84d 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -10,7 +10,8 @@ import { USER_ID, INVOICE_RETENTION_DAYS, PAID_ACTION_PAYMENT_METHODS, WALLET_CREATE_INVOICE_TIMEOUT_MS, - WALLET_RETRY_AFTER_MS + WALLET_RETRY_AFTER_MS, + WALLET_RETRY_BEFORE_MS } from '@/lib/constants' import { amountSchema, validateSchema, withdrawlSchema, lnAddrSchema } from '@/lib/validate' import assertGofacYourself from './ofac' @@ -471,7 +472,10 @@ const resolvers = { SELECT id FROM "Invoice" WHERE "userId" = ${me.id} AND "actionState" = 'FAILED' - AND "cancelledAt" < now() - interval '${WALLET_RETRY_AFTER_MS} milliseconds' + AND now()::timestamp <@ tsrange( + "cancelledAt" + interval '${WALLET_RETRY_AFTER_MS} milliseconds', + "cancelledAt" + interval '${WALLET_RETRY_BEFORE_MS} milliseconds' + ) AND "lockedAt" IS NULL ORDER BY id DESC FOR UPDATE SKIP LOCKED diff --git a/lib/constants.js b/lib/constants.js index 204f355ba..dc78107ce 100644 --- a/lib/constants.js +++ b/lib/constants.js @@ -198,3 +198,4 @@ export const WALLET_CREATE_INVOICE_TIMEOUT_MS = 45_000 // This must be high enough such that intermediate failed invoices that will be retried // by the client due to sender or receiver fallbacks are not returned to the client. export const WALLET_RETRY_AFTER_MS = 60_000 +export const WALLET_RETRY_BEFORE_MS = 86_400_000 // 24 hours