lnworker: write rationale for PaymentInfo class in docstring
What changed, and why it matters
This commit only adds explanatory comments (a docstring) to a data class used in Electrum's Lightning payment handling. It does not change any code behavior, fix any bug, or alter any security mechanism. There is no security issue here.
No action needed. This is a documentation-only change with no security relevance.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch expands the docstring of the PaymentInfo dataclass in electrum/lnworker.py to document historical design rationale: previously the code stored full BOLT11 invoices but deserialization was slow, so PaymentInfo now stores parsed fields (payment_hash, amount_msat, direction, status). It also notes that for unpaid incoming requests, the UI can regenerate BOLT11 strings with updated routing hints when displayed. No executable code was modified.
Changed components
electrum/lnworker.pyInspect captured patch +9 / −1
diff --git a/electrum/lnworker.py b/electrum/lnworker.py
index 2d32d7f..c49aa3d 100644
--- a/electrum/lnworker.py
+++ b/electrum/lnworker.py
@@ -118,7 +118,15 @@ class PaymentDirection(IntEnum):
@dataclasses.dataclass(frozen=True, kw_only=True)
class PaymentInfo:
- """Information required to handle incoming htlcs for a payment request"""
+ """Information required to handle incoming htlcs for a payment request.
+
+ - Historically, we used to store "bolt11, direction, status", but deserializing bolt11 was too slow.
+ (even deserializing just once - all bolt11 during wallet-open - was slow)
+ - note: the deserialization code in lnaddr.py has been significantly sped up since
+ - For incoming payments, for unpaid requests, ~every time the user displays the unpaid bolt11,
+ we get a chance to display a new bolt11, with same payment_hash/amount, but with updated
+ routing_hints (channels might get closed/opened, or just liquidity changed drastically).
+ """
payment_hash: bytes
amount_msat: Optional[int]
direction: lnutil.Direction
Why this scored 15/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.