fix(phoenixd): use descriptionHash when unhashed_description is provided (#3913)
What changed, and why it matters
This commit fixes how LNbits' PhoenixD wallet integration handles invoice descriptions. Previously, when a caller provided an 'unhashed_description', the code ignored it and fell back to a short text memo. The fix now correctly hashes that full description and sends it to PhoenixD as a description hash, matching the expected BOLT-11 invoice behavior. This is a correctness fix that prevents invoices from having mismatched or missing descriptions, which could break payment flows or cause wallets to reject invoices.
Review other wallet backends for consistent handling of unhashed_description and description_hash. Ensure integration tests cover cases where unhashed_description is provided without description_hash. No urgent security patch is indicated, but the fix should be included in the next release.
Security signals we found
Data-flow correctness fix: previously ignored user-supplied description data
BOLT-11 description_hash handling alignment
Potential invoice description mismatch could lead to payment failures or user confusion
No explicit security claim by vendor in commit message
Evidence from the diff
In lnbits/wallets/phoenixd.py, the create_invoice logic for building the PhoenixD API payload is corrected. Previously, if description_hash was absent, the code set desc = memo, and only if memo was None did it decode unhashed_description. As a result, when both memo and unhashed_description were present, the unhashed_description was discarded. The patch changes the precedence: if description_hash is provided use it; else if unhashed_description is provided, SHA-256 hash it and set descriptionHash; else fall back to memo (truncated/hashed if over 128 chars). This aligns with how LNbits’ other wallet backends and the BOLT-11 spec treat unhashed_description.
Changed components
lnbits/wallets/phoenixd.pyPhoenixD wallet backendInvoice creation / BOLT-11 description handlingInspect captured patch +5 / −4
diff --git a/lnbits/wallets/phoenixd.py b/lnbits/wallets/phoenixd.py
index e793462..fe84470 100644
--- a/lnbits/wallets/phoenixd.py
+++ b/lnbits/wallets/phoenixd.py
@@ -117,11 +117,12 @@ class PhoenixdWallet(Wallet):
# PhoenixD description limited to 128 characters
if description_hash:
data["descriptionHash"] = description_hash.hex()
+ elif unhashed_description:
+ data["descriptionHash"] = hashlib.sha256(
+ unhashed_description
+ ).hexdigest()
else:
- desc = memo
- if desc is None and unhashed_description:
- desc = unhashed_description.decode()
- desc = desc or ""
+ desc = memo or ""
if len(desc) > 128:
data["descriptionHash"] = hashlib.sha256(desc.encode()).hexdigest()
else:
Why this scored 32/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.