Browse Source

LN private route hints: don't include low receive capacity channels

see code comment.

While the balance in the channels might shift before the sender tries to
pay the invoice, as we are not a forwarding node, that seems unlikely to matter.
patch-4
SomberNight 4 years ago
parent
commit
a339338958
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 5
      electrum/lnworker.py

5
electrum/lnworker.py

@ -1912,6 +1912,11 @@ class LNWallet(LNWorker):
# we include channels that cannot *right now* receive (e.g. peer disconnected or balance insufficient)
channels = [chan for chan in channels
if (chan.is_open() and not chan.is_frozen_for_receiving())]
# Filter out channels that have very low receive capacity compared to invoice amt.
# Even with MPP, below a certain threshold, including these channels probably
# hurts more than help, as they lead to many failed attempts for the sender.
channels = [chan for chan in channels
if chan.available_to_spend(REMOTE) > (amount_msat or 0) * 0.05]
# cap max channels to include to keep QR code reasonably scannable
channels = sorted(channels, key=lambda chan: (not chan.is_active(), -chan.available_to_spend(REMOTE)))
channels = channels[:15]

Loading…
Cancel
Save