Skip to content

Commit c624b25

Browse files
Add CandidateRouteHop::Blinded and ::OneHopBlinded 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 ab5f72c commit c624b25

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
@@ -939,9 +939,15 @@ enum CandidateRouteHop<'a> {
939939
info: DirectedChannelInfo<'a>,
940940
short_channel_id: u64,
941941
},
942-
/// A hop to the payee found in the payment invoice, though not necessarily a direct channel.
942+
/// A hop to the payee found in the BOLT 11 payment invoice, though not necessarily a direct
943+
/// channel.
943944
PrivateHop {
944945
hint: &'a RouteHintHop,
946+
},
947+
/// The payee's identity is concealed behind blinded paths provided in a BOLT 12 invoice.
948+
Blinded {
949+
hint: &'a (BlindedPayInfo, BlindedPath),
950+
hint_idx: usize,
945951
}
946952
}
947953

@@ -951,6 +957,7 @@ impl<'a> CandidateRouteHop<'a> {
951957
CandidateRouteHop::FirstHop { details } => Some(details.get_outbound_payment_scid().unwrap()),
952958
CandidateRouteHop::PublicHop { short_channel_id, .. } => Some(*short_channel_id),
953959
CandidateRouteHop::PrivateHop { hint } => Some(hint.short_channel_id),
960+
CandidateRouteHop::Blinded { .. } => None,
954961
}
955962
}
956963

@@ -960,6 +967,7 @@ impl<'a> CandidateRouteHop<'a> {
960967
CandidateRouteHop::FirstHop { details } => details.counterparty.features.to_context(),
961968
CandidateRouteHop::PublicHop { info, .. } => info.channel().features.clone(),
962969
CandidateRouteHop::PrivateHop { .. } => ChannelFeatures::empty(),
970+
CandidateRouteHop::Blinded { .. } => ChannelFeatures::empty(),
963971
}
964972
}
965973

@@ -968,6 +976,8 @@ impl<'a> CandidateRouteHop<'a> {
968976
CandidateRouteHop::FirstHop { .. } => 0,
969977
CandidateRouteHop::PublicHop { info, .. } => info.direction().cltv_expiry_delta as u32,
970978
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 }
971981
}
972982
}
973983

@@ -976,6 +986,8 @@ impl<'a> CandidateRouteHop<'a> {
976986
CandidateRouteHop::FirstHop { details } => details.next_outbound_htlc_minimum_msat,
977987
CandidateRouteHop::PublicHop { info, .. } => info.direction().htlc_minimum_msat,
978988
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 }
979991
}
980992
}
981993

@@ -986,6 +998,16 @@ impl<'a> CandidateRouteHop<'a> {
986998
},
987999
CandidateRouteHop::PublicHop { info, .. } => info.direction().fees,
9881000
CandidateRouteHop::PrivateHop { hint } => hint.fees,
1001+
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+
}
1009+
}
1010+
}
9891011
}
9901012
}
9911013

@@ -999,10 +1021,15 @@ impl<'a> CandidateRouteHop<'a> {
9991021
EffectiveCapacity::HintMaxHTLC { amount_msat: *max },
10001022
CandidateRouteHop::PrivateHop { hint: RouteHintHop { htlc_maximum_msat: None, .. }} =>
10011023
EffectiveCapacity::Infinite,
1024+
CandidateRouteHop::Blinded { hint, .. } =>
1025+
if hint.1.blinded_hops.len() == 1 { EffectiveCapacity::Infinite }
1026+
else { EffectiveCapacity::HintMaxHTLC { amount_msat: hint.0.htlc_maximum_msat } }
10021027
}
10031028
}
1029+
10041030
fn id(&self, channel_direction: bool /* src_node_id < target_node_id */) -> CandidateHopId {
10051031
match self {
1032+
CandidateRouteHop::Blinded { hint_idx, .. } => CandidateHopId::Blinded(*hint_idx),
10061033
_ => CandidateHopId::Clear((self.short_channel_id().unwrap(), channel_direction)),
10071034
}
10081035
}
@@ -1259,6 +1286,12 @@ struct LoggedCandidateHop<'a>(&'a CandidateRouteHop<'a>);
12591286
impl<'a> fmt::Display for LoggedCandidateHop<'a> {
12601287
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12611288
match self.0 {
1289+
CandidateRouteHop::Blinded { hint, .. } => {
1290+
"blinded route hint with introduction node id ".fmt(f)?;
1291+
hint.1.introduction_node_id.fmt(f)?;
1292+
" and blinding point ".fmt(f)?;
1293+
hint.1.blinding_point.fmt(f)
1294+
},
12621295
_ => {
12631296
"SCID ".fmt(f)?;
12641297
self.0.short_channel_id().unwrap().fmt(f)

0 commit comments

Comments
 (0)