Skip to content

Commit 0eb744a

Browse files
Add CandidateRouteHop::Blinded variant
It's unclear what values 1-hop blinded paths should set their BlindedPayInfos to, because those values are meant to refer to the fees/cltv delta on the path *between* the intro node and the destination. We zero out these values in the new variant's methods so they don't mess with path finding/construction.
1 parent b9d561a commit 0eb744a

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,9 +942,15 @@ enum CandidateRouteHop<'a> {
942942
info: DirectedChannelInfo<'a>,
943943
short_channel_id: u64,
944944
},
945-
/// A hop to the payee found in the payment invoice, though not necessarily a direct channel.
945+
/// A hop to the payee found in the BOLT 11 payment invoice, though not necessarily a direct
946+
/// channel.
946947
PrivateHop {
947948
hint: &'a RouteHintHop,
949+
},
950+
/// The payee's identity is concealed behind blinded paths provided in a BOLT 12 invoice.
951+
Blinded {
952+
hint: &'a (BlindedPayInfo, BlindedPath),
953+
hint_idx: usize,
948954
}
949955
}
950956

@@ -954,6 +960,7 @@ impl<'a> CandidateRouteHop<'a> {
954960
CandidateRouteHop::FirstHop { details } => Some(details.get_outbound_payment_scid().unwrap()),
955961
CandidateRouteHop::PublicHop { short_channel_id, .. } => Some(*short_channel_id),
956962
CandidateRouteHop::PrivateHop { hint } => Some(hint.short_channel_id),
963+
CandidateRouteHop::Blinded { .. } => None,
957964
}
958965
}
959966

@@ -963,6 +970,7 @@ impl<'a> CandidateRouteHop<'a> {
963970
CandidateRouteHop::FirstHop { details } => details.counterparty.features.to_context(),
964971
CandidateRouteHop::PublicHop { info, .. } => info.channel().features.clone(),
965972
CandidateRouteHop::PrivateHop { .. } => ChannelFeatures::empty(),
973+
CandidateRouteHop::Blinded { .. } => ChannelFeatures::empty(),
966974
}
967975
}
968976

@@ -971,6 +979,8 @@ impl<'a> CandidateRouteHop<'a> {
971979
CandidateRouteHop::FirstHop { .. } => 0,
972980
CandidateRouteHop::PublicHop { info, .. } => info.direction().cltv_expiry_delta as u32,
973981
CandidateRouteHop::PrivateHop { hint } => hint.cltv_expiry_delta as u32,
982+
CandidateRouteHop::Blinded { hint, .. } =>
983+
if hint.1.blinded_hops.len() == 1 { 0 } else { hint.0.cltv_expiry_delta as u32 }
974984
}
975985
}
976986

@@ -979,6 +989,8 @@ impl<'a> CandidateRouteHop<'a> {
979989
CandidateRouteHop::FirstHop { details } => details.next_outbound_htlc_minimum_msat,
980990
CandidateRouteHop::PublicHop { info, .. } => info.direction().htlc_minimum_msat,
981991
CandidateRouteHop::PrivateHop { hint } => hint.htlc_minimum_msat.unwrap_or(0),
992+
CandidateRouteHop::Blinded { hint, .. } =>
993+
if hint.1.blinded_hops.len() == 1 { 0 } else { hint.0.htlc_minimum_msat }
982994
}
983995
}
984996

@@ -989,6 +1001,16 @@ impl<'a> CandidateRouteHop<'a> {
9891001
},
9901002
CandidateRouteHop::PublicHop { info, .. } => info.direction().fees,
9911003
CandidateRouteHop::PrivateHop { hint } => hint.fees,
1004+
CandidateRouteHop::Blinded { hint, .. } => {
1005+
if hint.1.blinded_hops.len() == 1 {
1006+
RoutingFees { base_msat: 0, proportional_millionths: 0 }
1007+
} else {
1008+
RoutingFees {
1009+
base_msat: hint.0.fee_base_msat,
1010+
proportional_millionths: hint.0.fee_proportional_millionths
1011+
}
1012+
}
1013+
}
9921014
}
9931015
}
9941016

@@ -1002,10 +1024,15 @@ impl<'a> CandidateRouteHop<'a> {
10021024
EffectiveCapacity::HintMaxHTLC { amount_msat: *max },
10031025
CandidateRouteHop::PrivateHop { hint: RouteHintHop { htlc_maximum_msat: None, .. }} =>
10041026
EffectiveCapacity::Infinite,
1027+
CandidateRouteHop::Blinded { hint, .. } =>
1028+
if hint.1.blinded_hops.len() == 1 { EffectiveCapacity::Infinite }
1029+
else { EffectiveCapacity::HintMaxHTLC { amount_msat: hint.0.htlc_maximum_msat } }
10051030
}
10061031
}
1032+
10071033
fn id(&self, channel_direction: bool /* src_node_id < target_node_id */) -> CandidateHopId {
10081034
match self {
1035+
CandidateRouteHop::Blinded { hint_idx, .. } => CandidateHopId::Blinded(*hint_idx),
10091036
_ => CandidateHopId::Clear((self.short_channel_id().unwrap(), channel_direction)),
10101037
}
10111038
}
@@ -1262,6 +1289,12 @@ struct LoggedCandidateHop<'a>(&'a CandidateRouteHop<'a>);
12621289
impl<'a> fmt::Display for LoggedCandidateHop<'a> {
12631290
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12641291
match self.0 {
1292+
CandidateRouteHop::Blinded { hint, .. } => {
1293+
"blinded route hint with introduction node id ".fmt(f)?;
1294+
hint.1.introduction_node_id.fmt(f)?;
1295+
" and blinding point ".fmt(f)?;
1296+
hint.1.blinding_point.fmt(f)
1297+
},
12651298
_ => {
12661299
"SCID ".fmt(f)?;
12671300
self.0.short_channel_id().unwrap().fmt(f)

0 commit comments

Comments
 (0)