From 383272f1c2456dd9f34d7fd2bbeae255f9ad485e Mon Sep 17 00:00:00 2001 From: ekzyis Date: Thu, 24 Oct 2024 21:47:29 +0200 Subject: [PATCH] Fix description of wrapped invoices don't respect privacy setting --- api/paidAction/index.js | 4 +++- wallets/wrap.js | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/paidAction/index.js b/api/paidAction/index.js index 424198be4..fcbfb4e31 100644 --- a/api/paidAction/index.js +++ b/api/paidAction/index.js @@ -258,8 +258,10 @@ export async function createLightningInvoice (actionType, args, context) { expiry: INVOICE_EXPIRE_SECS }, { models }) + // the sender (me) decides if the wrapped invoice has a description + // whereas the recipient decides if their invoice has a description const { invoice: wrappedInvoice, maxFee } = await wrapInvoice( - bolt11, { msats: cost, description }, { lnd }) + bolt11, { msats: cost, description }, { me, lnd }) return { bolt11, diff --git a/wallets/wrap.js b/wallets/wrap.js index ae63a6ed8..b470587b9 100644 --- a/wallets/wrap.js +++ b/wallets/wrap.js @@ -22,7 +22,7 @@ const ZAP_SYBIL_FEE_MULT = 10 / 7 // the fee for the zap sybil service maxFee: number } */ -export default async function wrapInvoice (bolt11, { msats, description, descriptionHash }, { lnd }) { +export default async function wrapInvoice (bolt11, { msats, description, descriptionHash }, { me, lnd }) { try { console.group('wrapInvoice', description) @@ -112,6 +112,11 @@ export default async function wrapInvoice (bolt11, { msats, description, descrip wrapped.description = inv.description } + if (me?.hideInvoiceDesc) { + wrapped.description = undefined + wrapped.description_hash = undefined + } + // validate the expiration if (new Date(inv.expires_at) < new Date(Date.now() + INCOMING_EXPIRATION_BUFFER_MSECS)) { throw new Error('Invoice expiration is too soon')