refactor: replace mempool internal API with a more generic config API
This commit is contained in:
@@ -6,7 +6,7 @@ from lnbits.core.services import create_invoice
|
||||
from lnbits.core.views.api import api_payment
|
||||
from lnbits.helpers import urlsafe_short_hash
|
||||
|
||||
from ..watchonly.crud import get_fresh_address, get_mempool, get_watch_wallet
|
||||
from ..watchonly.crud import get_fresh_address, get_config, get_watch_wallet
|
||||
|
||||
# from lnbits.db import open_ext_db
|
||||
from . import db
|
||||
@@ -18,7 +18,6 @@ from .models import Charges, CreateCharge
|
||||
async def create_charge(user: str, data: CreateCharge) -> Charges:
|
||||
charge_id = urlsafe_short_hash()
|
||||
if data.onchainwallet:
|
||||
wallet = await get_watch_wallet(data.onchainwallet)
|
||||
onchain = await get_fresh_address(data.onchainwallet)
|
||||
onchainaddress = onchain.address
|
||||
else:
|
||||
@@ -102,11 +101,11 @@ async def check_address_balance(charge_id: str) -> List[Charges]:
|
||||
charge = await get_charge(charge_id)
|
||||
if not charge.paid:
|
||||
if charge.onchainaddress:
|
||||
mempool = await get_mempool(charge.user)
|
||||
config = await get_config(charge.user)
|
||||
try:
|
||||
async with httpx.AsyncClient() as client:
|
||||
r = await client.get(
|
||||
mempool.endpoint + "/api/address/" + charge.onchainaddress
|
||||
config.mempool_endpoint + "/api/address/" + charge.onchainaddress
|
||||
)
|
||||
respAmount = r.json()["chain_stats"]["funded_txo_sum"]
|
||||
if respAmount >= charge.balance:
|
||||
|
||||
Reference in New Issue
Block a user