Skip to content

Commit 8022d1e

Browse files
committed
Select the channel with the highest balance for blinded paths
When building a compact blinded path we need to pick a channel for an SCID that we think is mostl likely to stick around the longest. We don't really have any great options cause we have no idea what downstream code does, but "highest balance" seems marginally better than the previous criteria of "oldest channel".
1 parent 10391b7 commit 8022d1e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14085,7 +14085,9 @@ impl<
1408514085
short_channel_id: peer_chans
1408614086
.iter()
1408714087
.filter(|chan| chan.is_usable)
14088-
.min_by_key(|chan| chan.short_channel_id)
14088+
// Select the channel which has the highest local balance. We assume this
14089+
// channel is the most likely to stick around.
14090+
.max_by_key(|chan| chan.inbound_capacity_msat)
1408914091
.and_then(|chan| chan.get_inbound_payment_scid()),
1409014092
})
1409114093
}
@@ -14108,7 +14110,9 @@ impl<
1410814110
.iter()
1410914111
.filter(|(_, channel)| channel.context().is_usable())
1411014112
.filter_map(|(_, channel)| channel.as_funded())
14111-
.min_by_key(|funded_channel| funded_channel.context.channel_creation_height)
14113+
// Select the channel which has the highest local balance. We assume this
14114+
// channel is the most likely to stick around.
14115+
.max_by_key(|funded_channel| funded_channel.funding.get_value_to_self_msat())
1411214116
.and_then(|funded_channel| funded_channel.get_inbound_scid()),
1411314117
})
1411414118
.collect::<Vec<_>>()

0 commit comments

Comments
 (0)