merge main

This commit is contained in:
dni ⚡ 2022-12-01 12:37:08 +01:00
commit 803c9349d4
6 changed files with 21 additions and 8 deletions

View file

@ -6,15 +6,16 @@ PORT=5000
DEBUG=false DEBUG=false
# User IDs seperated by comma # Allow users and admins by user IDs (comma separated list)
LNBITS_ALLOWED_USERS=""
LNBITS_ADMIN_USERS="" LNBITS_ADMIN_USERS=""
# Extensions only admin can access # Extensions only admin can access
LNBITS_ADMIN_EXTENSIONS="ngrok, admin" LNBITS_ADMIN_EXTENSIONS="ngrok, admin"
# Enable Admin GUI, available for the first user in LNBITS_ADMIN_USERS if available # Enable Admin GUI, available for the first user in LNBITS_ADMIN_USERS if available
LNBITS_ADMIN_UI=false LNBITS_ADMIN_UI=false
# Restricts access, User IDs seperated by comma # Restricts access, User IDs seperated by comma
LNBITS_ALLOWED_USERS="" LNBITS_ALLOWED_USERS=""
LNBITS_DEFAULT_WALLET_NAME="LNbits wallet" LNBITS_DEFAULT_WALLET_NAME="LNbits wallet"
@ -110,6 +111,6 @@ LNTIPS_API_KEY=LNTIPS_ADMIN_KEY
LNTIPS_API_ENDPOINT=https://ln.tips LNTIPS_API_ENDPOINT=https://ln.tips
# Cashu Mint # Cashu Mint
# Use a long-enough random (!) private key. # Use a long-enough random (!) private key.
# Once set, you cannot change this key as for now. # Once set, you cannot change this key as for now.
CASHU_PRIVATE_KEY="SuperSecretPrivateKey" CASHU_PRIVATE_KEY="SuperSecretPrivateKey"

View file

@ -86,7 +86,8 @@ class Connection(Compat):
return raw_html return raw_html
# tuple to list and back to tuple # tuple to list and back to tuple
values = tuple([cleanhtml(l) for l in list(values)]) value_list = [values] if isinstance(values, str) else list(values)
values = tuple([cleanhtml(l) for l in value_list])
return values return values
async def fetchall(self, query: str, values: tuple = ()) -> list: async def fetchall(self, query: str, values: tuple = ()) -> list:

View file

@ -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)

View file

@ -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,13 @@ 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"
<<<<<<< HEAD
extra: str = "{}" extra: str = "{}"
custom_css: Optional[str] custom_css: Optional[str]
=======
custom_css: Optional[str]
extra: str = DEFAULT_MEMPOOL_CONFIG
>>>>>>> main
time: int time: int
amount: int amount: int
balance: int balance: int

View file

@ -5,6 +5,7 @@ from fastapi.params import Depends
from loguru import logger from loguru import logger
from starlette.exceptions import HTTPException from starlette.exceptions import HTTPException
from lnbits.core.crud import get_wallet
from lnbits.decorators import ( from lnbits.decorators import (
WalletTypeInfo, WalletTypeInfo,
get_key_type, get_key_type,

View file

@ -203,7 +203,7 @@ async def update_address(id: str, **kwargs) -> Optional[Address]:
f"""UPDATE watchonly.addresses SET {q} WHERE id = ? """, f"""UPDATE watchonly.addresses SET {q} WHERE id = ? """,
(*kwargs.values(), id), (*kwargs.values(), id),
) )
row = await db.fetchone("SELECT * FROM watchonly.addresses WHERE id = ?", (id)) row = await db.fetchone("SELECT * FROM watchonly.addresses WHERE id = ?", (id,))
return Address.from_row(row) if row else None return Address.from_row(row) if row else None