mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-19 03:57:29 +02:00
Merge pull request #1140 from motorina0/fix_cln_unhashed_description
fix: allow both `description_hash` and `unhashed_description` to be present
This commit is contained in:
@@ -155,30 +155,29 @@ class CreateInvoiceData(BaseModel):
|
|||||||
|
|
||||||
|
|
||||||
async def api_payments_create_invoice(data: CreateInvoiceData, wallet: Wallet):
|
async def api_payments_create_invoice(data: CreateInvoiceData, wallet: Wallet):
|
||||||
if data.description_hash:
|
if data.description_hash or data.unhashed_description:
|
||||||
try:
|
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:
|
except binascii.Error:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.BAD_REQUEST,
|
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 = ""
|
memo = ""
|
||||||
else:
|
else:
|
||||||
description_hash = b""
|
description_hash = b""
|
||||||
unhashed_description = b""
|
unhashed_description = b""
|
||||||
memo = data.memo or LNBITS_SITE_TITLE
|
memo = data.memo or LNBITS_SITE_TITLE
|
||||||
|
|
||||||
if data.unit == "sat":
|
if data.unit == "sat":
|
||||||
amount = int(data.amount)
|
amount = int(data.amount)
|
||||||
else:
|
else:
|
||||||
|
Reference in New Issue
Block a user