From 09bacdc0166ec9d37922a3d4c8d22fb1ae0c32db Mon Sep 17 00:00:00 2001 From: k00b Date: Wed, 20 Nov 2024 14:47:22 -0600 Subject: [PATCH] catch wrap invoice error as noninvoiceable --- api/paidAction/index.js | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/api/paidAction/index.js b/api/paidAction/index.js index 01fdb227..36f7c5ed 100644 --- a/api/paidAction/index.js +++ b/api/paidAction/index.js @@ -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