From eac55e9662770caf1ce2392055ac581d52bf4e91 Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Mon, 28 Nov 2022 17:51:29 +0200 Subject: [PATCH] fix: force default value initialisation --- lnbits/extensions/satspay/crud.py | 1 + lnbits/extensions/satspay/models.py | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lnbits/extensions/satspay/crud.py b/lnbits/extensions/satspay/crud.py index 7e34f6f8..bc364323 100644 --- a/lnbits/extensions/satspay/crud.py +++ b/lnbits/extensions/satspay/crud.py @@ -16,6 +16,7 @@ from .models import Charges, CreateCharge, SatsPayThemes async def create_charge(user: str, data: CreateCharge) -> Charges: + data = CreateCharge(**data.dict()) charge_id = urlsafe_short_hash() if data.onchainwallet: config = await get_config(user) diff --git a/lnbits/extensions/satspay/models.py b/lnbits/extensions/satspay/models.py index cfb3c7ac..0b2b1473 100644 --- a/lnbits/extensions/satspay/models.py +++ b/lnbits/extensions/satspay/models.py @@ -6,6 +6,10 @@ from typing import Optional from fastapi.param_functions import Query from pydantic import BaseModel +DEFAULT_MEMPOOL_CONFIG = ( + '{"mempool_endpoint": "https://mempool.space", "network": "Mainnet"}' +) + class CreateCharge(BaseModel): onchainwallet: str = Query(None) @@ -17,7 +21,7 @@ class CreateCharge(BaseModel): custom_css: Optional[str] time: int = Query(..., ge=1) amount: int = Query(..., ge=1) - extra: str = "{}" + extra: str = DEFAULT_MEMPOOL_CONFIG class ChargeConfig(BaseModel): @@ -38,8 +42,8 @@ class Charges(BaseModel): webhook: Optional[str] completelink: Optional[str] completelinktext: Optional[str] = "Back to Merchant" - extra: str = "{}" custom_css: Optional[str] + extra: str = DEFAULT_MEMPOOL_CONFIG time: int amount: int balance: int