Browse Source

ln invoices: more relaxed filtering of chans to include route hints for

e.g. just because remote peer is temporarily offline, we might still want it
included in the invoice
master
SomberNight 5 years ago
parent
commit
c034219c5a
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 10
      electrum/lnworker.py

10
electrum/lnworker.py

@ -1216,19 +1216,21 @@ class LNWallet(LNWorker):
"""calculate routing hints (BOLT-11 'r' field)""" """calculate routing hints (BOLT-11 'r' field)"""
routing_hints = [] routing_hints = []
channels = list(self.channels.values()) channels = list(self.channels.values())
random.shuffle(channels) # not sure this has any benefit but let's not leak channel order
scid_to_my_channels = {chan.short_channel_id: chan for chan in channels scid_to_my_channels = {chan.short_channel_id: chan for chan in channels
if chan.short_channel_id is not None} if chan.short_channel_id is not None}
ignore_min_htlc_value = False
if amount_sat: if amount_sat:
amount_msat = 1000 * amount_sat amount_msat = 1000 * amount_sat
else: else:
# for no amt invoices, check if channel can receive at least 1 msat # for no amt invoices, check if channel can receive at least 1 msat
amount_msat = 1 amount_msat = 1
ignore_min_htlc_value = True
# note: currently we add *all* our channels; but this might be a privacy leak? # note: currently we add *all* our channels; but this might be a privacy leak?
for chan in channels: for chan in channels:
if not chan.can_receive(amount_msat=amount_msat, check_frozen=True, # do minimal filtering of channels.
ignore_min_htlc_value=ignore_min_htlc_value): # we include channels that cannot *right now* receive (e.g. peer disconnected or balance insufficient)
if not (chan.is_open() and not chan.is_frozen_for_receiving()):
continue
if amount_msat > 1000 * chan.constraints.capacity:
continue continue
chan_id = chan.short_channel_id chan_id = chan.short_channel_id
assert isinstance(chan_id, bytes), chan_id assert isinstance(chan_id, bytes), chan_id

Loading…
Cancel
Save