feat: Allow custom memo on pay invoice (#3236)

Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
Tiago Vasconcelos
2025-07-15 11:14:15 +02:00
committed by dni ⚡
co-authored by Vlad Stan
parent 9aa2194d94
commit 88cf1ac853
9 changed files with 204 additions and 58 deletions
+2 -2
View File
File diff suppressed because one or more lines are too long
+5
View File
@@ -101,6 +101,11 @@ window.localisation.en = {
memo: 'Memo',
date: 'Date',
path: 'Path',
internal_memo: 'Internal memo (optional)',
internal_memo_hint_receive:
"This memo is not shown to the payer but it's stored in the invoice for your reference.",
internal_memo_hint_pay:
"This memo is not shown to the payee but it's stored in the payment for your reference.",
payment_processing: 'Processing payment...',
payment_processing: 'Processing payment...',
payment_successful: 'Payment successful!',
+35 -10
View File
@@ -20,22 +20,35 @@ window.LNbits = {
memo,
unit = 'sat',
lnurlCallback = null,
fiatProvider = null
fiatProvider = null,
internalMemo = null
) {
return this.request('post', '/api/v1/payments', wallet.inkey, {
const data = {
out: false,
amount: amount,
memo: memo,
lnurl_callback: lnurlCallback,
unit: unit,
lnurl_callback: lnurlCallback,
fiat_provider: fiatProvider
})
}
if (internalMemo) {
data.extra = {
internal_memo: String(internalMemo)
}
}
return this.request('post', '/api/v1/payments', wallet.inkey, data)
},
payInvoice(wallet, bolt11) {
return this.request('post', '/api/v1/payments', wallet.adminkey, {
payInvoice(wallet, bolt11, internalMemo = null) {
const data = {
out: true,
bolt11: bolt11
})
}
if (internalMemo) {
data.extra = {
internal_memo: String(internalMemo)
}
}
return this.request('post', '/api/v1/payments', wallet.adminkey, data)
},
payLnurl(
wallet,
@@ -44,16 +57,28 @@ window.LNbits = {
amount,
description = '',
comment = '',
unit = ''
unit = '',
internalMemo = null
) {
return this.request('post', '/api/v1/payments/lnurl', wallet.adminkey, {
const data = {
callback,
description_hash,
amount,
comment,
description,
unit
})
}
if (internalMemo) {
data.internal_memo = String(internalMemo)
}
return this.request(
'post',
'/api/v1/payments/lnurl',
wallet.adminkey,
data
)
},
authLnurl(wallet, callback) {
return this.request('post', '/api/v1/lnurlauth', wallet.adminkey, {
+13 -1
View File
@@ -8,7 +8,8 @@ window.PaymentsPageLogic = {
searchData: {
wallet_id: null,
payment_hash: null,
memo: null
memo: null,
internal_memo: null
},
statusFilters: {
success: true,
@@ -82,6 +83,14 @@ window.PaymentsPageLogic = {
sortable: false,
max_length: 20
},
{
name: 'internal_memo',
align: 'left',
label: 'Internal Memo',
field: 'internal_memo',
sortable: false,
max_length: 20
},
{
name: 'wallet_id',
align: 'left',
@@ -166,6 +175,9 @@ window.PaymentsPageLogic = {
p.extra.wallet_fiat_currency
)
}
if (p.extra?.internal_memo) {
p.internal_memo = p.extra.internal_memo
}
p.fee_sats =
new Intl.NumberFormat(window.LOCALE).format(p.fee / 1000) + ' sats'
+14 -4
View File
@@ -14,6 +14,7 @@ window.WalletPageLogic = {
request: '',
amount: 0,
comment: '',
internalMemo: null,
unit: 'sat'
},
paymentChecker: null,
@@ -38,7 +39,8 @@ window.WalletPageLogic = {
fiatProvider: '',
data: {
amount: null,
memo: ''
memo: '',
internalMemo: null
}
},
invoiceQrCode: '',
@@ -197,6 +199,7 @@ window.WalletPageLogic = {
this.receive.paymentHash = null
this.receive.data.amount = null
this.receive.data.memo = null
this.receive.data.internalMemo = null
this.receive.unit = this.isFiatPriority
? this.g.wallet.currency || 'sat'
: 'sat'
@@ -218,6 +221,7 @@ window.WalletPageLogic = {
window.isSecureContext && navigator.clipboard?.readText !== undefined
this.parse.data.request = ''
this.parse.data.comment = ''
this.parse.data.internalMemo = null
this.parse.data.paymentChecker = null
this.parse.camera.show = false
this.focusInput('textArea')
@@ -253,7 +257,8 @@ window.WalletPageLogic = {
this.receive.data.memo,
this.receive.unit,
this.receive.lnurl && this.receive.lnurl.callback,
this.receive.fiatProvider
this.receive.fiatProvider,
this.receive.data.internalMemo
)
.then(response => {
this.g.updatePayments = !this.g.updatePayments
@@ -477,7 +482,11 @@ window.WalletPageLogic = {
})
LNbits.api
.payInvoice(this.g.wallet, this.parse.data.request)
.payInvoice(
this.g.wallet,
this.parse.data.request,
this.parse.data.internalMemo
)
.then(response => {
dismissPaymentMsg()
this.updatePayments = !this.updatePayments
@@ -515,7 +524,8 @@ window.WalletPageLogic = {
this.parse.data.amount * 1000,
this.parse.lnurlpay.description.slice(0, 120),
this.parse.data.comment,
this.parse.data.unit
this.parse.data.unit,
this.parse.data.internalMemo
)
.then(response => {
this.parse.show = false