lnrouter: LiquidityHints: add comment to update_liquidity_hints
What changed, and why it matters
This commit only renames an internal method from update_inflight_htlcs to update_num_inflight_htlcs and expands a code comment explaining how Lightning Network payment routing hints are updated. There are no functional code changes and no security relevance.
No action needed; this is a documentation and naming-only change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff is a non-functional refactor: a method rename propagated through callers in lnworker.py, plus a docstring/comment rewrite for update_liquidity_hints. No logic, behavior, or data-flow changes are introduced.
Changed components
electrum/lnrouter.pyelectrum/lnworker.pyInspect captured patch +13 / −9
diff --git a/electrum/lnrouter.py b/electrum/lnrouter.py
index 2768289..023395a 100644
--- a/electrum/lnrouter.py
+++ b/electrum/lnrouter.py
@@ -428,12 +428,16 @@ class LNPathFinder(Logger):
self,
route: LNPaymentRoute,
amount_msat: int,
- failing_channel: ShortChannelID=None
+ failing_channel: ShortChannelID = None,
):
- # go through the route and record successes until the failing channel is reached,
- # for the failing channel, add a cannot_send liquidity hint
- # note: actual routable amounts are slightly different than reported here
- # as fees would need to be added
+ """We mark all channels along the route as able to forward the amount, until
+ the failing channel is reached. For the failing channel, add a cannot_send liquidity hint.
+ In the case of success (failing_channel=None), we still mark channels of the route
+ as being able to send the same amount in the future, as we assume to not know the capacity.
+
+ note: actual routable amounts are slightly different than reported here
+ as fees would need to be added.
+ """
for r in route:
if r.short_channel_id != failing_channel:
self.logger.info(f"report {r.short_channel_id} to be able to forward {amount_msat} msat")
@@ -445,7 +449,7 @@ class LNPathFinder(Logger):
else:
assert failing_channel is None
- def update_inflight_htlcs(self, route: LNPaymentRoute, *, add_htlcs: bool) -> None:
+ def update_num_inflight_htlcs(self, route: LNPaymentRoute, *, add_htlcs: bool) -> None:
self.logger.info(f"{'Adding' if add_htlcs else 'Removing'} inflight htlcs to graph (liquidity hints).")
for r in route:
if add_htlcs:
diff --git a/electrum/lnworker.py b/electrum/lnworker.py
index 96995a9..5639cb4 100644
--- a/electrum/lnworker.py
+++ b/electrum/lnworker.py
@@ -2161,7 +2161,7 @@ class LNWallet(Logger):
self.active_forwardings[fw_payment_key].append(htlc_key)
if self.network.path_finder:
# add inflight htlcs to liquidity hints; removed again in htlc_fulfilled/htlc_failed
- self.network.path_finder.update_inflight_htlcs(shi.route, add_htlcs=True)
+ self.network.path_finder.update_num_inflight_htlcs(shi.route, add_htlcs=True)
util.trigger_callback('htlc_added', chan, htlc, SENT)
def handle_error_code_from_failed_htlc(
@@ -3160,7 +3160,7 @@ class LNWallet(Logger):
chan.pop_onion_key(htlc_id)
if self.network.path_finder:
self.network.path_finder.update_liquidity_hints(shi.route, shi.amount_receiver_msat)
- self.network.path_finder.update_inflight_htlcs(shi.route, add_htlcs=False)
+ self.network.path_finder.update_num_inflight_htlcs(shi.route, add_htlcs=False)
payment_key = payment_hash + shi.payment_secret_orig
paysession = self._paysessions[payment_key]
q = paysession.sent_htlcs_q
@@ -3208,7 +3208,7 @@ class LNWallet(Logger):
if shi and htlc_id in chan.onion_keys:
onion_key = chan.pop_onion_key(htlc_id)
if self.network.path_finder:
- self.network.path_finder.update_inflight_htlcs(shi.route, add_htlcs=False)
+ self.network.path_finder.update_num_inflight_htlcs(shi.route, add_htlcs=False)
payment_okey = payment_hash + shi.payment_secret_orig
paysession = self._paysessions[payment_okey]
q = paysession.sent_htlcs_q
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.