Skip to content

Commit 899c6e5

Browse files
f add ::OneHopBlinded variant
1 parent c624b25 commit 899c6e5

File tree

1 file changed

+24
-16
lines changed

1 file changed

+24
-16
lines changed

lightning/src/routing/router.rs

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -948,7 +948,14 @@ enum CandidateRouteHop<'a> {
948948
Blinded {
949949
hint: &'a (BlindedPayInfo, BlindedPath),
950950
hint_idx: usize,
951-
}
951+
},
952+
/// Similar to [`Self::Blinded`], but the path here has 1 blinded hop. `BlindedPayInfo` provided
953+
/// for 1-hop blinded paths is ignored because it is meant to apply to the hops *between* the
954+
/// introduction node and the destination.
955+
OneHopBlinded {
956+
hint: &'a (BlindedPayInfo, BlindedPath),
957+
hint_idx: usize,
958+
},
952959
}
953960

954961
impl<'a> CandidateRouteHop<'a> {
@@ -958,6 +965,7 @@ impl<'a> CandidateRouteHop<'a> {
958965
CandidateRouteHop::PublicHop { short_channel_id, .. } => Some(*short_channel_id),
959966
CandidateRouteHop::PrivateHop { hint } => Some(hint.short_channel_id),
960967
CandidateRouteHop::Blinded { .. } => None,
968+
CandidateRouteHop::OneHopBlinded { .. } => None,
961969
}
962970
}
963971

@@ -968,6 +976,7 @@ impl<'a> CandidateRouteHop<'a> {
968976
CandidateRouteHop::PublicHop { info, .. } => info.channel().features.clone(),
969977
CandidateRouteHop::PrivateHop { .. } => ChannelFeatures::empty(),
970978
CandidateRouteHop::Blinded { .. } => ChannelFeatures::empty(),
979+
CandidateRouteHop::OneHopBlinded { .. } => ChannelFeatures::empty(),
971980
}
972981
}
973982

@@ -976,8 +985,8 @@ impl<'a> CandidateRouteHop<'a> {
976985
CandidateRouteHop::FirstHop { .. } => 0,
977986
CandidateRouteHop::PublicHop { info, .. } => info.direction().cltv_expiry_delta as u32,
978987
CandidateRouteHop::PrivateHop { hint } => hint.cltv_expiry_delta as u32,
979-
CandidateRouteHop::Blinded { hint, .. } =>
980-
if hint.1.blinded_hops.len() == 1 { 0 } else { hint.0.cltv_expiry_delta as u32 }
988+
CandidateRouteHop::Blinded { hint, .. } => hint.0.cltv_expiry_delta as u32,
989+
CandidateRouteHop::OneHopBlinded { .. } => 0,
981990
}
982991
}
983992

@@ -986,8 +995,8 @@ impl<'a> CandidateRouteHop<'a> {
986995
CandidateRouteHop::FirstHop { details } => details.next_outbound_htlc_minimum_msat,
987996
CandidateRouteHop::PublicHop { info, .. } => info.direction().htlc_minimum_msat,
988997
CandidateRouteHop::PrivateHop { hint } => hint.htlc_minimum_msat.unwrap_or(0),
989-
CandidateRouteHop::Blinded { hint, .. } =>
990-
if hint.1.blinded_hops.len() == 1 { 0 } else { hint.0.htlc_minimum_msat }
998+
CandidateRouteHop::Blinded { hint, .. } => hint.0.htlc_minimum_msat,
999+
CandidateRouteHop::OneHopBlinded { .. } => 0,
9911000
}
9921001
}
9931002

@@ -999,15 +1008,13 @@ impl<'a> CandidateRouteHop<'a> {
9991008
CandidateRouteHop::PublicHop { info, .. } => info.direction().fees,
10001009
CandidateRouteHop::PrivateHop { hint } => hint.fees,
10011010
CandidateRouteHop::Blinded { hint, .. } => {
1002-
if hint.1.blinded_hops.len() == 1 {
1003-
RoutingFees { base_msat: 0, proportional_millionths: 0 }
1004-
} else {
1005-
RoutingFees {
1006-
base_msat: hint.0.fee_base_msat,
1007-
proportional_millionths: hint.0.fee_proportional_millionths
1008-
}
1011+
RoutingFees {
1012+
base_msat: hint.0.fee_base_msat,
1013+
proportional_millionths: hint.0.fee_proportional_millionths
10091014
}
1010-
}
1015+
},
1016+
CandidateRouteHop::OneHopBlinded { .. } =>
1017+
RoutingFees { base_msat: 0, proportional_millionths: 0 },
10111018
}
10121019
}
10131020

@@ -1022,14 +1029,15 @@ impl<'a> CandidateRouteHop<'a> {
10221029
CandidateRouteHop::PrivateHop { hint: RouteHintHop { htlc_maximum_msat: None, .. }} =>
10231030
EffectiveCapacity::Infinite,
10241031
CandidateRouteHop::Blinded { hint, .. } =>
1025-
if hint.1.blinded_hops.len() == 1 { EffectiveCapacity::Infinite }
1026-
else { EffectiveCapacity::HintMaxHTLC { amount_msat: hint.0.htlc_maximum_msat } }
1032+
EffectiveCapacity::HintMaxHTLC { amount_msat: hint.0.htlc_maximum_msat },
1033+
CandidateRouteHop::OneHopBlinded { .. } => EffectiveCapacity::Infinite,
10271034
}
10281035
}
10291036

10301037
fn id(&self, channel_direction: bool /* src_node_id < target_node_id */) -> CandidateHopId {
10311038
match self {
10321039
CandidateRouteHop::Blinded { hint_idx, .. } => CandidateHopId::Blinded(*hint_idx),
1040+
CandidateRouteHop::OneHopBlinded { hint_idx, .. } => CandidateHopId::Blinded(*hint_idx),
10331041
_ => CandidateHopId::Clear((self.short_channel_id().unwrap(), channel_direction)),
10341042
}
10351043
}
@@ -1286,7 +1294,7 @@ struct LoggedCandidateHop<'a>(&'a CandidateRouteHop<'a>);
12861294
impl<'a> fmt::Display for LoggedCandidateHop<'a> {
12871295
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12881296
match self.0 {
1289-
CandidateRouteHop::Blinded { hint, .. } => {
1297+
CandidateRouteHop::Blinded { hint, .. } | CandidateRouteHop::OneHopBlinded { hint, .. } => {
12901298
"blinded route hint with introduction node id ".fmt(f)?;
12911299
hint.1.introduction_node_id.fmt(f)?;
12921300
" and blinding point ".fmt(f)?;

0 commit comments

Comments
 (0)