Skip to content

Commit 549df3e

Browse files
committed
Use inbound SCID alias for blinded path creation
When we generate a compact blinded path to ourselves, we currently use the real SCID of our channels to tell our peers where to forward to. This is fine for short-lived blinded paths where we expect the channel to still be around, but post-splicing this may spuriously invalidate blinded paths just because we spliced. Instead, here, we default to using inbound SCID aliases where possible. We also avoid one more reference to the channel's internal `FundingContext` in `channelmanager.rs`.
1 parent 6771d84 commit 549df3e

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lightning/src/ln/channel.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9403,6 +9403,12 @@ where
94039403
false
94049404
}
94059405

9406+
/// Gets the latest inbound SCID alias from our peer, or if none exists, the channel's real
9407+
/// SCID.
9408+
pub fn get_inbound_scid(&self) -> Option<u64> {
9409+
self.context.latest_inbound_scid_alias.or(self.funding.get_short_channel_id())
9410+
}
9411+
94069412
/// Returns true if our channel_ready has been sent
94079413
pub fn is_our_channel_ready(&self) -> bool {
94089414
matches!(self.context.channel_state, ChannelState::AwaitingChannelReady(flags) if flags.is_set(AwaitingChannelReadyFlags::OUR_CHANNEL_READY))

lightning/src/ln/channelmanager.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11524,8 +11524,9 @@ where
1152411524
.channel_by_id
1152511525
.iter()
1152611526
.filter(|(_, channel)| channel.context().is_usable())
11527-
.min_by_key(|(_, channel)| channel.context().channel_creation_height)
11528-
.and_then(|(_, channel)| channel.funding().get_short_channel_id()),
11527+
.filter_map(|(_, channel)| channel.as_funded())
11528+
.min_by_key(|funded_channel| funded_channel.context.channel_creation_height)
11529+
.and_then(|funded_channel| funded_channel.get_inbound_scid()),
1152911530
})
1153011531
.collect::<Vec<_>>()
1153111532
}

0 commit comments

Comments
 (0)