|
|
@ -4,7 +4,7 @@ from os import path |
|
|
|
|
|
|
|
from lnbits.core import core_app |
|
|
|
from lnbits.decorators import check_user_exists, validate_uuids |
|
|
|
from lnbits.settings import LNBITS_ALLOWED_USERS, SERVICE_FEE |
|
|
|
from lnbits.settings import LNBITS_ALLOWED_USERS, SERVICE_FEE, LNBITS_ADMIN_USERS |
|
|
|
|
|
|
|
from ..crud import ( |
|
|
|
create_account, |
|
|
@ -50,7 +50,7 @@ def wallet(): |
|
|
|
wallet_id = request.args.get("wal", type=str) |
|
|
|
wallet_name = request.args.get("nme", type=str) |
|
|
|
service_fee = int(SERVICE_FEE) if int(SERVICE_FEE) == SERVICE_FEE else SERVICE_FEE |
|
|
|
|
|
|
|
admin = False |
|
|
|
# just wallet_name: create a new user, then create a new wallet for user with wallet_name |
|
|
|
# just user_id: return the first user wallet or create one if none found (with default wallet_name) |
|
|
|
# user_id and wallet_name: create a new wallet for user with wallet_name |
|
|
@ -64,6 +64,8 @@ def wallet(): |
|
|
|
|
|
|
|
if LNBITS_ALLOWED_USERS and user_id not in LNBITS_ALLOWED_USERS: |
|
|
|
abort(HTTPStatus.UNAUTHORIZED, "User not authorized.") |
|
|
|
if LNBITS_ADMIN_USERS and user_id in LNBITS_ADMIN_USERS: |
|
|
|
admin = True |
|
|
|
|
|
|
|
if not wallet_id: |
|
|
|
if user.wallets and not wallet_name: |
|
|
@ -76,7 +78,7 @@ def wallet(): |
|
|
|
if wallet_id not in user.wallet_ids: |
|
|
|
abort(HTTPStatus.FORBIDDEN, "Not your wallet.") |
|
|
|
|
|
|
|
return render_template("core/wallet.html", user=user, wallet=user.get_wallet(wallet_id), service_fee=service_fee) |
|
|
|
return render_template("core/wallet.html", user=user, wallet=user.get_wallet(wallet_id), service_fee=service_fee, admin=admin) |
|
|
|
|
|
|
|
|
|
|
|
@core_app.route("/deletewallet") |
|
|
|