Skip to content

Commit 19dfc38

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 5684f46 commit 19dfc38

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

lightning/src/routing/router.rs

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,9 +931,15 @@ enum CandidateRouteHop<'a> {
931931
info: DirectedChannelInfo<'a>,
932932
short_channel_id: u64,
933933
},
934-
/// A hop to the payee found in the payment invoice, though not necessarily a direct channel.
934+
/// A hop to the payee found in the BOLT 11 payment invoice, though not necessarily a direct
935+
/// channel.
935936
PrivateHop {
936937
hint: &'a RouteHintHop,
938+
},
939+
/// The payee's identity is concealed behind blinded paths provided in a BOLT 12 invoice.
940+
Blinded {
941+
hint: &'a (BlindedPayInfo, BlindedPath),
942+
hint_idx: usize,
937943
}
938944
}
939945

@@ -943,6 +949,7 @@ impl<'a> CandidateRouteHop<'a> {
943949
CandidateRouteHop::FirstHop { details } => Some(details.get_outbound_payment_scid().unwrap()),
944950
CandidateRouteHop::PublicHop { short_channel_id, .. } => Some(*short_channel_id),
945951
CandidateRouteHop::PrivateHop { hint } => Some(hint.short_channel_id),
952+
CandidateRouteHop::Blinded { .. } => None,
946953
}
947954
}
948955

@@ -952,6 +959,7 @@ impl<'a> CandidateRouteHop<'a> {
952959
CandidateRouteHop::FirstHop { details } => details.counterparty.features.to_context(),
953960
CandidateRouteHop::PublicHop { info, .. } => info.channel().features.clone(),
954961
CandidateRouteHop::PrivateHop { .. } => ChannelFeatures::empty(),
962+
CandidateRouteHop::Blinded { .. } => ChannelFeatures::empty(),
955963
}
956964
}
957965

@@ -960,6 +968,8 @@ impl<'a> CandidateRouteHop<'a> {
960968
CandidateRouteHop::FirstHop { .. } => 0,
961969
CandidateRouteHop::PublicHop { info, .. } => info.direction().cltv_expiry_delta as u32,
962970
CandidateRouteHop::PrivateHop { hint } => hint.cltv_expiry_delta as u32,
971+
CandidateRouteHop::Blinded { hint, .. } =>
972+
if hint.1.blinded_hops.len() == 1 { 0 } else { hint.0.cltv_expiry_delta as u32 }
963973
}
964974
}
965975

@@ -968,6 +978,8 @@ impl<'a> CandidateRouteHop<'a> {
968978
CandidateRouteHop::FirstHop { details } => details.next_outbound_htlc_minimum_msat,
969979
CandidateRouteHop::PublicHop { info, .. } => info.direction().htlc_minimum_msat,
970980
CandidateRouteHop::PrivateHop { hint } => hint.htlc_minimum_msat.unwrap_or(0),
981+
CandidateRouteHop::Blinded { hint, .. } =>
982+
if hint.1.blinded_hops.len() == 1 { 0 } else { hint.0.htlc_minimum_msat }
971983
}
972984
}
973985

@@ -978,6 +990,17 @@ impl<'a> CandidateRouteHop<'a> {
978990
},
979991
CandidateRouteHop::PublicHop { info, .. } => info.direction().fees,
980992
CandidateRouteHop::PrivateHop { hint } => hint.fees,
993+
CandidateRouteHop::Blinded { hint, .. } => {
994+
if hint.1.blinded_hops.len() == 1 {
995+
RoutingFees { base_msat: 0, proportional_millionths: 0 }
996+
} else {
997+
RoutingFees {
998+
base_msat: hint.0.fee_base_msat,
999+
proportional_millionths:
1000+
hint.0.fee_proportional_millionths
1001+
}
1002+
}
1003+
}
9811004
}
9821005
}
9831006

@@ -991,10 +1014,17 @@ impl<'a> CandidateRouteHop<'a> {
9911014
EffectiveCapacity::HintMaxHTLC { amount_msat: *max },
9921015
CandidateRouteHop::PrivateHop { hint: RouteHintHop { htlc_maximum_msat: None, .. }} =>
9931016
EffectiveCapacity::Infinite,
1017+
CandidateRouteHop::Blinded { hint, .. } =>
1018+
EffectiveCapacity::HintMaxHTLC {
1019+
amount_msat: if hint.1.blinded_hops.len() == 1 { u64::max_value() }
1020+
else { hint.0.htlc_maximum_msat }
1021+
},
9941022
}
9951023
}
1024+
9961025
fn id(&self, channel_direction: bool /* src_node_id < target_node_id */) -> CandidateHopId {
9971026
match self {
1027+
CandidateRouteHop::Blinded { hint_idx, .. } => CandidateHopId::Blinded(*hint_idx),
9981028
_ => CandidateHopId::Clear((self.short_channel_id().unwrap(), channel_direction)),
9991029
}
10001030
}
@@ -1251,6 +1281,12 @@ struct LoggedCandidateHop<'a>(&'a CandidateRouteHop<'a>);
12511281
impl<'a> fmt::Display for LoggedCandidateHop<'a> {
12521282
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
12531283
match self.0 {
1284+
CandidateRouteHop::Blinded { hint, .. } => {
1285+
"blinded route hint with introduction node id ".fmt(f)?;
1286+
hint.1.introduction_node_id.fmt(f)?;
1287+
" and blinding point ".fmt(f)?;
1288+
hint.1.blinding_point.fmt(f)
1289+
},
12541290
_ => {
12551291
"SCID ".fmt(f)?;
12561292
self.0.short_channel_id().unwrap().fmt(f)

0 commit comments

Comments
 (0)