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
|
|
|
|
2022-07-07 14:30:16 +02:00
|
|
|
DEBUG = env.bool("DEBUG", default=False)
|
|
|
|
|
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()
|
2022-07-17 14:34:25 +02:00
|
|
|
FAKE_WALLET = getattr(wallets_module, "FakeWallet")()
|
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)
|
|
|
|
|
2022-08-13 20:19:08 +02:00
|
|
|
RESERVE_FEE_MIN = env.int("LNBITS_RESERVE_FEE_MIN", default=2000)
|
|
|
|
RESERVE_FEE_PERCENT = env.float("LNBITS_RESERVE_FEE_PERCENT", default=1.0)
|
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"
|
Boltz.exchange Extension (#922)
* initial commit and still draft, ready for review
* forgot to uncomment this line
* fee estimation and blockheight
* resolve conversation with michael, to use mempool websockets instead of boltz status event
* Update lnbits/extensions/boltz/boltz.py
Co-authored-by: michael1011 <me@michael1011.at>
* add status to swaps, add sorting and data into listing
* add swap status checks, change urls to docker test setup, dynamic minimum and maximum limits
* fix docker hosts for development
* add api endpoints to _api_docs
* add wallet name and id, to list and status information
* fix status_update for reverse_swaps
* chore: format with black
* more blackformatting and refactoring create_swap()
* fix variable bug
* check if swap is already refunded
* use create_task instead of ensure_future
* add mempool and boltz urls depending on DEBUG .env
* raise exception in mempool fails
* fix onchain txs, sending funds to wrong address and add a refund address for normal swaps beforehand
* add status to swaps, add sorting and data into listing
* add swap status checks, change urls to docker test setup, dynamic minimum and maximum limits
* add wallet name and id, to list and status information
* fix status_update for reverse_swaps
* chore: format with black
* use create_task instead of ensure_future
* add mempool and boltz urls depending on DEBUG .env
* fix onchain txs, sending funds to wrong address and add a refund address for normal swaps beforehand
* black formatting
* add some logging with loguru, and remove function duplication
* cleanup readme
* updates/suggestions from calle
Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
* remove unused comments
* Update API Endpoints
Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
* un-factor get_boltz_pairs
* added a explaination for the onchain tx
* remove unused template file
* rename api endpoints
* fix isort and prettier
* more verbose logging!!
* add boltz to mock_data.zip
* new mockdata
* remove comment
* better readme
* fix mempool urls
* change /refund /check /status to post requests
* first step in tests2
* add first tests
* change refund,check,status to post requests
* next try on tests
* overall code improvements
* just testing tests
* throw http exceptions in views_api
* require admincheck for refund,check,status and added fastapi documentation for those
* added more tests
* black
* many code improvements
* adding tests
* temp fix test
* fix race condition when pay_invoice fails
* test are working
* add boltz env variables
* add startup check, bugfixes, improvements
* improve on status checking
* remove check_invoice_status
* more fixes and tests
* testing testing testing
* make tests run again inside regtest
* fix bad error :O
* fix postgres boolean bug and add swap test
* Update README.md
Update README.md
Update README.md
Update README.md
* some mypy
* blacked
* the missing commit?
* fix api_docs readme link
* better refunding error catching
fix
* check swaps now also shows pending reverse swap, ui improvements, tooltips
* add backend check for boltz limits
fixup
* many improvements, startup check for swaps working, reverse needs more testing
* little last fixes
* remove unused logic
* fastapi documentation
fixup
* formatting and remove unused tests
* fix test
* fix swapstatus model
* Update lnbits/extensions/boltz/tasks.py
Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
* Update lnbits/extensions/boltz/views_api.py
Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
* balance check msg, format
* fix mypy data override
* fix swapstatus, remove can refund column
* Update lnbits/extensions/boltz/README.md
Co-authored-by: michael1011 <me@michael1011.at>
* empty lines
* fix error message when swap is not found
* remove preimage_hash from database
* fix api_docs html
fix api_docs html
* catch boltz network exceptions better
* formatting
* check for timeout on swap at get request
Co-authored-by: michael1011 <me@michael1011.at>
Co-authored-by: fusion44 <some.fusion@gmail.com>
Co-authored-by: calle <93376500+callebtc@users.noreply.github.com>
2022-08-30 12:51:17 +02:00
|
|
|
|
|
|
|
|
|
|
|
BOLTZ_NETWORK = env.str("BOLTZ_NETWORK", default="main")
|
|
|
|
BOLTZ_URL = env.str("BOLTZ_URL", default="https://boltz.exchange/api")
|
|
|
|
BOLTZ_MEMPOOL_SPACE_URL = env.str(
|
|
|
|
"BOLTZ_MEMPOOL_SPACE_URL", default="https://mempool.space"
|
|
|
|
)
|
|
|
|
BOLTZ_MEMPOOL_SPACE_URL_WS = env.str(
|
|
|
|
"BOLTZ_MEMPOOL_SPACE_URL_WS", default="wss://mempool.space"
|
|
|
|
)
|