Reset wallet keys (#2929)

This commit is contained in:
Tiago Vasconcelos
2025-02-06 15:07:36 +02:00
committed by GitHub
parent 34a959f0bc
commit 432b3a0fe0
7 changed files with 94 additions and 27 deletions
+1 -1
View File
File diff suppressed because one or more lines are too long
+4 -1
View File
@@ -505,5 +505,8 @@ window.localisation.en = {
payments_balance_chart: 'Balance Chart',
payments_wallets_chart: 'Wallets Chart',
payments_balance_in_out_chart: 'Balance In/Out Chart',
payments_count_in_out_chart: 'Count In/Out Chart'
payments_count_in_out_chart: 'Count In/Out Chart',
reset_wallet_keys: 'Reset Keys',
reset_wallet_keys_desc:
'Reset the API keys for this wallet. This will invalidate the current keys and generate new ones.'
}
+11 -6
View File
@@ -132,15 +132,20 @@ window.LNbits = {
name: name
})
},
deleteWallet(wallet) {
return this.request('delete', '/api/v1/wallet', wallet.adminkey).then(
_ => {
let url = new URL(window.location.href)
url.searchParams.delete('wal')
window.location = url
resetWalletKeys(wallet) {
return this.request('put', `/api/v1/wallet/reset/${wallet.id}`).then(
res => {
return res.data
}
)
},
deleteWallet(wallet) {
return this.request('delete', `/api/v1/wallet/${wallet.id}`).then(_ => {
let url = new URL(window.location.href)
url.searchParams.delete('wal')
window.location = url
})
},
getPayments(wallet, params) {
return this.request(
'get',
+34
View File
@@ -564,6 +564,40 @@ window.WalletPageLogic = {
}
})
},
resetKeys() {
LNbits.utils
.confirmDialog('Are you sure you want to reset your API keys?')
.onOk(() => {
LNbits.api
.resetWalletKeys(this.g.wallet)
.then(response => {
const {id, adminkey, inkey} = response
this.g.wallet = {
...this.g.wallet,
inkey,
adminkey
}
const walletIndex = this.g.user.wallets.findIndex(
wallet => wallet.id === id
)
if (walletIndex !== -1) {
this.g.user.wallets[walletIndex] = {
...this.g.user.wallets[walletIndex],
inkey,
adminkey
}
}
Quasar.Notify.create({
timeout: 3500,
type: 'positive',
message: 'API keys reset!'
})
})
.catch(err => {
LNbits.utils.notifyApiError(err)
})
})
},
updateWallet(data) {
LNbits.api
.request('PATCH', '/api/v1/wallet', this.g.wallet.adminkey, data)