mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-03-15 12:20:21 +01:00
fix: phoenixd wallet description field supports lnurlp (#2514)
* Fix for phoenixd and lnurlp nostr usage - Support description, restricted to 128 characters - Support descriptionHash Co-authored-by: Pavol Rusnak <pavol@rusnak.io> Co-authored-by: Vic <vic@example.com>
This commit is contained in:
parent
2db5a83f4e
commit
83b89851a5
1 changed files with 15 additions and 4 deletions
|
@ -1,5 +1,6 @@
|
|||
import asyncio
|
||||
import base64
|
||||
import hashlib
|
||||
import json
|
||||
import urllib.parse
|
||||
from typing import AsyncGenerator, Dict, Optional
|
||||
|
@ -17,7 +18,6 @@ from .base import (
|
|||
PaymentStatus,
|
||||
PaymentSuccessStatus,
|
||||
StatusResponse,
|
||||
UnsupportedError,
|
||||
Wallet,
|
||||
)
|
||||
|
||||
|
@ -87,17 +87,28 @@ class PhoenixdWallet(Wallet):
|
|||
unhashed_description: Optional[bytes] = None,
|
||||
**kwargs,
|
||||
) -> InvoiceResponse:
|
||||
if description_hash or unhashed_description:
|
||||
raise UnsupportedError("description_hash")
|
||||
|
||||
try:
|
||||
msats_amount = amount
|
||||
data: Dict = {
|
||||
"amountSat": f"{msats_amount}",
|
||||
"description": memo,
|
||||
"externalId": "",
|
||||
}
|
||||
|
||||
# Either 'description' (string) or 'descriptionHash' must be supplied
|
||||
# PhoenixD description limited to 128 characters
|
||||
if description_hash:
|
||||
data["descriptionHash"] = description_hash.hex()
|
||||
else:
|
||||
desc = memo
|
||||
if desc is None and unhashed_description:
|
||||
desc = unhashed_description.decode()
|
||||
desc = desc or ""
|
||||
if len(desc) > 128:
|
||||
data["descriptionHash"] = hashlib.sha256(desc.encode()).hexdigest()
|
||||
else:
|
||||
data["description"] = desc
|
||||
|
||||
r = await self.client.post(
|
||||
"/createinvoice",
|
||||
data=data,
|
||||
|
|
Loading…
Add table
Reference in a new issue