refactor: fix duplicate keychecker (#2339)

* refactor: fix duplicate keychecker

- refactor KeyChecker to be more approachable
- only 1 sql query needed even if you use `get_key_type`
- rename `WalletType` to `KeyType` wallet type was misleading

fix test

sorting

* fixup!

* revert 404
This commit is contained in:
dni ⚡
2024-05-13 15:26:25 +01:00
committed by GitHub
parent 9f8942a921
commit 6730c6ed67
7 changed files with 101 additions and 177 deletions
+2 -2
View File
@@ -26,11 +26,11 @@ from lnbits.core.models import (
CreateInvoice,
CreateLnurl,
DecodePayment,
KeyType,
Payment,
PaymentFilters,
PaymentHistoryPoint,
Wallet,
WalletType,
)
from lnbits.db import Filters, Page
from lnbits.decorators import (
@@ -252,7 +252,7 @@ async def api_payments_create(
wallet: WalletTypeInfo = Depends(require_invoice_key),
invoice_data: CreateInvoice = Body(...),
):
if invoice_data.out is True and wallet.wallet_type == WalletType.admin:
if invoice_data.out is True and wallet.key_type == KeyType.admin:
if not invoice_data.bolt11:
raise HTTPException(
status_code=HTTPStatus.BAD_REQUEST,