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:
dni ⚡
2024-12-17 21:06:58 +01:00
committed by GitHub
co-authored by Vlad Stan
parent 368da935db
commit 37187bfc2c
20 changed files with 121 additions and 145 deletions
+8 -10
View File
@@ -24,9 +24,9 @@ from lnbits.core.crud import (
from lnbits.core.models import (
AccountFilters,
AccountOverview,
CreateTopup,
CreateUser,
SimpleStatus,
UpdateBalance,
User,
UserExtra,
Wallet,
@@ -267,16 +267,14 @@ async def api_users_delete_user_wallet(user_id: str, wallet: str) -> SimpleStatu
@users_router.put(
"/topup",
name="Topup",
"/balance",
name="UpdateBalance",
summary="Update balance for a particular wallet.",
status_code=HTTPStatus.OK,
dependencies=[Depends(check_super_user)],
)
async def api_topup_balance(data: CreateTopup) -> SimpleStatus:
await get_wallet(data.id)
if settings.lnbits_backend_wallet_class == "VoidWallet":
raise Exception("VoidWallet active")
await update_wallet_balance(wallet_id=data.id, amount=int(data.amount))
async def api_update_balance(data: UpdateBalance) -> SimpleStatus:
wallet = await get_wallet(data.id)
if not wallet:
raise HTTPException(HTTPStatus.NOT_FOUND, "Wallet not found.")
await update_wallet_balance(wallet=wallet, amount=int(data.amount))
return SimpleStatus(success=True, message="Balance updated.")