What changed, and why it matters
This commit fixes a bug in Electrum's Lightning Network payment routing. When splitting a payment into multiple parts, the app was checking each partial route's fees against the entire payment's fee budget instead of that part's fair share. This could cause a payment to silently overspend on fees, or wrongly reject a valid route as too expensive. The fix makes each partial route responsible only for its proportional share of the fee budget.
Users relying on Lightning payments should upgrade to a version containing this commit. Review related multi-part payment tests and consider adding regression tests for fee-budget checks with number_parts > 1.
Security signals we found
Fee-budget logic regression in payment routing
Multi-part Lightning payment fee overpayment possible
Incorrect comparison of full amount/budget against partial route
Potential payment failure or excessive fee acceptance
Evidence from the diff
In electrum/lnworker.py, LNWallet’s local pathfinding compared the full payment amount (amount_msat) and full budget against each candidate route during multi-part payments. The regression, introduced by df5c8c4c9, is corrected by passing part_amount_msat and a budget with fee_msat divided by sc.config.number_parts(). This aligns the per-route fee-budget check with the actual partial amount being routed.
Changed components
electrum/lnworker.pyLNWallet local pathfindingLightning Network payment routingFeeBudgetExceeded handlingInspect captured patch +2 / −2
diff --git a/electrum/lnworker.py b/electrum/lnworker.py
index db5d29f..9681951 100644
--- a/electrum/lnworker.py
+++ b/electrum/lnworker.py
@@ -2524,8 +2524,8 @@ class LNWallet(Logger):
full_path=full_path,
))
if not is_route_within_budget(
- route, budget=budget,
- amount_msat_for_dest=amount_msat,
+ route, budget=budget._replace(fee_msat=budget.fee_msat // sc.config.number_parts()),
+ amount_msat_for_dest=part_amount_msat,
cltv_delta_for_dest=paysession.min_final_cltv_delta):
self.logger.info(f"rejecting route (exceeds budget): {route=}. {budget=}")
raise FeeBudgetExceeded()
Why this scored 63/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.