Lnurlp: use unhashed_description instead of description_hash (#878)

* dont assume field

* pass unhashed_description instead of description_hash for LNURL stuff

* more
This commit is contained in:
calle 2022-08-14 21:59:36 +02:00 committed by GitHub
parent 3df66334db
commit 0f760bf39e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 10 additions and 8 deletions

View File

@ -73,7 +73,7 @@ async def lnurl_callback(
wallet_id=cp.wallet,
amount=int(amount_received / 1000),
memo=cp.lnurl_title,
description_hash=(
unhashed_description=(
LnurlPayMetadata(json.dumps([["text/plain", str(cp.lnurl_title)]]))
).encode("utf-8"),
extra={"tag": "copilot", "copilotid": cp.id, "comment": comment},

View File

@ -90,7 +90,7 @@ async def lnurl_callback(
wallet_id=ls.wallet,
amount=int(amount_received / 1000),
memo=await track.fullname(),
description_hash=(await track.lnurlpay_metadata()).encode("utf-8"),
unhashed_description=(await track.lnurlpay_metadata()).encode("utf-8"),
extra={"tag": "livestream", "track": track.id, "comment": comment},
)

View File

@ -205,7 +205,7 @@ async def lnurl_callback(
wallet_id=device.wallet,
amount=lnurldevicepayment.sats / 1000,
memo=device.title,
description_hash=(await device.lnurlpay_metadata()).encode("utf-8"),
unhashed_description=(await device.lnurlpay_metadata()).encode("utf-8"),
extra={"tag": "PoS"},
)
lnurldevicepayment = await update_lnurldevicepayment(

View File

@ -87,7 +87,7 @@ async def api_lnurl_callback(request: Request, link_id):
wallet_id=link.wallet,
amount=int(amount_received / 1000),
memo=link.description,
description_hash=link.lnurlpay_metadata.encode("utf-8"),
unhashed_description=link.lnurlpay_metadata.encode("utf-8"),
extra={
"tag": "lnurlp",
"link": link.id,

View File

@ -73,7 +73,7 @@ async def lnurl_callback(request: Request, item_id: int):
wallet_id=shop.wallet,
amount=int(amount_received / 1000),
memo=item.name,
description_hash=(await item.lnurlpay_metadata()).encode("utf-8"),
unhashed_description=(await item.lnurlpay_metadata()).encode("utf-8"),
extra={"tag": "offlineshop", "item": item.id},
)
except Exception as exc:

View File

@ -77,7 +77,7 @@ async def api_lnurlp_callback(
wallet_id=link.wallet,
amount=int(amount_received / 1000),
memo="Satsdice bet",
description_hash=link.lnurlpay_metadata.encode("utf-8"),
unhashed_description=link.lnurlpay_metadata.encode("utf-8"),
extra={"tag": "satsdice", "link": link.id, "comment": "comment"},
)

View File

@ -87,8 +87,10 @@ class CoreLightningWallet(Wallet):
label = "lbl{}".format(random.random())
msat: int = int(amount * 1000)
try:
if description_hash:
raise Unsupported("description_hash")
if description_hash and not unhashed_description:
raise Unsupported(
"'description_hash' unsupported by CLN, provide 'unhashed_description'"
)
if unhashed_description and not self.supports_description_hash:
raise Unsupported("unhashed_description")
r = self.ln.invoice(