feat: HodlInvoices (Rebase) (#2869)

Co-authored-by: pseudozach <git@pseudozach.com>
Co-authored-by: dni  <office@dnilabs.com>
Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
ziggieXXX
2025-07-15 11:15:14 +02:00
committed by dni ⚡
co-authored by pseudozach dni ⚡ Vlad Stan
parent 6e9f451419
commit f91c933919
23 changed files with 4192 additions and 6027 deletions
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+10
View File
@@ -176,7 +176,17 @@ window.localisation.en = {
extension_required_lnbits_version: 'This release requires LNbits version',
min_version: 'Minimum (included)',
max_version: 'Maximum (excluded)',
preimage: 'Preimage',
preimage_hint: 'Preimage to settle the hold invoice',
hold_invoice: 'Hold Invoice',
hold_invoice_description:
'This invoice is on hold and requires a preimage to settle.',
payment_hash: 'Payment Hash',
invoice_cancelled: 'Invoice Cancelled',
invoice_settled: 'Invoice Settled',
hold_invoice_payment_hash: 'Payment hash for hold invoice (optional)',
settle_invoice: 'Settle Invoice',
cancel_invoice: 'Cancel Invoice',
fee: 'Fee',
amount: 'Amount',
amount_limits: 'Amount Limits',
+14 -2
View File
@@ -21,7 +21,8 @@ window.LNbits = {
unit = 'sat',
lnurlCallback = null,
fiatProvider = null,
internalMemo = null
internalMemo = null,
payment_hash = null
) {
const data = {
out: false,
@@ -29,7 +30,8 @@ window.LNbits = {
memo: memo,
unit: unit,
lnurl_callback: lnurlCallback,
fiat_provider: fiatProvider
fiat_provider: fiatProvider,
payment_hash: payment_hash
}
if (internalMemo) {
data.extra = {
@@ -80,6 +82,16 @@ window.LNbits = {
data
)
},
cancelInvoice(wallet, paymentHash) {
return this.request('post', '/api/v1/payments/cancel', wallet.adminkey, {
payment_hash: paymentHash
})
},
settleInvoice(wallet, preimage) {
return this.request('post', `/api/v1/payments/settle`, wallet.adminkey, {
preimage: preimage
})
},
authLnurl(wallet, callback) {
return this.request('post', '/api/v1/lnurlauth', wallet.adminkey, {
callback
@@ -118,7 +118,13 @@ window.app.component('payment-list', {
field: row => row.extra.wallet_fiat_amount
}
],
preimage: null,
loading: false
},
hodlInvoice: {
show: false,
payment: null,
preimage: null
}
}
},
@@ -223,6 +229,35 @@ window.app.component('payment-list', {
})
.catch(LNbits.utils.notifyApiError)
},
showHoldInvoiceDialog(payment) {
this.hodlInvoice.show = true
this.hodlInvoice.preimage = ''
this.hodlInvoice.payment = payment
},
cancelHoldInvoice(payment_hash) {
LNbits.api
.cancelInvoice(this.g.wallet, payment_hash)
.then(() => {
this.update = !this.update
Quasar.Notify.create({
type: 'positive',
message: this.$t('invoice_cancelled')
})
})
.catch(LNbits.utils.notifyApiError)
},
settleHoldInvoice(preimage) {
LNbits.api
.settleInvoice(this.g.wallet, preimage)
.then(() => {
this.update = !this.update
Quasar.Notify.create({
type: 'positive',
message: this.$t('invoice_settled')
})
})
.catch(LNbits.utils.notifyApiError)
},
paymentTableRowKey(row) {
return row.payment_hash + row.amount
},
+5 -2
View File
@@ -40,7 +40,8 @@ window.WalletPageLogic = {
data: {
amount: null,
memo: '',
internalMemo: null
internalMemo: null,
payment_hash: null
}
},
invoiceQrCode: '',
@@ -200,6 +201,7 @@ window.WalletPageLogic = {
this.receive.data.amount = null
this.receive.data.memo = null
this.receive.data.internalMemo = null
this.receive.data.payment_hash = null
this.receive.unit = this.isFiatPriority
? this.g.wallet.currency || 'sat'
: 'sat'
@@ -258,7 +260,8 @@ window.WalletPageLogic = {
this.receive.unit,
this.receive.lnurl && this.receive.lnurl.callback,
this.receive.fiatProvider,
this.receive.data.internalMemo
this.receive.data.internalMemo,
this.receive.data.payment_hash
)
.then(response => {
this.g.updatePayments = !this.g.updatePayments