Skip to content

Commit

Permalink
catch wrap invoice error as noninvoiceable
Browse files Browse the repository at this point in the history
  • Loading branch information
huumn committed Nov 20, 2024
1 parent 67a0565 commit 09bacdc
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions api/paidAction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,24 +198,30 @@ async function performP2PAction (actionType, args, incomingContext) {
throw new NonInvoiceablePeerError()
}

await assertBelowMaxPendingInvoices(incomingContext)
let context
try {
await assertBelowMaxPendingInvoices(incomingContext)

const description = await paidActions[actionType].describe(args, incomingContext)
const { invoice, wrappedInvoice, wallet, maxFee } = await createWrappedInvoice(userId, {
msats: cost,
feePercent: sybilFeePercent,
description,
expiry: INVOICE_EXPIRE_SECS
}, { models, me, lnd })
const description = await paidActions[actionType].describe(args, incomingContext)
const { invoice, wrappedInvoice, wallet, maxFee } = await createWrappedInvoice(userId, {
msats: cost,
feePercent: sybilFeePercent,
description,
expiry: INVOICE_EXPIRE_SECS
}, { models, me, lnd })

const context = {
...incomingContext,
invoiceArgs: {
bolt11: invoice,
wrappedBolt11: wrappedInvoice,
wallet,
maxFee
context = {
...incomingContext,
invoiceArgs: {
bolt11: invoice,
wrappedBolt11: wrappedInvoice,
wallet,
maxFee
}
}
} catch (e) {
console.error('failed to create wrapped invoice', e)
throw new NonInvoiceablePeerError()
}

return me
Expand Down

0 comments on commit 09bacdc

Please sign in to comment.