Merge pull request #1513 from stackernews/fix-hide-invoice-desc

Fix description of wrapped invoices don't respect privacy setting
This commit is contained in:
Keyan 2024-11-01 20:09:31 -05:00 committed by GitHub
commit c68589597d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 2 deletions

View File

@ -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,

View File

@ -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')