What changed, and why it matters
This is a one-line fix in Electrum's Lightning Network code. It adjusts when Electrum considers the first part of a trampoline payment 'complete' by subtracting JIT (just-in-time) channel opening fees from the amount being forwarded. Without the fix, a trampoline payment stage could be incorrectly marked complete too early, potentially causing accounting or routing issues. The commit message frames it as a bug fix, not a security issue, and no security impact is directly stated.
Review the broader trampoline and JIT fee handling to confirm this fix fully addresses the underlying accounting issue. Monitor for related follow-up commits or bug reports. No immediate emergency action is indicated based solely on this diff.
Security signals we found
Logic correction in payment state transition
Financial/accounting-related code path in Lightning routing
Partial fix (single condition) without broader context
Evidence from the diff
In electrum/lnpeer.py, the condition for marking the first stage of a trampoline payment as complete is changed from amount_msat >= any_trampoline_onion.amt_to_forward to amount_msat >= (any_trampoline_onion.amt_to_forward - jit_opening_fees_msat). This ensures that just-in-time (JIT) channel opening fees are accounted for before the parent trampoline payment key is set. The change is minimal and appears to correct a logic error where fees were not deducted for trampoline payments, potentially leading to premature state transitions.
Changed components
electrum/lnpeer.pyLightning Network trampoline payment handlingJIT channel opening fee logicInspect captured patch +1 / −1
diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
index 22aa8a4..eaaddac 100644
--- a/electrum/lnpeer.py
+++ b/electrum/lnpeer.py
@@ -3095,7 +3095,7 @@ class Peer(Logger, EventListener):
if trampoline_payment_key and trampoline_payment_key != payment_key:
# first stage of trampoline payment, the first stage must never get set COMPLETE
- if amount_msat >= any_trampoline_onion.amt_to_forward:
+ if amount_msat >= (any_trampoline_onion.amt_to_forward - jit_opening_fees_msat):
# setting the parent key will mark the htlcs to be moved to the parent set
self.logger.debug(f"trampoline part complete. {len(mpp_set.htlcs)=}, "
f"{amount_msat=}. setting parent key: {trampoline_payment_key}")
Why this scored 41/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.