fix: create public invoice

This commit is contained in:
Vlad Stan
2026-07-09 16:33:09 +03:00
parent 003e2e4bb4
commit dab53a70e4
2 changed files with 7 additions and 6 deletions
+6 -5
View File
@@ -134,6 +134,7 @@ class ExtensionAPI:
self.permissions, self.permission_policies = self._permission_data(permissions) self.permissions, self.permission_policies = self._permission_data(permissions)
self.user_id = user_id self.user_id = user_id
self.wallet_id = wallet_id self.wallet_id = wallet_id
self._uuid = secrets.token_urlsafe(12).replace("-", "_")
def require_permission(self, permission: str | None) -> None: def require_permission(self, permission: str | None) -> None:
if permission and permission not in self.permissions: if permission and permission not in self.permissions:
@@ -299,7 +300,7 @@ class ExtensionAPI:
from lnbits.core.services.payments import create_payment_request from lnbits.core.services.payments import create_payment_request
table, wallet_field = self._public_invoice_wallet_source() table, wallet_field = self._public_invoice_wallet_source()
row = await storage_get_row(self.extension_id, table, request.id) row = await storage_get_row(self.extension_id, table, request.source_id)
if not row: if not row:
raise PermissionError("Public invoice source was not found.") raise PermissionError("Public invoice source was not found.")
@@ -315,7 +316,7 @@ class ExtensionAPI:
memo=request.memo, memo=request.memo,
extra={ extra={
"tag": self.extension_id, "tag": self.extension_id,
"source_id": request.id, "source_id": request.source_id,
}, },
extension=self.extension_id, extension=self.extension_id,
), ),
@@ -364,7 +365,7 @@ class ExtensionAPI:
host_name="random_id", host_name="random_id",
sdk_name="id", sdk_name="id",
description="Create a random extension-local identifier.", description="Create a random extension-local identifier.",
require_auth=True, require_auth=False,
) )
async def system_random_id(self, request: RandomIdRequest) -> RandomIdResponse: async def system_random_id(self, request: RandomIdRequest) -> RandomIdResponse:
return RandomIdResponse( return RandomIdResponse(
@@ -378,7 +379,7 @@ class ExtensionAPI:
host_name="now", host_name="now",
sdk_name="now", sdk_name="now",
description="Return the current Unix timestamp.", description="Return the current Unix timestamp.",
require_auth=True, require_auth=False,
) )
async def system_now(self, request: EmptyRequest) -> NowResponse: async def system_now(self, request: EmptyRequest) -> NowResponse:
return NowResponse(timestamp=int(time.time())) return NowResponse(timestamp=int(time.time()))
@@ -390,7 +391,7 @@ class ExtensionAPI:
host_name="log", host_name="log",
sdk_name="log", sdk_name="log",
description="Write a bounded message to the extension log.", description="Write a bounded message to the extension log.",
require_auth=True, require_auth=False,
) )
async def system_log(self, request: LogRequest) -> LogResponse: async def system_log(self, request: LogRequest) -> LogResponse:
log = getattr(logger, request.level) log = getattr(logger, request.level)
+1 -1
View File
@@ -83,7 +83,7 @@ class CreateInvoiceRequest(BaseModel):
class CreateInvoicePublicRequest(BaseModel): class CreateInvoicePublicRequest(BaseModel):
id: str = Field(..., min_length=1, max_length=512) source_id: str = Field(..., min_length=1, max_length=512)
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)