Migrate to Pydantic 2 for LNbits 1.7.0 (#17)
What changed, and why it matters
This commit is a routine extension migration to support Pydantic 2 and LNbits 1.7.0. It adds the entire paywall extension codebase, configuration, tests, and build tooling. There is no indication in the commit or supplied references that this change fixes or introduces a security vulnerability.
No security action required based on this commit alone. Treat as a normal dependency/framework migration. If auditing, review views_api.py for authorization checks and ensure file download proxying in views.py does not introduce SSRF or header injection.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit 0def81933607ac2c75446879e77dc6e004553ca9 in the lnbits/paywall repository introduces the full paywall extension source tree, including FastAPI routers, Pydantic v2 models, SQL migrations, Jinja/Vue templates, static assets, GitHub Actions workflows, pyproject.toml, and a uv.lock file. The title and message describe it as a migration to Pydantic 2 for LNbits 1.7.0. No security-relevant changes, bug fixes, or vulnerability disclosures are mentioned in the commit metadata or diff. The code does not visibly introduce common vulnerability patterns such as SQL injection, unsafe deserialization, or missing authorization, though a full security audit would require reviewing the omitted views.py and views_api.py files and runtime behavior.
Changed components
lnbits/paywall extensionPydantic models (models.py)Database migrations (migrations.py)FastAPI routers (views.py, views_api.py - not shown in diff)Frontend templates and static assetsCI/release workflowsInspect captured patch +922 / −380
### config.json
@@ -1,8 +1,9 @@
{
"name": "Paywall",
+ "version": "1.3.0",
"short_description": "Create paywalls for content",
"tile": "/paywall/static/image/paywall.png",
- "min_lnbits_version": "1.3.0",
+ "min_lnbits_version": "1.7.0-rc1",
"contributors": [
{
"name": "eillarra",
### crud.py
@@ -11,7 +11,7 @@ async def create_paywall(wallet_id: str, data: CreatePaywall) -> Paywall:
paywall = Paywall(
id=paywall_id,
wallet=wallet_id,
- **data.dict(),
+ **data.model_dump(),
)
await db.insert("paywall.paywalls", paywall)
return paywall
### models.py
@@ -21,7 +21,7 @@ class PaywallExtra(BaseModel):
class CreatePaywall(BaseModel):
url: str = Query(...)
memo: str = Query(...)
- description: str = Query(None)
+ description: str | None = Query(None)
amount: float = Query(..., ge=0)
currency: str | None = "sat"
fiat_provider: str | None = None
@@ -43,7 +43,7 @@ class PublicPaywall(BaseModel):
wallet: str
url: str
memo: str
- description: str | None
+ description: str | None = None
amount: float
currency: str
fiat_provider: str | None = None
### pyproject.toml
@@ -1,27 +1,33 @@
[project]
name = "lnbits-paywall"
-version = "0.0.0"
-requires-python = ">=3.10,<3.13"
+version = "1.3.0"
+requires-python = ">=3.10,<3.14"
description = "LNbits, free and open-source Lightning wallet and accounts system."
authors = [{ name = "Alan Bits", email = "alan@lnbits.com" }]
urls = { Homepage = "https://lnbits.com", Repository = "https://github.com/lnbits/paywall" }
-dependencies = [ "lnbits>1" ]
+dependencies = [ "lnbits>=1.7.0rc1" ]
[tool.poetry]
package-mode = false
-[tool.uv]
-dev-dependencies = [
+[dependency-groups]
+dev = [
"black",
"pytest-asyncio",
"pytest",
- "mypy",
+ "mypy==1.17.1",
"pre-commit",
"ruff",
"pytest-md",
]
+[tool.poetry.dependencies]
+python = ">=3.10,<3.13"
+
+[tool.uv]
+build-constraint-dependencies = ["scikit-build-core<0.10"]
+
[tool.mypy]
plugins = ["pydantic.mypy"]
### uv.lock
[binary or diff unavailable]
### views.py
@@ -20,7 +20,7 @@ def paywall_renderer():
@paywall_generic_router.get("/")
async def index(request: Request, user: User = Depends(check_user_exists)):
return paywall_renderer().TemplateResponse(
- "paywall/index.html", {"request": request, "user": user.json()}
+ "paywall/index.html", {"request": request, "user": user.model_dump_json()}
)
@@ -31,7 +31,8 @@ async def display(request: Request, paywall_id: str):
raise HTTPException(
status_code=HTTPStatus.NOT_FOUND, detail="Paywall does not exist."
)
- public_paywall = PublicPaywall(**paywall.dict())
+ public_paywall = PublicPaywall(**paywall.model_dump())
return paywall_renderer().TemplateResponse(
- "paywall/display.html", {"request": request, "paywall": public_paywall.json()}
+ "paywall/display.html",
+ {"request": request, "paywall": public_paywall.model_dump_json()},
)
### views_api.py
@@ -79,7 +79,7 @@ async def api_paywall_update(
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN, detail="Not your paywall."
)
- for k, v in data.dict().items():
+ for k, v in data.model_dump().items():
setattr(paywall, k, v)
await update_paywall(paywall)
return paywallWhy this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.