diff --git a/docs/guide/wallets.md b/docs/guide/wallets.md
index 80fb54c04..10724f34b 100644
--- a/docs/guide/wallets.md
+++ b/docs/guide/wallets.md
@@ -79,3 +79,8 @@ For the invoice to work you must have a publicly accessible URL in your LNbits.
- `LNBITS_BACKEND_WALLET_CLASS`: **OpenNodeWallet**
- `OPENNODE_API_ENDPOINT`: https://api.opennode.com/
- `OPENNODE_KEY`: opennodeAdminApiKey
+
+
+### Cliche Wallet
+
+- `CLICHE_ENDPOINT`: ws://127.0.0.1:12000
diff --git a/lnbits/app.py b/lnbits/app.py
index 8b9cf7985..075828ef0 100644
--- a/lnbits/app.py
+++ b/lnbits/app.py
@@ -91,7 +91,6 @@ def create_app(config_object="lnbits.settings") -> FastAPI:
)
app.add_middleware(GZipMiddleware, minimum_size=1000)
- # app.add_middleware(ASGIProxyFix)
check_funding_source(app)
register_assets(app)
diff --git a/lnbits/core/static/js/wallet.js b/lnbits/core/static/js/wallet.js
index 76d82ad4c..668013135 100644
--- a/lnbits/core/static/js/wallet.js
+++ b/lnbits/core/static/js/wallet.js
@@ -361,6 +361,35 @@ new Vue({
this.receive.status = 'pending'
})
},
+ onInitQR: async function (promise) {
+ try {
+ await promise
+ } catch (error) {
+ let mapping = {
+ NotAllowedError: 'ERROR: you need to grant camera access permission',
+ NotFoundError: 'ERROR: no camera on this device',
+ NotSupportedError:
+ 'ERROR: secure context required (HTTPS, localhost)',
+ NotReadableError: 'ERROR: is the camera already in use?',
+ OverconstrainedError: 'ERROR: installed cameras are not suitable',
+ StreamApiNotSupportedError:
+ 'ERROR: Stream API is not supported in this browser',
+ InsecureContextError:
+ 'ERROR: Camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP.'
+ }
+ let valid_error = Object.keys(mapping).filter(key => {
+ return error.name === key
+ })
+ let camera_error = valid_error
+ ? mapping[valid_error]
+ : `ERROR: Camera error (${error.name})`
+ this.parse.camera.show = false
+ this.$q.notify({
+ message: camera_error,
+ type: 'negative'
+ })
+ }
+ },
decodeQR: function (res) {
this.parse.data.request = res
this.decodeRequest()
diff --git a/lnbits/core/templates/core/wallet.html b/lnbits/core/templates/core/wallet.html
index bccdc2b48..4bf6067c0 100644
--- a/lnbits/core/templates/core/wallet.html
+++ b/lnbits/core/templates/core/wallet.html
@@ -653,6 +653,7 @@
@@ -671,6 +672,7 @@
diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py
index c07df568a..983d5a261 100644
--- a/lnbits/core/views/api.py
+++ b/lnbits/core/views/api.py
@@ -476,7 +476,7 @@ async def api_lnurlscan(code: str, wallet: WalletTypeInfo = Depends(get_key_type
except:
# parse internet identifier (user@domain.com)
name_domain = code.split("@")
- if len(name_domain) == 2 and len(name_domain[1].split(".")) == 2:
+ if len(name_domain) == 2 and len(name_domain[1].split(".")) >= 2:
name, domain = name_domain
url = (
("http://" if domain.endswith(".onion") else "https://")
diff --git a/lnbits/extensions/copilot/crud.py b/lnbits/extensions/copilot/crud.py
index d0da044eb..5ecb5cd45 100644
--- a/lnbits/extensions/copilot/crud.py
+++ b/lnbits/extensions/copilot/crud.py
@@ -10,7 +10,7 @@ from .models import Copilots, CreateCopilotData
async def create_copilot(
data: CreateCopilotData, inkey: Optional[str] = ""
-) -> Copilots:
+) -> Optional[Copilots]:
copilot_id = urlsafe_short_hash()
await db.execute(
"""
@@ -67,19 +67,19 @@ async def create_copilot(
async def update_copilot(
- data: CreateCopilotData, copilot_id: Optional[str] = ""
+ data: CreateCopilotData, copilot_id: str
) -> Optional[Copilots]:
q = ", ".join([f"{field[0]} = ?" for field in data])
items = [f"{field[1]}" for field in data]
items.append(copilot_id)
- await db.execute(f"UPDATE copilot.newer_copilots SET {q} WHERE id = ?", (items))
+ await db.execute(f"UPDATE copilot.newer_copilots SET {q} WHERE id = ?", (items,))
row = await db.fetchone(
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
)
return Copilots(**row) if row else None
-async def get_copilot(copilot_id: str) -> Copilots:
+async def get_copilot(copilot_id: str) -> Optional[Copilots]:
row = await db.fetchone(
"SELECT * FROM copilot.newer_copilots WHERE id = ?", (copilot_id,)
)
diff --git a/lnbits/extensions/copilot/tasks.py b/lnbits/extensions/copilot/tasks.py
index c59ef4cc8..48ad7813d 100644
--- a/lnbits/extensions/copilot/tasks.py
+++ b/lnbits/extensions/copilot/tasks.py
@@ -26,7 +26,7 @@ async def wait_for_paid_invoices():
async def on_invoice_paid(payment: Payment) -> None:
webhook = None
data = None
- if payment.extra.get("tag") != "copilot":
+ if not payment.extra or payment.extra.get("tag") != "copilot":
# not an copilot invoice
return
@@ -71,12 +71,12 @@ async def on_invoice_paid(payment: Payment) -> None:
async def mark_webhook_sent(payment: Payment, status: int) -> None:
- payment.extra["wh_status"] = status
-
- await core_db.execute(
- """
- UPDATE apipayments SET extra = ?
- WHERE hash = ?
- """,
- (json.dumps(payment.extra), payment.payment_hash),
- )
+ if payment.extra:
+ payment.extra["wh_status"] = status
+ await core_db.execute(
+ """
+ UPDATE apipayments SET extra = ?
+ WHERE hash = ?
+ """,
+ (json.dumps(payment.extra), payment.payment_hash),
+ )
diff --git a/lnbits/extensions/copilot/views.py b/lnbits/extensions/copilot/views.py
index 7ee7f590e..b4a2354a0 100644
--- a/lnbits/extensions/copilot/views.py
+++ b/lnbits/extensions/copilot/views.py
@@ -15,7 +15,9 @@ templates = Jinja2Templates(directory="templates")
@copilot_ext.get("/", response_class=HTMLResponse)
-async def index(request: Request, user: User = Depends(check_user_exists)):
+async def index(
+ request: Request, user: User = Depends(check_user_exists) # type: ignore
+):
return copilot_renderer().TemplateResponse(
"copilot/index.html", {"request": request, "user": user.dict()}
)
@@ -44,7 +46,7 @@ class ConnectionManager:
async def connect(self, websocket: WebSocket, copilot_id: str):
await websocket.accept()
- websocket.id = copilot_id
+ websocket.id = copilot_id # type: ignore
self.active_connections.append(websocket)
def disconnect(self, websocket: WebSocket):
@@ -52,7 +54,7 @@ class ConnectionManager:
async def send_personal_message(self, message: str, copilot_id: str):
for connection in self.active_connections:
- if connection.id == copilot_id:
+ if connection.id == copilot_id: # type: ignore
await connection.send_text(message)
async def broadcast(self, message: str):
diff --git a/lnbits/extensions/copilot/views_api.py b/lnbits/extensions/copilot/views_api.py
index 91b0572a5..46611a2ea 100644
--- a/lnbits/extensions/copilot/views_api.py
+++ b/lnbits/extensions/copilot/views_api.py
@@ -23,7 +23,7 @@ from .views import updater
@copilot_ext.get("/api/v1/copilot")
async def api_copilots_retrieve(
- req: Request, wallet: WalletTypeInfo = Depends(get_key_type)
+ req: Request, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
wallet_user = wallet.wallet.user
copilots = [copilot.dict() for copilot in await get_copilots(wallet_user)]
@@ -37,7 +37,7 @@ async def api_copilots_retrieve(
async def api_copilot_retrieve(
req: Request,
copilot_id: str = Query(None),
- wallet: WalletTypeInfo = Depends(get_key_type),
+ wallet: WalletTypeInfo = Depends(get_key_type), # type: ignore
):
copilot = await get_copilot(copilot_id)
if not copilot:
@@ -54,7 +54,7 @@ async def api_copilot_retrieve(
async def api_copilot_create_or_update(
data: CreateCopilotData,
copilot_id: str = Query(None),
- wallet: WalletTypeInfo = Depends(require_admin_key),
+ wallet: WalletTypeInfo = Depends(require_admin_key), # type: ignore
):
data.user = wallet.wallet.user
data.wallet = wallet.wallet.id
@@ -67,7 +67,8 @@ async def api_copilot_create_or_update(
@copilot_ext.delete("/api/v1/copilot/{copilot_id}")
async def api_copilot_delete(
- copilot_id: str = Query(None), wallet: WalletTypeInfo = Depends(require_admin_key)
+ copilot_id: str = Query(None),
+ wallet: WalletTypeInfo = Depends(require_admin_key), # type: ignore
):
copilot = await get_copilot(copilot_id)
diff --git a/lnbits/extensions/discordbot/crud.py b/lnbits/extensions/discordbot/crud.py
index 5661fcb4d..629a5c004 100644
--- a/lnbits/extensions/discordbot/crud.py
+++ b/lnbits/extensions/discordbot/crud.py
@@ -98,21 +98,21 @@ async def get_discordbot_wallet(wallet_id: str) -> Optional[Wallets]:
return Wallets(**row) if row else None
-async def get_discordbot_wallets(admin_id: str) -> Optional[Wallets]:
+async def get_discordbot_wallets(admin_id: str) -> List[Wallets]:
rows = await db.fetchall(
"SELECT * FROM discordbot.wallets WHERE admin = ?", (admin_id,)
)
return [Wallets(**row) for row in rows]
-async def get_discordbot_users_wallets(user_id: str) -> Optional[Wallets]:
+async def get_discordbot_users_wallets(user_id: str) -> List[Wallets]:
rows = await db.fetchall(
"""SELECT * FROM discordbot.wallets WHERE "user" = ?""", (user_id,)
)
return [Wallets(**row) for row in rows]
-async def get_discordbot_wallet_transactions(wallet_id: str) -> Optional[Payment]:
+async def get_discordbot_wallet_transactions(wallet_id: str) -> List[Payment]:
return await get_payments(
wallet_id=wallet_id, complete=True, pending=False, outgoing=True, incoming=True
)
diff --git a/lnbits/extensions/discordbot/views.py b/lnbits/extensions/discordbot/views.py
index a5395e21f..ec7d18cc3 100644
--- a/lnbits/extensions/discordbot/views.py
+++ b/lnbits/extensions/discordbot/views.py
@@ -9,7 +9,9 @@ from . import discordbot_ext, discordbot_renderer
@discordbot_ext.get("/", response_class=HTMLResponse)
-async def index(request: Request, user: User = Depends(check_user_exists)):
+async def index(
+ request: Request, user: User = Depends(check_user_exists) # type: ignore
+):
return discordbot_renderer().TemplateResponse(
"discordbot/index.html", {"request": request, "user": user.dict()}
)
diff --git a/lnbits/extensions/discordbot/views_api.py b/lnbits/extensions/discordbot/views_api.py
index 6f213a89a..e6d004dbb 100644
--- a/lnbits/extensions/discordbot/views_api.py
+++ b/lnbits/extensions/discordbot/views_api.py
@@ -27,32 +27,37 @@ from .models import CreateUserData, CreateUserWallet
@discordbot_ext.get("/api/v1/users", status_code=HTTPStatus.OK)
-async def api_discordbot_users(wallet: WalletTypeInfo = Depends(get_key_type)):
+async def api_discordbot_users(
+ wallet: WalletTypeInfo = Depends(get_key_type), # type: ignore
+):
user_id = wallet.wallet.user
return [user.dict() for user in await get_discordbot_users(user_id)]
@discordbot_ext.get("/api/v1/users/{user_id}", status_code=HTTPStatus.OK)
-async def api_discordbot_user(user_id, wallet: WalletTypeInfo = Depends(get_key_type)):
+async def api_discordbot_user(
+ user_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
+):
user = await get_discordbot_user(user_id)
- return user.dict()
+ if user:
+ return user.dict()
@discordbot_ext.post("/api/v1/users", status_code=HTTPStatus.CREATED)
async def api_discordbot_users_create(
- data: CreateUserData, wallet: WalletTypeInfo = Depends(get_key_type)
+ data: CreateUserData, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
user = await create_discordbot_user(data)
full = user.dict()
- full["wallets"] = [
- wallet.dict() for wallet in await get_discordbot_users_wallets(user.id)
- ]
+ wallets = await get_discordbot_users_wallets(user.id)
+ if wallets:
+ full["wallets"] = [wallet for wallet in wallets]
return full
@discordbot_ext.delete("/api/v1/users/{user_id}")
async def api_discordbot_users_delete(
- user_id, wallet: WalletTypeInfo = Depends(get_key_type)
+ user_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
user = await get_discordbot_user(user_id)
if not user:
@@ -75,7 +80,7 @@ async def api_discordbot_activate_extension(
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="User does not exist."
)
- update_user_extension(user_id=userid, extension=extension, active=active)
+ await update_user_extension(user_id=userid, extension=extension, active=active)
return {"extension": "updated"}
@@ -84,7 +89,7 @@ async def api_discordbot_activate_extension(
@discordbot_ext.post("/api/v1/wallets")
async def api_discordbot_wallets_create(
- data: CreateUserWallet, wallet: WalletTypeInfo = Depends(get_key_type)
+ data: CreateUserWallet, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
user = await create_discordbot_wallet(
user_id=data.user_id, wallet_name=data.wallet_name, admin_id=data.admin_id
@@ -93,28 +98,30 @@ async def api_discordbot_wallets_create(
@discordbot_ext.get("/api/v1/wallets")
-async def api_discordbot_wallets(wallet: WalletTypeInfo = Depends(get_key_type)):
+async def api_discordbot_wallets(
+ wallet: WalletTypeInfo = Depends(get_key_type), # type: ignore
+):
admin_id = wallet.wallet.user
- return [wallet.dict() for wallet in await get_discordbot_wallets(admin_id)]
+ return await get_discordbot_wallets(admin_id)
@discordbot_ext.get("/api/v1/transactions/{wallet_id}")
async def api_discordbot_wallet_transactions(
- wallet_id, wallet: WalletTypeInfo = Depends(get_key_type)
+ wallet_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
return await get_discordbot_wallet_transactions(wallet_id)
@discordbot_ext.get("/api/v1/wallets/{user_id}")
async def api_discordbot_users_wallets(
- user_id, wallet: WalletTypeInfo = Depends(get_key_type)
+ user_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
- return [s_wallet.dict() for s_wallet in await get_discordbot_users_wallets(user_id)]
+ return await get_discordbot_users_wallets(user_id)
@discordbot_ext.delete("/api/v1/wallets/{wallet_id}")
async def api_discordbot_wallets_delete(
- wallet_id, wallet: WalletTypeInfo = Depends(get_key_type)
+ wallet_id, wallet: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
get_wallet = await get_discordbot_wallet(wallet_id)
if not get_wallet:
diff --git a/lnbits/extensions/example/views.py b/lnbits/extensions/example/views.py
index 252b47263..29b257f45 100644
--- a/lnbits/extensions/example/views.py
+++ b/lnbits/extensions/example/views.py
@@ -12,7 +12,10 @@ templates = Jinja2Templates(directory="templates")
@example_ext.get("/", response_class=HTMLResponse)
-async def index(request: Request, user: User = Depends(check_user_exists)):
+async def index(
+ request: Request,
+ user: User = Depends(check_user_exists), # type: ignore
+):
return example_renderer().TemplateResponse(
"example/index.html", {"request": request, "user": user.dict()}
)
diff --git a/lnbits/extensions/subdomains/crud.py b/lnbits/extensions/subdomains/crud.py
index 207e2d1d4..aa358d11c 100644
--- a/lnbits/extensions/subdomains/crud.py
+++ b/lnbits/extensions/subdomains/crud.py
@@ -3,10 +3,10 @@ from typing import List, Optional, Union
from lnbits.helpers import urlsafe_short_hash
from . import db
-from .models import CreateDomain, Domains, Subdomains
+from .models import CreateDomain, CreateSubdomain, Domains, Subdomains
-async def create_subdomain(payment_hash, wallet, data: CreateDomain) -> Subdomains:
+async def create_subdomain(payment_hash, wallet, data: CreateSubdomain) -> Subdomains:
await db.execute(
"""
INSERT INTO subdomains.subdomain (id, domain, email, subdomain, ip, wallet, sats, duration, paid, record_type)
diff --git a/lnbits/extensions/subdomains/models.py b/lnbits/extensions/subdomains/models.py
index 170045040..39e176155 100644
--- a/lnbits/extensions/subdomains/models.py
+++ b/lnbits/extensions/subdomains/models.py
@@ -3,24 +3,24 @@ from pydantic.main import BaseModel
class CreateDomain(BaseModel):
- wallet: str = Query(...)
- domain: str = Query(...)
- cf_token: str = Query(...)
- cf_zone_id: str = Query(...)
- webhook: str = Query("")
- description: str = Query(..., min_length=0)
- cost: int = Query(..., ge=0)
- allowed_record_types: str = Query(...)
+ wallet: str = Query(...) # type: ignore
+ domain: str = Query(...) # type: ignore
+ cf_token: str = Query(...) # type: ignore
+ cf_zone_id: str = Query(...) # type: ignore
+ webhook: str = Query("") # type: ignore
+ description: str = Query(..., min_length=0) # type: ignore
+ cost: int = Query(..., ge=0) # type: ignore
+ allowed_record_types: str = Query(...) # type: ignore
class CreateSubdomain(BaseModel):
- domain: str = Query(...)
- subdomain: str = Query(...)
- email: str = Query(...)
- ip: str = Query(...)
- sats: int = Query(..., ge=0)
- duration: int = Query(...)
- record_type: str = Query(...)
+ domain: str = Query(...) # type: ignore
+ subdomain: str = Query(...) # type: ignore
+ email: str = Query(...) # type: ignore
+ ip: str = Query(...) # type: ignore
+ sats: int = Query(..., ge=0) # type: ignore
+ duration: int = Query(...) # type: ignore
+ record_type: str = Query(...) # type: ignore
class Domains(BaseModel):
diff --git a/lnbits/extensions/subdomains/tasks.py b/lnbits/extensions/subdomains/tasks.py
index 04ee2dd48..c5a7f47ba 100644
--- a/lnbits/extensions/subdomains/tasks.py
+++ b/lnbits/extensions/subdomains/tasks.py
@@ -20,7 +20,7 @@ async def wait_for_paid_invoices():
async def on_invoice_paid(payment: Payment) -> None:
- if payment.extra.get("tag") != "lnsubdomain":
+ if not payment.extra or payment.extra.get("tag") != "lnsubdomain":
# not an lnurlp invoice
return
@@ -37,7 +37,7 @@ async def on_invoice_paid(payment: Payment) -> None:
)
### Use webhook to notify about cloudflare registration
- if domain.webhook:
+ if domain and domain.webhook:
async with httpx.AsyncClient() as client:
try:
r = await client.post(
diff --git a/lnbits/extensions/subdomains/views.py b/lnbits/extensions/subdomains/views.py
index df387ba8c..962f850d0 100644
--- a/lnbits/extensions/subdomains/views.py
+++ b/lnbits/extensions/subdomains/views.py
@@ -16,7 +16,9 @@ templates = Jinja2Templates(directory="templates")
@subdomains_ext.get("/", response_class=HTMLResponse)
-async def index(request: Request, user: User = Depends(check_user_exists)):
+async def index(
+ request: Request, user: User = Depends(check_user_exists) # type:ignore
+):
return subdomains_renderer().TemplateResponse(
"subdomains/index.html", {"request": request, "user": user.dict()}
)
diff --git a/lnbits/extensions/subdomains/views_api.py b/lnbits/extensions/subdomains/views_api.py
index b01e6ffbb..34d8e75be 100644
--- a/lnbits/extensions/subdomains/views_api.py
+++ b/lnbits/extensions/subdomains/views_api.py
@@ -29,12 +29,15 @@ from .crud import (
@subdomains_ext.get("/api/v1/domains")
async def api_domains(
- g: WalletTypeInfo = Depends(get_key_type), all_wallets: bool = Query(False)
+ g: WalletTypeInfo = Depends(get_key_type), # type: ignore
+ all_wallets: bool = Query(False),
):
wallet_ids = [g.wallet.id]
if all_wallets:
- wallet_ids = (await get_user(g.wallet.user)).wallet_ids
+ user = await get_user(g.wallet.user)
+ if user is not None:
+ wallet_ids = user.wallet_ids
return [domain.dict() for domain in await get_domains(wallet_ids)]
@@ -42,7 +45,9 @@ async def api_domains(
@subdomains_ext.post("/api/v1/domains")
@subdomains_ext.put("/api/v1/domains/{domain_id}")
async def api_domain_create(
- data: CreateDomain, domain_id=None, g: WalletTypeInfo = Depends(get_key_type)
+ data: CreateDomain,
+ domain_id=None,
+ g: WalletTypeInfo = Depends(get_key_type), # type: ignore
):
if domain_id:
domain = await get_domain(domain_id)
@@ -63,7 +68,9 @@ async def api_domain_create(
@subdomains_ext.delete("/api/v1/domains/{domain_id}")
-async def api_domain_delete(domain_id, g: WalletTypeInfo = Depends(get_key_type)):
+async def api_domain_delete(
+ domain_id, g: WalletTypeInfo = Depends(get_key_type) # type: ignore
+):
domain = await get_domain(domain_id)
if not domain:
@@ -82,12 +89,14 @@ async def api_domain_delete(domain_id, g: WalletTypeInfo = Depends(get_key_type)
@subdomains_ext.get("/api/v1/subdomains")
async def api_subdomains(
- all_wallets: bool = Query(False), g: WalletTypeInfo = Depends(get_key_type)
+ all_wallets: bool = Query(False), g: WalletTypeInfo = Depends(get_key_type) # type: ignore
):
wallet_ids = [g.wallet.id]
if all_wallets:
- wallet_ids = (await get_user(g.wallet.user)).wallet_ids
+ user = await get_user(g.wallet.user)
+ if user is not None:
+ wallet_ids = user.wallet_ids
return [domain.dict() for domain in await get_subdomains(wallet_ids)]
@@ -173,7 +182,9 @@ async def api_subdomain_send_subdomain(payment_hash):
@subdomains_ext.delete("/api/v1/subdomains/{subdomain_id}")
-async def api_subdomain_delete(subdomain_id, g: WalletTypeInfo = Depends(get_key_type)):
+async def api_subdomain_delete(
+ subdomain_id, g: WalletTypeInfo = Depends(get_key_type) # type: ignore
+):
subdomain = await get_subdomain(subdomain_id)
if not subdomain:
diff --git a/lnbits/proxy_fix.py b/lnbits/proxy_fix.py
deleted file mode 100644
index 897835e0d..000000000
--- a/lnbits/proxy_fix.py
+++ /dev/null
@@ -1,95 +0,0 @@
-from functools import partial
-from typing import Callable, List, Optional
-from urllib.parse import urlparse
-from urllib.request import parse_http_list as _parse_list_header
-
-from quart import Request
-from quart_trio.asgi import TrioASGIHTTPConnection
-from werkzeug.datastructures import Headers
-
-
-class ASGIProxyFix(TrioASGIHTTPConnection):
- def _create_request_from_scope(self, send: Callable) -> Request:
- headers = Headers()
- headers["Remote-Addr"] = (self.scope.get("client") or [""])[0]
- for name, value in self.scope["headers"]:
- headers.add(name.decode("latin1").title(), value.decode("latin1"))
- if self.scope["http_version"] < "1.1":
- headers.setdefault("Host", self.app.config["SERVER_NAME"] or "")
-
- path = self.scope["path"]
- path = path if path[0] == "/" else urlparse(path).path
-
- x_proto = self._get_real_value(1, headers.get("X-Forwarded-Proto"))
- if x_proto:
- self.scope["scheme"] = x_proto
-
- x_host = self._get_real_value(1, headers.get("X-Forwarded-Host"))
- if x_host:
- headers["host"] = x_host.lower()
-
- return self.app.request_class(
- self.scope["method"],
- self.scope["scheme"],
- path,
- self.scope["query_string"],
- headers,
- self.scope.get("root_path", ""),
- self.scope["http_version"],
- max_content_length=self.app.config["MAX_CONTENT_LENGTH"],
- body_timeout=self.app.config["BODY_TIMEOUT"],
- send_push_promise=partial(self._send_push_promise, send),
- scope=self.scope,
- )
-
- def _get_real_value(self, trusted: int, value: Optional[str]) -> Optional[str]:
- """Get the real value from a list header based on the configured
- number of trusted proxies.
- :param trusted: Number of values to trust in the header.
- :param value: Comma separated list header value to parse.
- :return: The real value, or ``None`` if there are fewer values
- than the number of trusted proxies.
- .. versionchanged:: 1.0
- Renamed from ``_get_trusted_comma``.
- .. versionadded:: 0.15
- """
- if not (trusted and value):
- return None
-
- values = self.parse_list_header(value)
- if len(values) >= trusted:
- return values[-trusted]
-
- return None
-
- def parse_list_header(self, value: str) -> List[str]:
- result = []
- for item in _parse_list_header(value):
- if item[:1] == item[-1:] == '"':
- item = self.unquote_header_value(item[1:-1])
- result.append(item)
- return result
-
- def unquote_header_value(self, value: str, is_filename: bool = False) -> str:
- r"""Unquotes a header value. (Reversal of :func:`quote_header_value`).
- This does not use the real unquoting but what browsers are actually
- using for quoting.
- .. versionadded:: 0.5
- :param value: the header value to unquote.
- :param is_filename: The value represents a filename or path.
- """
- if value and value[0] == value[-1] == '"':
- # this is not the real unquoting, but fixing this so that the
- # RFC is met will result in bugs with internet explorer and
- # probably some other browsers as well. IE for example is
- # uploading files with "C:\foo\bar.txt" as filename
- value = value[1:-1]
-
- # if this is a filename and the starting characters look like
- # a UNC path, then just return the value without quotes. Using the
- # replace sequence below on a UNC path has the effect of turning
- # the leading double slash into a single slash and then
- # _fix_ie_filename() doesn't work correctly. See #458.
- if not is_filename or value[:2] != "\\\\":
- return value.replace("\\\\", "\\").replace('\\"', '"')
- return value
diff --git a/pyproject.toml b/pyproject.toml
index 19dac8600..7418de272 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -89,8 +89,34 @@ profile = "black"
ignore_missing_imports = "True"
files = "lnbits"
exclude = """(?x)(
- ^lnbits/extensions.
- | ^lnbits/wallets/lnd_grpc_files.
+ ^lnbits/extensions/bleskomat.
+ | ^lnbits/extensions/boltz.
+ | ^lnbits/extensions/boltcards.
+ | ^lnbits/extensions/events.
+ | ^lnbits/extensions/hivemind.
+ | ^lnbits/extensions/invoices.
+ | ^lnbits/extensions/jukebox.
+ | ^lnbits/extensions/livestream.
+ | ^lnbits/extensions/lnaddress.
+ | ^lnbits/extensions/lndhub.
+ | ^lnbits/extensions/lnticket.
+ | ^lnbits/extensions/lnurldevice.
+ | ^lnbits/extensions/lnurlp.
+ | ^lnbits/extensions/lnurlpayout.
+ | ^lnbits/extensions/ngrok.
+ | ^lnbits/extensions/offlineshop.
+ | ^lnbits/extensions/paywall.
+ | ^lnbits/extensions/satsdice.
+ | ^lnbits/extensions/satspay.
+ | ^lnbits/extensions/scrub.
+ | ^lnbits/extensions/splitpayments.
+ | ^lnbits/extensions/streamalerts.
+ | ^lnbits/extensions/tipjar.
+ | ^lnbits/extensions/tpos.
+ | ^lnbits/extensions/usermanager.
+ | ^lnbits/extensions/watchonly.
+ | ^lnbits/extensions/withdraw.
+ | ^lnbits/wallets/lnd_grpc_files.
)"""
[tool.pytest.ini_options]