This commit is contained in:
ben 2022-11-28 13:13:45 +00:00
parent 746e119046
commit aefd1fad69
3 changed files with 27 additions and 67 deletions

View file

@ -2,7 +2,7 @@ import asyncio
import json import json
from binascii import unhexlify from binascii import unhexlify
from io import BytesIO from io import BytesIO
from typing import Dict, Optional, Tuple, List from typing import Dict, List, Optional, Tuple
from urllib.parse import parse_qs, urlparse from urllib.parse import parse_qs, urlparse
import httpx import httpx
@ -13,27 +13,18 @@ from loguru import logger
from lnbits import bolt11 from lnbits import bolt11
from lnbits.db import Connection from lnbits.db import Connection
from lnbits.decorators import ( from lnbits.decorators import (WalletTypeInfo, get_key_type, require_admin_key,
WalletTypeInfo, require_invoice_key)
get_key_type,
require_admin_key,
require_invoice_key,
)
from lnbits.helpers import url_for, urlsafe_short_hash from lnbits.helpers import url_for, urlsafe_short_hash
from lnbits.requestvars import g from lnbits.requestvars import g
from lnbits.settings import FAKE_WALLET, RESERVE_FEE_MIN, RESERVE_FEE_PERCENT, WALLET from lnbits.settings import (FAKE_WALLET, RESERVE_FEE_MIN, RESERVE_FEE_PERCENT,
WALLET)
from lnbits.wallets.base import PaymentResponse, PaymentStatus from lnbits.wallets.base import PaymentResponse, PaymentStatus
from . import db from . import db
from .crud import ( from .crud import (check_internal, create_payment, delete_wallet_payment,
check_internal, get_wallet, get_wallet_payment, update_payment_details,
create_payment, update_payment_status)
delete_wallet_payment,
get_wallet,
get_wallet_payment,
update_payment_details,
update_payment_status,
)
from .models import Payment from .models import Payment
try: try:

View file

@ -9,10 +9,10 @@ from io import BytesIO
from typing import Dict, List, Optional, Tuple, Union from typing import Dict, List, Optional, Tuple, Union
from urllib.parse import ParseResult, parse_qs, urlencode, urlparse, urlunparse from urllib.parse import ParseResult, parse_qs, urlencode, urlparse, urlunparse
import async_timeout
import httpx import httpx
import pyqrcode import pyqrcode
from fastapi import Depends, Header, Query, Request, WebSocket, WebSocketDisconnect from fastapi import (Depends, Header, Query, Request, WebSocket,
WebSocketDisconnect)
from fastapi.exceptions import HTTPException from fastapi.exceptions import HTTPException
from fastapi.params import Body from fastapi.params import Body
from loguru import logger from loguru import logger
@ -21,44 +21,23 @@ from pydantic.fields import Field
from sse_starlette.sse import EventSourceResponse, ServerSentEvent from sse_starlette.sse import EventSourceResponse, ServerSentEvent
from starlette.responses import HTMLResponse, StreamingResponse from starlette.responses import HTMLResponse, StreamingResponse
import async_timeout
from lnbits import bolt11, lnurl from lnbits import bolt11, lnurl
from lnbits.core.models import Payment, Wallet from lnbits.core.models import Payment, Wallet
from lnbits.decorators import ( from lnbits.decorators import (WalletTypeInfo, get_key_type, require_admin_key,
WalletTypeInfo, require_invoice_key)
get_key_type,
require_admin_key,
require_invoice_key,
)
from lnbits.helpers import url_for, urlsafe_short_hash from lnbits.helpers import url_for, urlsafe_short_hash
from lnbits.settings import LNBITS_ADMIN_USERS, LNBITS_SITE_TITLE, WALLET from lnbits.settings import LNBITS_ADMIN_USERS, LNBITS_SITE_TITLE, WALLET
from lnbits.utils.exchange_rates import ( from lnbits.utils.exchange_rates import (currencies, fiat_amount_as_satoshis,
currencies, satoshis_amount_as_fiat)
fiat_amount_as_satoshis,
satoshis_amount_as_fiat,
)
from .. import core_app, db from .. import core_app, db
from ..crud import ( from ..crud import (create_payment, get_payments, get_standalone_payment,
create_payment, get_total_balance, get_wallet, get_wallet_for_key,
get_payments, save_balance_check, update_payment_status, update_wallet)
get_standalone_payment, from ..services import (InvoiceFailure, PaymentFailure,
get_total_balance, check_transaction_status, create_invoice, pay_invoice,
get_wallet, perform_lnurlauth, websocketManager, websocketUpdater)
get_wallet_for_key,
save_balance_check,
update_payment_status,
update_wallet,
)
from ..services import (
InvoiceFailure,
PaymentFailure,
check_transaction_status,
create_invoice,
pay_invoice,
perform_lnurlauth,
websocketManager,
websocketUpdater,
)
from ..tasks import api_invoice_listeners from ..tasks import api_invoice_listeners

View file

@ -15,24 +15,14 @@ from lnbits.core import db
from lnbits.core.models import User from lnbits.core.models import User
from lnbits.decorators import check_user_exists from lnbits.decorators import check_user_exists
from lnbits.helpers import template_renderer, url_for from lnbits.helpers import template_renderer, url_for
from lnbits.settings import ( from lnbits.settings import (LNBITS_ADMIN_USERS, LNBITS_ALLOWED_USERS,
LNBITS_ADMIN_USERS, LNBITS_CUSTOM_LOGO, LNBITS_SITE_TITLE,
LNBITS_ALLOWED_USERS, SERVICE_FEE)
LNBITS_CUSTOM_LOGO,
LNBITS_SITE_TITLE,
SERVICE_FEE,
)
from ...helpers import get_valid_extensions from ...helpers import get_valid_extensions
from ..crud import ( from ..crud import (create_account, create_wallet, delete_wallet,
create_account, get_balance_check, get_user, save_balance_notify,
create_wallet, update_user_extension)
delete_wallet,
get_balance_check,
get_user,
save_balance_notify,
update_user_extension,
)
from ..services import pay_invoice, redeem_lnurl_withdraw from ..services import pay_invoice, redeem_lnurl_withdraw
core_html_routes: APIRouter = APIRouter(tags=["Core NON-API Website Routes"]) core_html_routes: APIRouter = APIRouter(tags=["Core NON-API Website Routes"])