What changed, and why it matters
This is a minor code cleanup in Electrum's Lightning Network peer handling. It simplifies how an inner trampoline onion packet is processed, replacing an if-statement with a conditional expression. There is no visible security change: the same operations happen in the same order and with the same conditions as before.
No security action needed. Treat as ordinary code-quality/maintenance review.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff refactors _check_unfulfilled_htlc_set in electrum/lnpeer.py. Previously the code unconditionally assigned processed_onions[mpp_htlc] = (processed_onion, None), then optionally computed inner_onion and reassigned the tuple if a trampoline onion packet existed. The new version computes inner_onion once (using a conditional expression) and assigns the tuple exactly once. The observable behavior is unchanged.
Changed components
electrum/lnpeer.py:_check_unfulfilled_htlc_setInspect captured patch +6 / −9
### electrum/lnpeer.py
@@ -3090,15 +3090,12 @@ def _check_unfulfilled_htlc_set(
payment_hash=payment_hash,
is_trampoline=False, # this is always the outer onion
)
- processed_onions[mpp_htlc] = (processed_onion, None)
- inner_onion = None
- if processed_onion.trampoline_onion_packet:
- inner_onion = self._process_incoming_onion_packet(
- onion_packet=processed_onion.trampoline_onion_packet,
- payment_hash=payment_hash,
- is_trampoline=True,
- )
- processed_onions[mpp_htlc] = (processed_onion, inner_onion)
+ inner_onion = self._process_incoming_onion_packet(
+ onion_packet=processed_onion.trampoline_onion_packet,
+ payment_hash=payment_hash,
+ is_trampoline=True,
+ ) if processed_onion.trampoline_onion_packet else None
+ processed_onions[mpp_htlc] = (processed_onion, inner_onion)
total_msat_outer_onion = processed_onion.total_msat
total_msat_inner_onion = inner_onion.total_msat if inner_onion else NoneWhy this scored 12/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.