[fix] limit the size of the invoice description to 640 characters (#3045)

This commit is contained in:
Vlad Stan 2025-03-12 16:29:29 +02:00 committed by GitHub
parent 475ae5736e
commit b8a5f3942c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -198,7 +198,7 @@ class CreateInvoice(BaseModel):
internal: bool = False internal: bool = False
out: bool = True out: bool = True
amount: float = Query(None, ge=0) amount: float = Query(None, ge=0)
memo: str | None = None memo: str | None = Query(None, max_length=640)
description_hash: str | None = None description_hash: str | None = None
unhashed_description: str | None = None unhashed_description: str | None = None
expiry: int | None = None expiry: int | None = None

View file

@ -108,7 +108,7 @@ async def create_invoice(
if not user_wallet: if not user_wallet:
raise InvoiceError(f"Could not fetch wallet '{wallet_id}'.", status="failed") raise InvoiceError(f"Could not fetch wallet '{wallet_id}'.", status="failed")
invoice_memo = None if description_hash else memo invoice_memo = None if description_hash else memo[:640]
# use the fake wallet if the invoice is for internal use only # use the fake wallet if the invoice is for internal use only
funding_source = fake_wallet if internal else get_funding_source() funding_source = fake_wallet if internal else get_funding_source()