Browse Source

python black

adminvar
benarc 4 years ago
parent
commit
83598094e4
  1. 3
      lnbits/core/services.py
  2. 10
      lnbits/core/views/api.py
  3. 4
      lnbits/core/views/generic.py

3
lnbits/core/services.py

@ -126,6 +126,7 @@ def check_invoice_status(wallet_id: str, payment_hash: str) -> PaymentStatus:
return WALLET.get_invoice_status(payment.checking_id)
def update_wallet_balance(wallet_id: str, amount: int) -> str:
temp_id = f"temp_{urlsafe_short_hash()}"
internal_id = f"internal_{urlsafe_short_hash()}"
@ -134,7 +135,7 @@ def update_wallet_balance(wallet_id: str, amount: int) -> str:
checking_id=internal_id,
payment_request="admin_internal",
payment_hash="admin_internal",
amount=amount*1000,
amount=amount * 1000,
memo="Admin top up",
pending=False,
)

10
lnbits/core/views/api.py

@ -9,6 +9,7 @@ from lnbits.core.crud import delete_expired_invoices
from lnbits.decorators import api_check_wallet_key, api_validate_post_request
from lnbits.settings import WALLET, LNBITS_ADMIN_USERS
@core_app.route("/api/v1/payments", methods=["GET"])
@api_check_wallet_key("invoice")
def api_payments():
@ -122,15 +123,12 @@ def api_payment(payment_hash):
return jsonify({"paid": False}), HTTPStatus.OK
@core_app.route("/api/v1/balance", methods=["POST"])
@api_check_wallet_key("admin")
@api_validate_post_request(
schema={
"amount": {"type": "integer", "min": 1, "required": True}
}
)
@api_validate_post_request(schema={"amount": {"type": "integer", "min": 1, "required": True}})
def api_update_balance():
print(g.wallet.user)
if g.wallet.user in LNBITS_ADMIN_USERS:
return update_wallet_balance(g.wallet.id, g.data["amount"])
return jsonify({"message": "Not an admin wallet"}), HTTPStatus.INTERNAL_SERVER_ERROR
return jsonify({"message": "Not an admin wallet"}), HTTPStatus.INTERNAL_SERVER_ERROR

4
lnbits/core/views/generic.py

@ -78,7 +78,9 @@ 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, admin=admin)
return render_template(
"core/wallet.html", user=user, wallet=user.get_wallet(wallet_id), service_fee=service_fee, admin=admin
)
@core_app.route("/deletewallet")

Loading…
Cancel
Save