2020-03-31 19:05:25 +02:00
|
|
|
import importlib
|
2022-06-08 16:23:36 +02:00
|
|
|
import subprocess
|
2020-09-05 08:00:44 +02:00
|
|
|
from os import path
|
|
|
|
from typing import List
|
|
|
|
|
2022-06-08 16:23:36 +02:00
|
|
|
from environs import Env # type: ignore
|
2020-09-05 08:00:44 +02:00
|
|
|
|
|
|
|
env = Env()
|
|
|
|
env.read_env()
|
2020-01-15 16:19:54 +01:00
|
|
|
|
2020-04-11 19:47:25 +02:00
|
|
|
wallets_module = importlib.import_module("lnbits.wallets")
|
2021-03-24 04:40:32 +01:00
|
|
|
wallet_class = getattr(
|
|
|
|
wallets_module, env.str("LNBITS_BACKEND_WALLET_CLASS", default="VoidWallet")
|
|
|
|
)
|
2020-09-05 08:00:44 +02:00
|
|
|
|
2020-09-15 04:28:10 +02:00
|
|
|
ENV = env.str("QUART_ENV", default="production")
|
2020-09-15 20:54:05 +02:00
|
|
|
DEBUG = env.bool("QUART_DEBUG", default=False) or ENV == "development"
|
2020-09-15 04:28:10 +02:00
|
|
|
HOST = env.str("HOST", default="127.0.0.1")
|
|
|
|
PORT = env.int("PORT", default=5000)
|
|
|
|
|
2020-09-05 08:00:44 +02:00
|
|
|
LNBITS_PATH = path.dirname(path.realpath(__file__))
|
2021-03-24 04:40:32 +01:00
|
|
|
LNBITS_DATA_FOLDER = env.str(
|
|
|
|
"LNBITS_DATA_FOLDER", default=path.join(LNBITS_PATH, "data")
|
|
|
|
)
|
2021-06-22 04:22:52 +02:00
|
|
|
LNBITS_DATABASE_URL = env.str("LNBITS_DATABASE_URL", default=None)
|
|
|
|
|
2021-03-24 04:40:32 +01:00
|
|
|
LNBITS_ALLOWED_USERS: List[str] = env.list(
|
|
|
|
"LNBITS_ALLOWED_USERS", default=[], subcast=str
|
|
|
|
)
|
2022-01-31 17:29:42 +01:00
|
|
|
LNBITS_ADMIN_USERS: List[str] = env.list("LNBITS_ADMIN_USERS", default=[], subcast=str)
|
2022-06-01 14:53:05 +02:00
|
|
|
LNBITS_ADMIN_EXTENSIONS: List[str] = env.list(
|
|
|
|
"LNBITS_ADMIN_EXTENSIONS", default=[], subcast=str
|
|
|
|
)
|
2021-03-24 04:40:32 +01:00
|
|
|
LNBITS_DISABLED_EXTENSIONS: List[str] = env.list(
|
|
|
|
"LNBITS_DISABLED_EXTENSIONS", default=[], subcast=str
|
|
|
|
)
|
2021-06-28 23:57:23 +02:00
|
|
|
|
2022-02-23 14:51:30 +01:00
|
|
|
LNBITS_AD_SPACE = env.list("LNBITS_AD_SPACE", default=[])
|
2022-02-24 13:32:37 +01:00
|
|
|
LNBITS_HIDE_API = env.bool("LNBITS_HIDE_API", default=False)
|
2020-09-05 08:00:44 +02:00
|
|
|
LNBITS_SITE_TITLE = env.str("LNBITS_SITE_TITLE", default="LNbits")
|
2022-02-02 14:07:12 +01:00
|
|
|
LNBITS_DENOMINATION = env.str("LNBITS_DENOMINATION", default="sats")
|
2021-07-02 13:31:05 +02:00
|
|
|
LNBITS_SITE_TAGLINE = env.str(
|
|
|
|
"LNBITS_SITE_TAGLINE", default="free and open-source lightning wallet"
|
|
|
|
)
|
|
|
|
LNBITS_SITE_DESCRIPTION = env.str("LNBITS_SITE_DESCRIPTION", default="")
|
|
|
|
LNBITS_THEME_OPTIONS: List[str] = env.list(
|
|
|
|
"LNBITS_THEME_OPTIONS",
|
|
|
|
default="classic, flamingo, mint, salvador, monochrome, autumn",
|
|
|
|
subcast=str,
|
|
|
|
)
|
2022-06-08 16:23:36 +02:00
|
|
|
LNBITS_CUSTOM_LOGO = env.str("LNBITS_CUSTOM_LOGO", default="")
|
2019-12-18 14:44:58 +01:00
|
|
|
|
2020-03-31 19:05:25 +02:00
|
|
|
WALLET = wallet_class()
|
2020-09-05 08:00:44 +02:00
|
|
|
DEFAULT_WALLET_NAME = env.str("LNBITS_DEFAULT_WALLET_NAME", default="LNbits wallet")
|
2020-09-24 16:44:35 +02:00
|
|
|
PREFER_SECURE_URLS = env.bool("LNBITS_FORCE_HTTPS", default=True)
|
|
|
|
|
2020-09-05 08:00:44 +02:00
|
|
|
SERVICE_FEE = env.float("LNBITS_SERVICE_FEE", default=0.0)
|
2020-10-06 22:42:33 +02:00
|
|
|
|
|
|
|
try:
|
2020-11-11 02:29:52 +01:00
|
|
|
LNBITS_COMMIT = (
|
|
|
|
subprocess.check_output(
|
2021-10-17 19:33:29 +02:00
|
|
|
["git", "-C", LNBITS_PATH, "rev-parse", "HEAD"], stderr=subprocess.DEVNULL
|
2020-11-11 02:29:52 +01:00
|
|
|
)
|
|
|
|
.strip()
|
|
|
|
.decode("ascii")
|
|
|
|
)
|
2020-10-06 22:42:33 +02:00
|
|
|
except:
|
|
|
|
LNBITS_COMMIT = "unknown"
|