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:
commit
c68589597d
|
@ -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,
|
||||
|
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue