Skip to content

Commit

Permalink
Merge pull request #1513 from stackernews/fix-hide-invoice-desc
Browse files Browse the repository at this point in the history
Fix description of wrapped invoices don't respect privacy setting
  • Loading branch information
huumn authored Nov 2, 2024
2 parents 0039efc + 383272f commit c685895
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion api/paidAction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion wallets/wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit c685895

Please sign in to comment.