remove old topup route using new one, change wallet.js handling of that url

This commit is contained in:
dni ⚡ 2022-12-13 10:17:40 +01:00
parent 1859ff5e36
commit 02946c1d1c
2 changed files with 24 additions and 44 deletions

View File

@ -259,26 +259,31 @@ new Vue({
this.parse.camera.show = false
},
updateBalance: function (credit) {
if (LNBITS_DENOMINATION != 'sats') {
credit = credit * 100
}
LNbits.api
.request('PUT', '/api/v1/wallet/balance/' + credit, this.g.wallet.inkey)
.catch(err => {
LNbits.utils.notifyApiError(err)
})
.then(response => {
let data = response.data
if (data.status === 'ERROR') {
LNbits.api
.request(
'PUT',
'/admin/api/v1/topup/?usr=' + this.g.user.id,
this.g.user.wallets[0].adminkey,
{
amount: credit,
id: this.g.user.wallets[0].id
}
)
.then(response => {
this.$q.notify({
timeout: 5000,
type: 'warning',
message: `Failed to update.`
})
return
}
this.balance = this.balance + data.balance
})
type: 'positive',
message:
'Success! Added ' +
credit +
' sats to ' +
this.g.user.wallets[0].id,
icon: null
});
this.balance += parseInt(credit);
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
});
},
closeReceiveDialog: function () {
setTimeout(() => {

View File

@ -83,31 +83,6 @@ async def api_wallet(wallet: WalletTypeInfo = Depends(get_key_type)):
return {"name": wallet.wallet.name, "balance": wallet.wallet.balance_msat}
@core_app.put("/api/v1/wallet/balance/{amount}", dependencies=[Depends(check_admin)])
async def api_update_balance(
amount: int, wallet: WalletTypeInfo = Depends(get_key_type)
):
payHash = urlsafe_short_hash()
await create_payment(
wallet_id=wallet.wallet.id,
checking_id=payHash,
payment_request="selfPay",
payment_hash=payHash,
amount=amount * 1000,
memo="selfPay",
fee=0,
)
await update_payment_status(checking_id=payHash, pending=False)
updatedWallet = await get_wallet(wallet.wallet.id)
return {
"id": wallet.wallet.id,
"name": wallet.wallet.name,
"balance": amount,
}
@core_app.put("/api/v1/wallet/{new_name}")
async def api_update_wallet(
new_name: str, wallet: WalletTypeInfo = Depends(require_admin_key)