2023-06-27 16:11:00 +02:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
import importlib
|
|
|
|
from typing import Optional
|
|
|
|
|
2023-09-25 15:04:44 +02:00
|
|
|
from lnbits.nodes import set_node_class
|
2023-06-27 16:11:00 +02:00
|
|
|
from lnbits.settings import settings
|
|
|
|
from lnbits.wallets.base import Wallet
|
|
|
|
|
2023-11-14 11:28:25 -08:00
|
|
|
from .alby import AlbyWallet
|
2022-07-31 23:51:57 +01:00
|
|
|
from .cliche import ClicheWallet
|
2023-08-23 08:59:39 +02:00
|
|
|
from .corelightning import CoreLightningWallet
|
2023-11-06 10:20:26 +01:00
|
|
|
|
|
|
|
# The following import is intentional to keep backwards compatibility
|
|
|
|
# for old configs that called it CLightningWallet. Do not remove.
|
2023-08-23 08:59:39 +02:00
|
|
|
from .corelightning import CoreLightningWallet as CLightningWallet
|
|
|
|
from .corelightningrest import CoreLightningRestWallet
|
2022-04-29 11:39:27 +01:00
|
|
|
from .eclair import EclairWallet
|
|
|
|
from .fake import FakeWallet
|
2020-05-04 17:34:53 +02:00
|
|
|
from .lnbits import LNbitsWallet
|
2022-08-09 11:49:39 +02:00
|
|
|
from .lndgrpc import LndWallet
|
2020-04-25 22:11:27 +01:00
|
|
|
from .lndrest import LndRestWallet
|
2022-04-29 11:39:27 +01:00
|
|
|
from .lnpay import LNPayWallet
|
2022-10-10 16:12:06 +02:00
|
|
|
from .lntips import LnTipsWallet
|
2022-04-29 11:39:27 +01:00
|
|
|
from .opennode import OpenNodeWallet
|
2020-08-29 12:23:01 -03:00
|
|
|
from .spark import SparkWallet
|
2022-04-29 11:39:27 +01:00
|
|
|
from .void import VoidWallet
|
2023-06-27 16:11:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
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()
|
2023-09-25 15:04:44 +02:00
|
|
|
if WALLET.__node_cls__:
|
|
|
|
set_node_class(WALLET.__node_cls__(WALLET))
|
2023-06-27 16:11:00 +02:00
|
|
|
|
|
|
|
|
|
|
|
def get_wallet_class() -> Wallet:
|
|
|
|
return WALLET
|
|
|
|
|
|
|
|
|
|
|
|
wallets_module = importlib.import_module("lnbits.wallets")
|
2023-09-25 15:04:44 +02:00
|
|
|
FAKE_WALLET = FakeWallet()
|
2023-06-27 16:11:00 +02:00
|
|
|
|
|
|
|
# initialize as fake wallet
|
|
|
|
WALLET: Wallet = FAKE_WALLET
|