remove old topup route using new one, change wallet.js handling of that url
This commit is contained in:
parent
1859ff5e36
commit
02946c1d1c
2 changed files with 24 additions and 44 deletions
|
|
@ -259,26 +259,31 @@ new Vue({
|
||||||
this.parse.camera.show = false
|
this.parse.camera.show = false
|
||||||
},
|
},
|
||||||
updateBalance: function (credit) {
|
updateBalance: function (credit) {
|
||||||
if (LNBITS_DENOMINATION != 'sats') {
|
|
||||||
credit = credit * 100
|
|
||||||
}
|
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request('PUT', '/api/v1/wallet/balance/' + credit, this.g.wallet.inkey)
|
.request(
|
||||||
.catch(err => {
|
'PUT',
|
||||||
LNbits.utils.notifyApiError(err)
|
'/admin/api/v1/topup/?usr=' + this.g.user.id,
|
||||||
})
|
this.g.user.wallets[0].adminkey,
|
||||||
.then(response => {
|
{
|
||||||
let data = response.data
|
amount: credit,
|
||||||
if (data.status === 'ERROR') {
|
id: this.g.user.wallets[0].id
|
||||||
this.$q.notify({
|
|
||||||
timeout: 5000,
|
|
||||||
type: 'warning',
|
|
||||||
message: `Failed to update.`
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
this.balance = this.balance + data.balance
|
)
|
||||||
|
.then(response => {
|
||||||
|
this.$q.notify({
|
||||||
|
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 () {
|
closeReceiveDialog: function () {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
||||||
|
|
@ -83,31 +83,6 @@ async def api_wallet(wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||||
return {"name": wallet.wallet.name, "balance": wallet.wallet.balance_msat}
|
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}")
|
@core_app.put("/api/v1/wallet/{new_name}")
|
||||||
async def api_update_wallet(
|
async def api_update_wallet(
|
||||||
new_name: str, wallet: WalletTypeInfo = Depends(require_admin_key)
|
new_name: str, wallet: WalletTypeInfo = Depends(require_admin_key)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue