Skip to content

Commit

Permalink
Don't return intermediate failed invoices
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Jan 4, 2025
1 parent 7e0082e commit 240f3c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions api/resolvers/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { formatMsats, msatsToSats, msatsToSatsDecimal, satsToMsats } from '@/lib
import {
USER_ID, INVOICE_RETENTION_DAYS,
PAID_ACTION_PAYMENT_METHODS,
WALLET_CREATE_INVOICE_TIMEOUT_MS
WALLET_CREATE_INVOICE_TIMEOUT_MS,
WALLET_RETRY_BACKOFF_MS
} from '@/lib/constants'
import { amountSchema, validateSchema, withdrawlSchema, lnAddrSchema } from '@/lib/validate'
import assertGofacYourself from './ofac'
Expand Down Expand Up @@ -470,7 +471,7 @@ const resolvers = {
SELECT id FROM "Invoice"
WHERE "userId" = ${me.id}
AND "actionState" = 'FAILED'
AND "userCancel" = false
AND "cancelledAt" < now() - interval '${WALLET_RETRY_BACKOFF_MS} milliseconds'
AND "lockedAt" IS NULL
ORDER BY id DESC
FOR UPDATE SKIP LOCKED
Expand Down
4 changes: 4 additions & 0 deletions lib/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,7 @@ export const ZAP_UNDO_DELAY_MS = 5_000

export const WALLET_SEND_PAYMENT_TIMEOUT_MS = 150_000
export const WALLET_CREATE_INVOICE_TIMEOUT_MS = 45_000
// When should failed invoices be returned to a client to retry?
// 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_BACKOFF_MS = 60_000

0 comments on commit 240f3c0

Please sign in to comment.