feat: add negative topups (#2835)
* feat: add negative topups * remove topup dialog --------- Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -28,17 +28,17 @@ window.localisation.en = {
|
||||
restart: 'Restart server',
|
||||
save: 'Save',
|
||||
save_tooltip: 'Save your changes',
|
||||
topup: 'Topup',
|
||||
topup_wallet: 'Topup a wallet',
|
||||
topup_hint: 'Use the wallet ID to topup any wallet',
|
||||
credit_debit: 'Credit / Debit',
|
||||
credit_hint: 'Press Enter to credit/debit wallet (negative values allowed)',
|
||||
credit_label: '{denomination} to credit/debit',
|
||||
credit_ok:
|
||||
'Success crediting/debiting virtual funds ({amount} sats). Payments depend on actual funds on funding source.',
|
||||
restart_tooltip: 'Restart the server for changes to take effect',
|
||||
add_funds_tooltip: 'Add funds to a wallet.',
|
||||
reset_defaults: 'Reset to defaults',
|
||||
reset_defaults_tooltip: 'Delete all settings and reset to defaults.',
|
||||
download_backup: 'Download database backup',
|
||||
name_your_wallet: 'Name your {name} wallet',
|
||||
wallet_topup_ok:
|
||||
'Success creating virtual funds ({amount} sats). Payments depend on actual funds on funding source.',
|
||||
paste_invoice_label: 'Paste an invoice, payment request or lnurl code *',
|
||||
lnbits_description:
|
||||
'Easy to set up and lightweight, LNbits can run on any Lightning Network funding source and even LNbits itself! You can run LNbits for yourself, or easily offer a custodian solution for others. Each wallet has its own API keys and there is no limit to the number of wallets you can make. Being able to partition funds makes LNbits a useful tool for money management and as a development tool. Extensions add extra functionality to LNbits so you can experiment with a range of cutting-edge technologies on the lightning network. We have made developing extensions as easy as possible, and as a free and open-source project, we encourage people to develop and submit their own.',
|
||||
@@ -71,8 +71,6 @@ window.localisation.en = {
|
||||
api_keys_api_docs: 'Node URL, API keys and API docs',
|
||||
lnbits_version: 'LNbits version',
|
||||
runs_on: 'Runs on',
|
||||
credit_hint: 'Press Enter to credit account',
|
||||
credit_label: '{denomination} to credit',
|
||||
paste: 'Paste',
|
||||
paste_from_clipboard: 'Paste from clipboard',
|
||||
paste_request: 'Paste Request',
|
||||
|
||||
@@ -167,7 +167,7 @@ window.LNbits = {
|
||||
)
|
||||
},
|
||||
updateBalance(credit, wallet_id) {
|
||||
return this.request('PUT', '/users/api/v1/topup', null, {
|
||||
return this.request('PUT', '/users/api/v1/balance', null, {
|
||||
amount: credit,
|
||||
id: wallet_id
|
||||
})
|
||||
|
||||
@@ -484,7 +484,7 @@ window.app.component('lnbits-dynamic-chips', {
|
||||
window.app.component('lnbits-update-balance', {
|
||||
template: '#lnbits-update-balance',
|
||||
mixins: [window.windowMixin],
|
||||
props: ['wallet_id'],
|
||||
props: ['wallet_id', 'credit-value'],
|
||||
computed: {
|
||||
denomination() {
|
||||
return LNBITS_DENOMINATION
|
||||
@@ -514,11 +514,12 @@ window.app.component('lnbits-update-balance', {
|
||||
credit = parseInt(credit)
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
message: this.$t('wallet_topup_ok', {
|
||||
message: this.$t('credit_ok', {
|
||||
amount: credit
|
||||
}),
|
||||
icon: null
|
||||
})
|
||||
this.$emit('credit-value', credit)
|
||||
return credit
|
||||
})
|
||||
.catch(LNbits.utils.notifyApiError)
|
||||
|
||||
@@ -4,7 +4,6 @@ window.app = Vue.createApp({
|
||||
data() {
|
||||
return {
|
||||
paymentsWallet: {},
|
||||
wallet: {},
|
||||
cancel: {},
|
||||
users: [],
|
||||
wallets: [],
|
||||
@@ -21,9 +20,6 @@ window.app = Vue.createApp({
|
||||
userId: null,
|
||||
show: false
|
||||
},
|
||||
topupDialog: {
|
||||
show: false
|
||||
},
|
||||
activeUser: {
|
||||
data: null,
|
||||
showUserId: false,
|
||||
@@ -184,6 +180,9 @@ window.app = Vue.createApp({
|
||||
this.activeWallet.show = false
|
||||
this.fetchUsers()
|
||||
},
|
||||
handleBalanceUpdate() {
|
||||
this.fetchWallets(this.activeWallet.userId)
|
||||
},
|
||||
resetPassword(user_id) {
|
||||
return LNbits.api
|
||||
.request('PUT', `/users/api/v1/user/${user_id}/reset_password`)
|
||||
@@ -383,43 +382,10 @@ window.app = Vue.createApp({
|
||||
this.activeUser.show = false
|
||||
}
|
||||
},
|
||||
showTopupDialog(walletId) {
|
||||
this.wallet.id = walletId
|
||||
this.topupDialog.show = true
|
||||
},
|
||||
showPayments(wallet_id) {
|
||||
this.paymentsWallet = this.wallets.find(wallet => wallet.id === wallet_id)
|
||||
this.paymentPage.show = true
|
||||
},
|
||||
topupCallback(res) {
|
||||
if (res.success) {
|
||||
this.wallets.forEach(wallet => {
|
||||
if (res.wallet_id === wallet.id) {
|
||||
wallet.balance_msat += res.credit * 1000
|
||||
}
|
||||
})
|
||||
this.fetchUsers()
|
||||
}
|
||||
},
|
||||
topupWallet() {
|
||||
LNbits.api
|
||||
.request(
|
||||
'PUT',
|
||||
'/users/api/v1/topup',
|
||||
this.g.user.wallets[0].adminkey,
|
||||
this.wallet
|
||||
)
|
||||
.then(_ => {
|
||||
Quasar.Notify.create({
|
||||
type: 'positive',
|
||||
message: `Added ${this.wallet.amount} to ${this.wallet.id}`,
|
||||
icon: null
|
||||
})
|
||||
this.wallet = {}
|
||||
this.fetchWallets(this.activeWallet.userId)
|
||||
})
|
||||
.catch(LNbits.utils.notifyApiError)
|
||||
},
|
||||
searchUserBy(fieldName) {
|
||||
const fieldValue = this.searchData[fieldName]
|
||||
this.usersTable.filter = {}
|
||||
|
||||
@@ -51,7 +51,6 @@ window.app = Vue.createApp({
|
||||
balance: parseInt(wallet.balance_msat / 1000),
|
||||
fiatBalance: 0,
|
||||
mobileSimple: false,
|
||||
credit: 0,
|
||||
update: {
|
||||
name: null,
|
||||
currency: null
|
||||
@@ -151,6 +150,9 @@ window.app = Vue.createApp({
|
||||
this.receive.paymentHash = null
|
||||
}
|
||||
},
|
||||
handleBalanceUpdate(value) {
|
||||
this.balance = this.balance + value
|
||||
},
|
||||
createInvoice() {
|
||||
this.receive.status = 'loading'
|
||||
if (LNBITS_DENOMINATION != 'sats') {
|
||||
|
||||
Reference in New Issue
Block a user