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
+26
View File
@@ -1,4 +1,12 @@
from __future__ import annotations
# flake8: noqa: F401
import importlib
from typing import Optional
from lnbits.settings import settings
from lnbits.wallets.base import Wallet
from .cliche import ClicheWallet
from .cln import CoreLightningWallet
from .cln import CoreLightningWallet as CLightningWallet
@@ -12,3 +20,21 @@ from .lntips import LnTipsWallet
from .opennode import OpenNodeWallet
from .spark import SparkWallet
from .void import VoidWallet
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:
return WALLET
wallets_module = importlib.import_module("lnbits.wallets")
FAKE_WALLET: Wallet = FakeWallet()
# initialize as fake wallet
WALLET: Wallet = FAKE_WALLET