fix WALLET initialisation

This commit is contained in:
dni ⚡
2022-10-25 09:24:14 +02:00
parent 4e8374ed6d
commit e670b53412
8 changed files with 23 additions and 11 deletions
+2 -1
View File
@@ -11,7 +11,7 @@ from pydantic import BaseModel
from lnbits.db import Connection
from lnbits.helpers import url_for
from lnbits.settings import WALLET
from lnbits.settings import get_wallet_class
from lnbits.wallets.base import PaymentStatus
@@ -163,6 +163,7 @@ class Payment(BaseModel):
f"Checking {'outgoing' if self.is_out else 'incoming'} pending payment {self.checking_id}"
)
WALLET = get_wallet_class()
if self.is_out:
status = await WALLET.get_payment_status(self.checking_id)
else:
+3 -2
View File
@@ -21,7 +21,7 @@ from lnbits.decorators import (
)
from lnbits.helpers import url_for, urlsafe_short_hash
from lnbits.requestvars import g
from lnbits.settings import FAKE_WALLET, WALLET, settings
from lnbits.settings import FAKE_WALLET, get_wallet_class, settings
from lnbits.wallets.base import PaymentResponse, PaymentStatus
from . import db
@@ -65,7 +65,7 @@ async def create_invoice(
invoice_memo = None if description_hash else memo
# use the fake wallet if the invoice is for internal use only
wallet = FAKE_WALLET if internal else WALLET
wallet = FAKE_WALLET if internal else get_wallet_class()
ok, checking_id, payment_request, error_message = await wallet.create_invoice(
amount=amount,
@@ -193,6 +193,7 @@ async def pay_invoice(
else:
logger.debug(f"backend: sending payment {temp_id}")
# actually pay the external invoice
WALLET = get_wallet_class()
payment: PaymentResponse = await WALLET.pay_invoice(
payment_request, fee_reserve_msat
)
+2 -2
View File
@@ -30,7 +30,7 @@ from lnbits.decorators import (
require_invoice_key,
)
from lnbits.helpers import url_for, urlsafe_short_hash
from lnbits.settings import WALLET, settings
from lnbits.settings import get_wallet_class, settings
from lnbits.utils.exchange_rates import (
currencies,
fiat_amount_as_satoshis,
@@ -682,7 +682,7 @@ async def api_auditor(wallet: WalletTypeInfo = Depends(get_key_type)):
raise HTTPException(
status_code=HTTPStatus.FORBIDDEN, detail="Not an admin user"
)
WALLET = get_wallet_class()
total_balance = await get_total_balance()
error_message, node_balance = await WALLET.status()