mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-20 13:04:23 +02:00
fix: force default value initialisation
This commit is contained in:
@@ -16,6 +16,7 @@ from .models import Charges, CreateCharge, SatsPayThemes
|
|||||||
|
|
||||||
|
|
||||||
async def create_charge(user: str, data: CreateCharge) -> Charges:
|
async def create_charge(user: str, data: CreateCharge) -> Charges:
|
||||||
|
data = CreateCharge(**data.dict())
|
||||||
charge_id = urlsafe_short_hash()
|
charge_id = urlsafe_short_hash()
|
||||||
if data.onchainwallet:
|
if data.onchainwallet:
|
||||||
config = await get_config(user)
|
config = await get_config(user)
|
||||||
|
@@ -6,6 +6,10 @@ from typing import Optional
|
|||||||
from fastapi.param_functions import Query
|
from fastapi.param_functions import Query
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
DEFAULT_MEMPOOL_CONFIG = (
|
||||||
|
'{"mempool_endpoint": "https://mempool.space", "network": "Mainnet"}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class CreateCharge(BaseModel):
|
class CreateCharge(BaseModel):
|
||||||
onchainwallet: str = Query(None)
|
onchainwallet: str = Query(None)
|
||||||
@@ -17,7 +21,7 @@ class CreateCharge(BaseModel):
|
|||||||
custom_css: Optional[str]
|
custom_css: Optional[str]
|
||||||
time: int = Query(..., ge=1)
|
time: int = Query(..., ge=1)
|
||||||
amount: int = Query(..., ge=1)
|
amount: int = Query(..., ge=1)
|
||||||
extra: str = "{}"
|
extra: str = DEFAULT_MEMPOOL_CONFIG
|
||||||
|
|
||||||
|
|
||||||
class ChargeConfig(BaseModel):
|
class ChargeConfig(BaseModel):
|
||||||
@@ -38,8 +42,8 @@ class Charges(BaseModel):
|
|||||||
webhook: Optional[str]
|
webhook: Optional[str]
|
||||||
completelink: Optional[str]
|
completelink: Optional[str]
|
||||||
completelinktext: Optional[str] = "Back to Merchant"
|
completelinktext: Optional[str] = "Back to Merchant"
|
||||||
extra: str = "{}"
|
|
||||||
custom_css: Optional[str]
|
custom_css: Optional[str]
|
||||||
|
extra: str = DEFAULT_MEMPOOL_CONFIG
|
||||||
time: int
|
time: int
|
||||||
amount: int
|
amount: int
|
||||||
balance: int
|
balance: int
|
||||||
|
Reference in New Issue
Block a user