@@ -1121,6 +1121,7 @@ struct RouteGraphNode {
1121
1121
total_cltv_delta : u32 ,
1122
1122
/// The number of hops walked up to this node.
1123
1123
path_length_to_node : u8 ,
1124
+ is_intro_node : bool ,
1124
1125
}
1125
1126
1126
1127
impl cmp:: Ord for RouteGraphNode {
@@ -1161,6 +1162,9 @@ pub struct FirstHopCandidate<'a> {
1161
1162
///
1162
1163
/// This is not exported to bindings users as lifetimes are not expressible in most languages.
1163
1164
pub payer_node_id : & ' a NodeId ,
1165
+
1166
+ /// Whether the target of this hop is the introduction node of a payee-supplied blinded path.
1167
+ pub ( crate ) targets_blinded_path : bool ,
1164
1168
}
1165
1169
1166
1170
/// A [`CandidateRouteHop::PublicHop`] entry.
@@ -1174,12 +1178,14 @@ pub struct PublicHopCandidate<'a> {
1174
1178
/// The short channel ID of the channel, i.e. the identifier by which we refer to this
1175
1179
/// channel.
1176
1180
pub short_channel_id : u64 ,
1181
+ /// Whether the target of this hop is the introduction node of a payee-supplied blinded path.
1182
+ pub ( crate ) targets_blinded_path : bool ,
1177
1183
}
1178
1184
1179
1185
impl < ' a > PublicHopCandidate < ' a > {
1180
1186
#[ cfg( test) ]
1181
1187
pub ( super ) fn new ( info : DirectedChannelInfo < ' a > , short_channel_id : u64 ) -> Self {
1182
- Self { info, short_channel_id }
1188
+ Self { info, short_channel_id, targets_blinded_path : false }
1183
1189
}
1184
1190
}
1185
1191
@@ -2375,6 +2381,7 @@ where L::Target: Logger {
2375
2381
total_cltv_delta: hop_total_cltv_delta,
2376
2382
value_contribution_msat,
2377
2383
path_length_to_node,
2384
+ is_intro_node: $candidate. blinded_hint_idx( ) . is_some( ) ,
2378
2385
} ;
2379
2386
targets. push( new_graph_node) ;
2380
2387
old_entry. next_hops_fee_msat = $next_hops_fee_msat;
@@ -2450,7 +2457,7 @@ where L::Target: Logger {
2450
2457
// This data can later be helpful to optimize routing (pay lower fees).
2451
2458
macro_rules! add_entries_to_cheapest_to_target_node {
2452
2459
( $node: expr, $node_id: expr, $next_hops_value_contribution: expr,
2453
- $next_hops_cltv_delta: expr, $next_hops_path_length: expr ) => {
2460
+ $next_hops_cltv_delta: expr, $next_hops_path_length: expr, $is_intro_node : expr ) => {
2454
2461
let fee_to_target_msat;
2455
2462
let next_hops_path_htlc_minimum_msat;
2456
2463
let next_hops_path_penalty_msat;
@@ -2476,7 +2483,7 @@ where L::Target: Logger {
2476
2483
if let Some ( first_channels) = first_hop_targets. get( & $node_id) {
2477
2484
for details in first_channels {
2478
2485
let candidate = CandidateRouteHop :: FirstHop ( FirstHopCandidate {
2479
- details, payer_node_id: & our_node_id,
2486
+ details, payer_node_id: & our_node_id, targets_blinded_path : false ,
2480
2487
} ) ;
2481
2488
add_entry!( & candidate, fee_to_target_msat,
2482
2489
$next_hops_value_contribution,
@@ -2501,6 +2508,7 @@ where L::Target: Logger {
2501
2508
let candidate = CandidateRouteHop :: PublicHop ( PublicHopCandidate {
2502
2509
info: directed_channel,
2503
2510
short_channel_id: * chan_id,
2511
+ targets_blinded_path: $is_intro_node,
2504
2512
} ) ;
2505
2513
add_entry!( & candidate,
2506
2514
fee_to_target_msat,
@@ -2533,7 +2541,7 @@ where L::Target: Logger {
2533
2541
payee_node_id_opt. map ( |payee| first_hop_targets. get ( & payee) . map ( |first_channels| {
2534
2542
for details in first_channels {
2535
2543
let candidate = CandidateRouteHop :: FirstHop ( FirstHopCandidate {
2536
- details, payer_node_id : & our_node_id,
2544
+ details, payer_node_id : & our_node_id, targets_blinded_path : false ,
2537
2545
} ) ;
2538
2546
let added = add_entry ! ( & candidate, 0 , path_value_msat,
2539
2547
0 , 0u64 , 0 , 0 ) . is_some ( ) ;
@@ -2551,7 +2559,7 @@ where L::Target: Logger {
2551
2559
// If not, targets.pop() will not even let us enter the loop in step 2.
2552
2560
None => { } ,
2553
2561
Some ( node) => {
2554
- add_entries_to_cheapest_to_target_node ! ( node, payee, path_value_msat, 0 , 0 ) ;
2562
+ add_entries_to_cheapest_to_target_node ! ( node, payee, path_value_msat, 0 , 0 , false ) ;
2555
2563
} ,
2556
2564
} ) ;
2557
2565
@@ -2609,7 +2617,7 @@ where L::Target: Logger {
2609
2617
) ;
2610
2618
for details in first_channels {
2611
2619
let first_hop_candidate = CandidateRouteHop :: FirstHop ( FirstHopCandidate {
2612
- details, payer_node_id : & our_node_id,
2620
+ details, payer_node_id : & our_node_id, targets_blinded_path : true ,
2613
2621
} ) ;
2614
2622
let blinded_path_fee = match compute_fees ( path_contribution_msat, candidate. fees ( ) ) {
2615
2623
Some ( fee) => fee,
@@ -2665,6 +2673,7 @@ where L::Target: Logger {
2665
2673
. map ( |( info, _) | CandidateRouteHop :: PublicHop ( PublicHopCandidate {
2666
2674
info,
2667
2675
short_channel_id : hop. short_channel_id ,
2676
+ targets_blinded_path : false
2668
2677
} ) )
2669
2678
. unwrap_or_else ( || CandidateRouteHop :: PrivateHop ( PrivateHopCandidate { hint : hop, target_node_id : target } ) ) ;
2670
2679
@@ -2709,7 +2718,7 @@ where L::Target: Logger {
2709
2718
) ;
2710
2719
for details in first_channels {
2711
2720
let first_hop_candidate = CandidateRouteHop :: FirstHop ( FirstHopCandidate {
2712
- details, payer_node_id : & our_node_id,
2721
+ details, payer_node_id : & our_node_id, targets_blinded_path : false
2713
2722
} ) ;
2714
2723
add_entry ! ( & first_hop_candidate,
2715
2724
aggregate_next_hops_fee_msat, aggregate_path_contribution_msat,
@@ -2758,7 +2767,7 @@ where L::Target: Logger {
2758
2767
) ;
2759
2768
for details in first_channels {
2760
2769
let first_hop_candidate = CandidateRouteHop :: FirstHop ( FirstHopCandidate {
2761
- details, payer_node_id : & our_node_id,
2770
+ details, payer_node_id : & our_node_id, targets_blinded_path : false
2762
2771
} ) ;
2763
2772
add_entry ! ( & first_hop_candidate,
2764
2773
aggregate_next_hops_fee_msat,
@@ -2789,7 +2798,9 @@ where L::Target: Logger {
2789
2798
// Both these cases (and other cases except reaching recommended_value_msat) mean that
2790
2799
// paths_collection will be stopped because found_new_path==false.
2791
2800
// This is not necessarily a routing failure.
2792
- ' path_construction: while let Some ( RouteGraphNode { node_id, total_cltv_delta, mut value_contribution_msat, path_length_to_node, .. } ) = targets. pop ( ) {
2801
+ ' path_construction: while let Some ( RouteGraphNode {
2802
+ node_id, total_cltv_delta, mut value_contribution_msat, path_length_to_node, is_intro_node, ..
2803
+ } ) = targets. pop ( ) {
2793
2804
2794
2805
// Since we're going payee-to-payer, hitting our node as a target means we should stop
2795
2806
// traversing the graph and arrange the path out of what we found.
@@ -2926,7 +2937,7 @@ where L::Target: Logger {
2926
2937
Some ( node) => {
2927
2938
add_entries_to_cheapest_to_target_node ! ( node, node_id,
2928
2939
value_contribution_msat,
2929
- total_cltv_delta, path_length_to_node) ;
2940
+ total_cltv_delta, path_length_to_node, is_intro_node ) ;
2930
2941
} ,
2931
2942
}
2932
2943
}
0 commit comments