From e0fc3c89d106cc1cd4d92dd93104d0dbd72436fd Mon Sep 17 00:00:00 2001 From: Vlad Stan Date: Tue, 7 Jul 2026 13:36:17 +0300 Subject: [PATCH] refactor: checks --- lnbits/core/wasm_ext/api/host.py | 18 ++++++++---------- lnbits/core/wasm_ext/api/models.py | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lnbits/core/wasm_ext/api/host.py b/lnbits/core/wasm_ext/api/host.py index 1e9dc8852..4ff6f9742 100644 --- a/lnbits/core/wasm_ext/api/host.py +++ b/lnbits/core/wasm_ext/api/host.py @@ -201,16 +201,14 @@ class ExtensionHostAPI: from lnbits.core.models.payments import CreateInvoice from lnbits.core.services.payments import create_payment_request - if self.user_id: - wallet = await get_wallet(request.wallet_id) - if wallet is None or wallet.user != self.user_id: - raise PermissionError( - "Creating an invoice for this wallet requires an " - "authenticated user context." - ) - else: - pass - # todo: security stuff here + if not self.user_id: + raise PermissionError( + "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: + raise PermissionError("Not your wallet.") payment = await create_payment_request( request.wallet_id, diff --git a/lnbits/core/wasm_ext/api/models.py b/lnbits/core/wasm_ext/api/models.py index 7f71ddcdc..d8d89e1f5 100644 --- a/lnbits/core/wasm_ext/api/models.py +++ b/lnbits/core/wasm_ext/api/models.py @@ -116,7 +116,7 @@ class CreateInvoiceRequest(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) currency: str = Field(..., min_length=1, max_length=8) memo: str = Field("", max_length=512)