Wallets/unhashed_description (#870)

* new argument: unhashed_description

* accept in api

* set unhashed_description for memo case

* bolt11.py: dont be like CLN, accept the hash

* send hash to lnd in b64

* fix cln

* skip descr_hash for cln

* skip

* format
This commit is contained in:
calle 2022-08-13 14:29:04 +02:00 committed by GitHub
parent 3457ff101e
commit e5d8c500d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 101 additions and 21 deletions

View file

@ -11,6 +11,7 @@ from lnbits.core.views.api import (
api_payment,
api_payments_create_invoice,
)
from lnbits.settings import wallet_class
from ...helpers import get_random_invoice_data
@ -192,11 +193,32 @@ async def test_api_payment_with_key(invoice, inkey_headers_from):
# check POST /api/v1/payments: invoice creation with a description hash
@pytest.mark.skipif(
wallet_class.__name__ in ["CoreLightningWallet"],
reason="wallet does not support description_hash",
)
@pytest.mark.asyncio
async def test_create_invoice_with_description_hash(client, inkey_headers_to):
data = await get_random_invoice_data()
descr_hash = hashlib.sha256("asdasdasd".encode("utf-8")).hexdigest()
data["description_hash"] = "asdasdasd".encode("utf-8").hex()
data["description_hash"] = descr_hash
response = await client.post(
"/api/v1/payments", json=data, headers=inkey_headers_to
)
invoice = response.json()
invoice_bolt11 = bolt11.decode(invoice["payment_request"])
assert invoice_bolt11.description_hash == descr_hash
assert invoice_bolt11.description is None
return invoice
@pytest.mark.asyncio
async def test_create_invoice_with_unhashed_description(client, inkey_headers_to):
data = await get_random_invoice_data()
descr_hash = hashlib.sha256("asdasdasd".encode("utf-8")).hexdigest()
data["unhashed_description"] = "asdasdasd".encode("utf-8").hex()
response = await client.post(
"/api/v1/payments", json=data, headers=inkey_headers_to