Skip to content

Commit

Permalink
Fix fallbacks during last retry
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Jan 8, 2025
1 parent 09cb758 commit e752aae
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 1 addition & 3 deletions api/paidAction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,7 @@ export async function retryPaidAction (actionType, args, incomingContext) {
me: await models.user.findUnique({ where: { id: parseInt(me.id) } }),
cost: BigInt(msatsRequested),
actionId,
predecessorId: failedInvoice.id,
// a locked invoice means we're retrying a payment from the beginning with all sender and receiver wallets
retry: failedInvoice.lockedAt ? failedInvoice.retry + 1 : failedInvoice.retry
predecessorId: failedInvoice.id
}

let invoiceArgs
Expand Down
7 changes: 5 additions & 2 deletions api/resolvers/paidAction.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,14 @@ export default {
throw new Error(`Invoice is not in failed state: ${invoice.actionState}`)
}

if (invoice.retry >= WALLET_MAX_RETRIES) {
// a locked invoice means we want to retry a payment from the beginning
// with all sender and receiver wallets so we need to increment the retry count
const retry = invoice.lockedAt ? invoice.retry + 1 : invoice.retry
if (retry > WALLET_MAX_RETRIES) {
throw new Error('Payment has been retried too many times')
}

const result = await retryPaidAction(invoice.actionType, { invoice }, { models, me, lnd })
const result = await retryPaidAction(invoice.actionType, { invoice }, { retry, models, me, lnd })

return {
...result,
Expand Down

0 comments on commit e752aae

Please sign in to comment.