diff --git a/.env.example b/.env.example index de9cb3f7..b7fb9f06 100644 --- a/.env.example +++ b/.env.example @@ -6,6 +6,7 @@ PORT=5000 DEBUG=false +# Allow users and admins by user IDs (comma separated list) LNBITS_ALLOWED_USERS="" LNBITS_ADMIN_USERS="" # Extensions only admin can access diff --git a/lnbits/core/views/api.py b/lnbits/core/views/api.py index 8f4072b9..b645b43e 100644 --- a/lnbits/core/views/api.py +++ b/lnbits/core/views/api.py @@ -155,30 +155,29 @@ class CreateInvoiceData(BaseModel): async def api_payments_create_invoice(data: CreateInvoiceData, wallet: Wallet): - if data.description_hash: + if data.description_hash or data.unhashed_description: try: - description_hash = binascii.unhexlify(data.description_hash) + description_hash = ( + binascii.unhexlify(data.description_hash) + if data.description_hash + else b"" + ) + unhashed_description = ( + binascii.unhexlify(data.unhashed_description) + if data.unhashed_description + else b"" + ) except binascii.Error: raise HTTPException( status_code=HTTPStatus.BAD_REQUEST, - detail="'description_hash' must be a valid hex string", + detail="'description_hash' and 'unhashed_description' must be a valid hex strings", ) - unhashed_description = b"" - memo = "" - elif data.unhashed_description: - try: - unhashed_description = binascii.unhexlify(data.unhashed_description) - except binascii.Error: - raise HTTPException( - status_code=HTTPStatus.BAD_REQUEST, - detail="'unhashed_description' must be a valid hex string", - ) - description_hash = b"" memo = "" else: description_hash = b"" unhashed_description = b"" memo = data.memo or LNBITS_SITE_TITLE + if data.unit == "sat": amount = int(data.amount) else: