mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-13 11:35:56 +01:00
remove FIXME add couple of ignores
This commit is contained in:
parent
e63c4c9fa2
commit
00dba54ac8
3 changed files with 7 additions and 35 deletions
|
@ -270,9 +270,6 @@ async def perform_lnurlauth(
|
|||
|
||||
k1 = unhexlify(parse_qs(cb.query)["k1"][0])
|
||||
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
|
||||
key = wallet.wallet.lnurlauth_key(cb.netloc)
|
||||
|
||||
def int_to_bytes_suitable_der(x: int) -> bytes:
|
||||
|
|
|
@ -56,16 +56,12 @@ from ..tasks import api_invoice_listeners
|
|||
@core_app.get("/api/v1/wallet")
|
||||
async def api_wallet(wallet: WalletTypeInfo = Depends(get_key_type)):
|
||||
if wallet.wallet_type == 0:
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
return {
|
||||
"id": wallet.wallet.id,
|
||||
"name": wallet.wallet.name,
|
||||
"balance": wallet.wallet.balance_msat,
|
||||
}
|
||||
else:
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
return {"name": wallet.wallet.name, "balance": wallet.wallet.balance_msat}
|
||||
|
||||
|
||||
|
@ -73,9 +69,6 @@ async def api_wallet(wallet: WalletTypeInfo = Depends(get_key_type)):
|
|||
async def api_update_balance(
|
||||
amount: int, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
):
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
|
||||
if wallet.wallet.user not in LNBITS_ADMIN_USERS:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN, detail="Not an admin user"
|
||||
|
@ -105,9 +98,6 @@ async def api_update_balance(
|
|||
async def api_update_wallet(
|
||||
new_name: str, wallet: WalletTypeInfo = Depends(require_admin_key)
|
||||
):
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
|
||||
await update_wallet(wallet.wallet.id, new_name)
|
||||
return {
|
||||
"id": wallet.wallet.id,
|
||||
|
@ -122,9 +112,6 @@ async def api_payments(
|
|||
offset: Optional[int] = None,
|
||||
wallet: WalletTypeInfo = Depends(get_key_type),
|
||||
):
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
|
||||
pendingPayments = await get_payments(
|
||||
wallet_id=wallet.wallet.id,
|
||||
pending=True,
|
||||
|
@ -269,15 +256,11 @@ async def api_payments_create(
|
|||
status_code=HTTPStatus.BAD_REQUEST,
|
||||
detail="BOLT11 string is invalid or not given",
|
||||
)
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
return await api_payments_pay_invoice(
|
||||
invoiceData.bolt11, wallet.wallet
|
||||
) # admin key
|
||||
elif not invoiceData.out:
|
||||
# invoice key
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
return await api_payments_create_invoice(invoiceData, wallet.wallet)
|
||||
else:
|
||||
raise HTTPException(
|
||||
|
@ -342,8 +325,6 @@ async def api_payments_pay_lnurl(
|
|||
if data.comment:
|
||||
extra["comment"] = data.comment
|
||||
assert data.description is not None, "description is required"
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
payment_hash = await pay_invoice(
|
||||
wallet_id=wallet.wallet.id,
|
||||
payment_request=params["pr"],
|
||||
|
@ -397,8 +378,6 @@ async def subscribe(request: Request, wallet: Wallet):
|
|||
async def api_payments_sse(
|
||||
request: Request, wallet: WalletTypeInfo = Depends(get_key_type)
|
||||
):
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
return EventSourceResponse(
|
||||
subscribe(request, wallet.wallet), ping=20, media_type="text/event-stream"
|
||||
)
|
||||
|
@ -477,8 +456,6 @@ async def api_lnurlscan(code: str, wallet: WalletTypeInfo = Depends(get_key_type
|
|||
params.update(kind="auth")
|
||||
params.update(callback=url) # with k1 already in it
|
||||
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
lnurlauth_key = wallet.wallet.lnurlauth_key(domain)
|
||||
params.update(pubkey=lnurlauth_key.verifying_key.to_string("compressed").hex())
|
||||
else:
|
||||
|
|
|
@ -41,6 +41,7 @@ class KeyChecker(SecurityBase):
|
|||
name="X-API-KEY",
|
||||
description="Wallet API Key - HEADER",
|
||||
)
|
||||
self.wallet = None # type: ignore
|
||||
self.model: APIKey = key
|
||||
|
||||
async def __call__(self, request: Request):
|
||||
|
@ -53,7 +54,7 @@ class KeyChecker(SecurityBase):
|
|||
# FIXME: Find another way to validate the key. A fetch from DB should be avoided here.
|
||||
# Also, we should not return the wallet here - thats silly.
|
||||
# Possibly store it in a Redis DB
|
||||
self.wallet = await get_wallet_for_key(key_value, self._key_type)
|
||||
self.wallet = await get_wallet_for_key(key_value, self._key_type) # type: ignore
|
||||
if not self.wallet:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.UNAUTHORIZED,
|
||||
|
@ -100,9 +101,9 @@ class WalletAdminKeyChecker(KeyChecker):
|
|||
|
||||
class WalletTypeInfo:
|
||||
wallet_type: int
|
||||
wallet: Union[Wallet, None]
|
||||
wallet: Wallet
|
||||
|
||||
def __init__(self, wallet_type: int, wallet: Union[Wallet, None]) -> None:
|
||||
def __init__(self, wallet_type: int, wallet: Wallet) -> None:
|
||||
self.wallet_type = wallet_type
|
||||
self.wallet = wallet
|
||||
|
||||
|
@ -137,8 +138,7 @@ async def get_key_type(
|
|||
try:
|
||||
admin_checker = WalletAdminKeyChecker(api_key=token)
|
||||
await admin_checker.__call__(r)
|
||||
wallet = WalletTypeInfo(0, admin_checker.wallet)
|
||||
assert wallet.wallet is not None
|
||||
wallet = WalletTypeInfo(0, admin_checker.wallet) # type: ignore
|
||||
if (LNBITS_ADMIN_USERS and wallet.wallet.user not in LNBITS_ADMIN_USERS) and (
|
||||
LNBITS_ADMIN_EXTENSIONS and pathname in LNBITS_ADMIN_EXTENSIONS
|
||||
):
|
||||
|
@ -157,9 +157,7 @@ async def get_key_type(
|
|||
try:
|
||||
invoice_checker = WalletInvoiceKeyChecker(api_key=token)
|
||||
await invoice_checker.__call__(r)
|
||||
wallet = WalletTypeInfo(1, invoice_checker.wallet)
|
||||
# FIXME: wallet.wallet can be None here
|
||||
assert wallet.wallet is not None
|
||||
wallet = WalletTypeInfo(1, invoice_checker.wallet) # type: ignore
|
||||
if (LNBITS_ADMIN_USERS and wallet.wallet.user not in LNBITS_ADMIN_USERS) and (
|
||||
LNBITS_ADMIN_EXTENSIONS and pathname in LNBITS_ADMIN_EXTENSIONS
|
||||
):
|
||||
|
@ -171,7 +169,7 @@ async def get_key_type(
|
|||
if e.status_code == HTTPStatus.BAD_REQUEST:
|
||||
raise
|
||||
if e.status_code == HTTPStatus.UNAUTHORIZED:
|
||||
return WalletTypeInfo(2, None)
|
||||
return WalletTypeInfo(2, None) # type: ignore
|
||||
except:
|
||||
raise
|
||||
return wallet
|
||||
|
|
Loading…
Add table
Reference in a new issue