refactor: fix imports
This commit is contained in:
@@ -9,6 +9,7 @@ from typing import Any
|
||||
|
||||
from lnbits.helpers import sha256s
|
||||
|
||||
from ..client.extensions import send_extension_api_request
|
||||
from ..storage.crud import (
|
||||
storage_delete_row,
|
||||
storage_get_paginated_rows,
|
||||
@@ -425,7 +426,6 @@ class ExtensionHostAPI:
|
||||
require_auth=True,
|
||||
)
|
||||
async def extension_api_request(self, request: ExtensionApiRequest) -> HttpResponse:
|
||||
from ..client.extensions import send_extension_api_request
|
||||
|
||||
policies = self.permission_policies.get("extension.api.request") or []
|
||||
return await send_extension_api_request(
|
||||
|
||||
@@ -4,6 +4,16 @@ import time
|
||||
from datetime import datetime
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
from lnbits import bolt11
|
||||
from lnbits.settings import settings
|
||||
from lnbits.utils.crypto import random_secret_and_hash, verify_preimage
|
||||
from lnbits.utils.exchange_rates import (
|
||||
allowed_currencies,
|
||||
fiat_amount_as_satoshis,
|
||||
get_fiat_rate_and_price_satoshis,
|
||||
satoshis_amount_as_fiat,
|
||||
)
|
||||
|
||||
from .models import (
|
||||
Bolt11Request,
|
||||
CurrencyConvertRequest,
|
||||
@@ -60,7 +70,6 @@ class ExtensionCurrencyUtils(_ExtensionAPIUtilsGroup):
|
||||
require_auth=False,
|
||||
)
|
||||
async def list(self, request: EmptyRequest) -> CurrencyListResponse:
|
||||
from lnbits.utils.exchange_rates import allowed_currencies
|
||||
|
||||
return CurrencyListResponse(currencies=allowed_currencies())
|
||||
|
||||
@@ -76,7 +85,6 @@ class ExtensionCurrencyUtils(_ExtensionAPIUtilsGroup):
|
||||
require_auth=False,
|
||||
)
|
||||
async def rate(self, request: CurrencyRateRequest) -> CurrencyRateResponse:
|
||||
from lnbits.utils.exchange_rates import get_fiat_rate_and_price_satoshis
|
||||
|
||||
rate, price = await get_fiat_rate_and_price_satoshis(request.currency)
|
||||
return CurrencyRateResponse(rate=rate, price=price)
|
||||
@@ -93,10 +101,6 @@ class ExtensionCurrencyUtils(_ExtensionAPIUtilsGroup):
|
||||
require_auth=False,
|
||||
)
|
||||
async def convert(self, request: CurrencyConvertRequest) -> CurrencyConvertResponse:
|
||||
from lnbits.utils.exchange_rates import (
|
||||
fiat_amount_as_satoshis,
|
||||
satoshis_amount_as_fiat,
|
||||
)
|
||||
|
||||
from_currency = request.from_currency
|
||||
if from_currency == "sats":
|
||||
@@ -135,7 +139,6 @@ class ExtensionCurrencyUtils(_ExtensionAPIUtilsGroup):
|
||||
require_auth=False,
|
||||
)
|
||||
async def fiat_to_sats(self, request: FiatToSatsRequest) -> FiatToSatsResponse:
|
||||
from lnbits.utils.exchange_rates import fiat_amount_as_satoshis
|
||||
|
||||
return FiatToSatsResponse(
|
||||
amount_sat=await fiat_amount_as_satoshis(
|
||||
@@ -156,7 +159,6 @@ class ExtensionCurrencyUtils(_ExtensionAPIUtilsGroup):
|
||||
require_auth=False,
|
||||
)
|
||||
async def sats_to_fiat(self, request: SatsToFiatRequest) -> SatsToFiatResponse:
|
||||
from lnbits.utils.exchange_rates import satoshis_amount_as_fiat
|
||||
|
||||
return SatsToFiatResponse(
|
||||
amount=await satoshis_amount_as_fiat(request.amount, request.currency)
|
||||
@@ -176,7 +178,6 @@ class ExtensionServerUtils(_ExtensionAPIUtilsGroup):
|
||||
require_auth=False,
|
||||
)
|
||||
async def health(self, request: EmptyRequest) -> ServerHealthResponse:
|
||||
from lnbits.settings import settings
|
||||
|
||||
return ServerHealthResponse(
|
||||
server_time=int(time.time()),
|
||||
@@ -298,7 +299,6 @@ class ExtensionLightningUtils(_ExtensionAPIUtilsGroup):
|
||||
async def verify_preimage(
|
||||
self, request: VerifyPreimageRequest
|
||||
) -> VerifyPreimageResponse:
|
||||
from lnbits.utils.crypto import verify_preimage
|
||||
|
||||
return VerifyPreimageResponse(
|
||||
valid=verify_preimage(request.preimage, request.payment_hash)
|
||||
@@ -318,7 +318,6 @@ class ExtensionLightningUtils(_ExtensionAPIUtilsGroup):
|
||||
async def random_secret_and_hash(
|
||||
self, request: RandomSecretAndHashRequest
|
||||
) -> RandomSecretAndHashResponse:
|
||||
from lnbits.utils.crypto import random_secret_and_hash
|
||||
|
||||
secret, payment_hash = random_secret_and_hash(request.length)
|
||||
return RandomSecretAndHashResponse(secret=secret, hash=payment_hash)
|
||||
@@ -333,7 +332,6 @@ def extension_api_utils_method_classes() -> dict[str, type[_ExtensionAPIUtilsGro
|
||||
|
||||
|
||||
def _decode_bolt11(payment_request: str) -> Any:
|
||||
from lnbits import bolt11
|
||||
|
||||
return bolt11.decode(payment_request)
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ from lnbits.core.db import core_app_extra
|
||||
from lnbits.core.wasm_ext.storage.crud import storage_get_row_owner_id
|
||||
from lnbits.core.wasm_ext.wasm.invoke import invoke_wasm_extension_export
|
||||
|
||||
|
||||
async def dispatch_wasm_invoice_paid(payment: Any) -> None:
|
||||
extension_id = _payment_extension_id(payment)
|
||||
if not extension_id:
|
||||
@@ -57,7 +58,6 @@ async def _wasm_invoice_paid_owner_id(extension: Any, payment: Any) -> str | Non
|
||||
if not source_id or not source_tables:
|
||||
return None
|
||||
|
||||
|
||||
for source_table in source_tables:
|
||||
owner_id = await storage_get_row_owner_id(extension.id, source_table, source_id)
|
||||
if owner_id:
|
||||
|
||||
Reference in New Issue
Block a user