From a339338958ff4b1d982b89018740dbda41508c07 Mon Sep 17 00:00:00 2001 From: SomberNight Date: Fri, 2 Jul 2021 19:52:36 +0200 Subject: [PATCH] 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. --- electrum/lnworker.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/electrum/lnworker.py b/electrum/lnworker.py index b2730702c..9a15731c0 100644 --- a/electrum/lnworker.py +++ b/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]