Refactor get walletclass (#1776)

* move `get_wallet_class` to wallets module

* adjust imports, fix type issues

flake8
This commit is contained in:
jackstar12
2023-06-27 16:11:00 +02:00
committed by GitHub
parent 9a0878de19
commit bc55d52ea2
10 changed files with 45 additions and 29 deletions
+7 -17
View File
@@ -341,19 +341,6 @@ def set_cli_settings(**kwargs):
setattr(settings, key, value)
# set wallet class after settings are loaded
def set_wallet_class(class_name: Optional[str] = None):
backend_wallet_class = class_name or settings.lnbits_backend_wallet_class
wallet_class = getattr(wallets_module, backend_wallet_class)
global WALLET
WALLET = wallet_class()
def get_wallet_class():
# wallet_class = getattr(wallets_module, settings.lnbits_backend_wallet_class)
return WALLET
def send_admin_user_to_saas():
if settings.lnbits_saas_callback:
with httpx.Client() as client:
@@ -399,8 +386,11 @@ except:
settings.version = importlib.metadata.version("lnbits")
wallets_module = importlib.import_module("lnbits.wallets")
FAKE_WALLET = getattr(wallets_module, "FakeWallet")()
# initialize as fake wallet
WALLET = FAKE_WALLET
def get_wallet_class():
"""
Backwards compatibility
"""
from lnbits.wallets import get_wallet_class
return get_wallet_class()