Skip to content

Commit

Permalink
don't support direct payments to bolt12
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardobl committed Dec 17, 2024
1 parent e803efe commit 332d1e1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions api/paidAction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,16 @@ async function performDirectAction (actionType, args, incomingContext) {
invoiceObject = await createUserInvoice(userId, {
msats: cost,
description,
expiry: INVOICE_EXPIRE_SECS
expiry: INVOICE_EXPIRE_SECS,
supportBolt12: false // direct payment is not supported to bolt12 for compatibility reasons
}, { models, lnd })
} catch (e) {
console.error('failed to create outside invoice', e)
throw new NonInvoiceablePeerError()
}

const { invoice, wallet } = invoiceObject
const hash = await parseBolt11({ request: invoice }).id // direct payments are always to bolt11 invoices
const hash = await parseBolt11({ request: invoice }).id

const payment = await models.directPayment.create({
data: {
Expand Down
3 changes: 2 additions & 1 deletion wallets/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function checkInvoice (invoice, { msats }, { lnd, logger }) {
}
}

export async function createInvoice (userId, { msats, description, descriptionHash, expiry = 360 }, { predecessorId, models, lnd }) {
export async function createInvoice (userId, { msats, description, descriptionHash, expiry = 360, supportBolt12 = true }, { predecessorId, models, lnd }) {
// get the wallets in order of priority
const wallets = await getInvoiceableWallets(userId, { predecessorId, models })

Expand All @@ -74,6 +74,7 @@ export async function createInvoice (userId, { msats, description, descriptionHa
}

if (!isBolt12Offer(invoice)) {
if (!supportBolt12) continue
checkInvoice(invoice, { msats }, { lnd, logger })
}

Expand Down

0 comments on commit 332d1e1

Please sign in to comment.