refactor: checks
This commit is contained in:
@@ -201,16 +201,14 @@ class ExtensionHostAPI:
|
|||||||
from lnbits.core.models.payments import CreateInvoice
|
from lnbits.core.models.payments import CreateInvoice
|
||||||
from lnbits.core.services.payments import create_payment_request
|
from lnbits.core.services.payments import create_payment_request
|
||||||
|
|
||||||
if self.user_id:
|
if not self.user_id:
|
||||||
wallet = await get_wallet(request.wallet_id)
|
raise PermissionError(
|
||||||
if wallet is None or wallet.user != self.user_id:
|
"Creating an invoice for this wallet requires an "
|
||||||
raise PermissionError(
|
"authenticated user context."
|
||||||
"Creating an invoice for this wallet requires an "
|
)
|
||||||
"authenticated user context."
|
wallet = await get_wallet(request.wallet_id)
|
||||||
)
|
if wallet is None or wallet.user != self.user_id:
|
||||||
else:
|
raise PermissionError("Not your wallet.")
|
||||||
pass
|
|
||||||
# todo: security stuff here
|
|
||||||
|
|
||||||
payment = await create_payment_request(
|
payment = await create_payment_request(
|
||||||
request.wallet_id,
|
request.wallet_id,
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class CreateInvoiceRequest(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
class CreateInvoicePublicRequest(BaseModel):
|
class CreateInvoicePublicRequest(BaseModel):
|
||||||
source_id: str = Field(..., min_length=1, max_length=512)
|
source_id: str = Field(..., min_length=1, max_length=512, description="The source ID (entry id) of the wallet to create the invoice for.")
|
||||||
amount: float = Field(..., gt=0)
|
amount: float = Field(..., gt=0)
|
||||||
currency: str = Field(..., min_length=1, max_length=8)
|
currency: str = Field(..., min_length=1, max_length=8)
|
||||||
memo: str = Field("", max_length=512)
|
memo: str = Field("", max_length=512)
|
||||||
|
|||||||
Reference in New Issue
Block a user