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
This commit is contained in:
@@ -1216,19 +1216,21 @@ class LNWallet(LNWorker):
|
||||
"""calculate routing hints (BOLT-11 'r' field)"""
|
||||
routing_hints = []
|
||||
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
|
||||
if chan.short_channel_id is not None}
|
||||
ignore_min_htlc_value = False
|
||||
if amount_sat:
|
||||
amount_msat = 1000 * amount_sat
|
||||
else:
|
||||
# for no amt invoices, check if channel can receive at least 1 msat
|
||||
amount_msat = 1
|
||||
ignore_min_htlc_value = True
|
||||
# note: currently we add *all* our channels; but this might be a privacy leak?
|
||||
for chan in channels:
|
||||
if not chan.can_receive(amount_msat=amount_msat, check_frozen=True,
|
||||
ignore_min_htlc_value=ignore_min_htlc_value):
|
||||
# do minimal filtering of channels.
|
||||
# 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
|
||||
chan_id = chan.short_channel_id
|
||||
assert isinstance(chan_id, bytes), chan_id
|
||||
|
||||
Reference in New Issue
Block a user