@@ -135,15 +135,18 @@ fn mpp_retry() {
135135		_ => panic ! ( "Unexpected event" ) 
136136	} 
137137	events. remove ( 1 ) ; 
138- 	expect_payment_failed_conditions_event ( events,  payment_hash,  false ,  PaymentFailedConditions :: new ( ) . mpp_parts_remain ( ) ) ; 
138+ 
139+ 	let  channel_update = expect_payment_failed_conditions_event ( events,  payment_hash,  false , 
140+ 		PaymentFailedConditions :: new ( ) . mpp_parts_remain ( ) . blamed_chan_closed ( false ) ) ; 
139141
140142	// Rebalance the channel so the second half of the payment can succeed. 
141143	send_payment ( & nodes[ 3 ] ,  & vec ! ( & nodes[ 2 ] ) [ ..] ,  1_500_000 ) ; 
142144
143145	// Retry the second half of the payment and make sure it succeeds. 
144146	route. paths . remove ( 0 ) ; 
145147	route_params. final_value_msat  = 1_000_000 ; 
146- 	route_params. payment_params . previously_failed_channels . push ( chan_4_update. contents . short_channel_id ) ; 
148+ 	route_params. payment_params . previously_failed_channels . push ( 
149+ 		( chan_4_update. contents . short_channel_id ,  channel_update) ) ; 
147150	// Check the remaining max total routing fee for the second attempt is 50_000 - 1_000 msat fee 
148151	// used by the first path 
149152	route_params. max_total_routing_fee_msat  = Some ( max_total_routing_fee_msat - 1_000 ) ; 
@@ -242,8 +245,8 @@ fn mpp_retry_overpay() {
242245		_ => panic ! ( "Unexpected event" ) 
243246	} 
244247	events. remove ( 1 ) ; 
245- 	expect_payment_failed_conditions_event ( events,  payment_hash,  false , 
246- 		PaymentFailedConditions :: new ( ) . mpp_parts_remain ( ) ) ; 
248+ 	let  channel_update =  expect_payment_failed_conditions_event ( events,  payment_hash,  false , 
249+ 		PaymentFailedConditions :: new ( ) . mpp_parts_remain ( ) . blamed_chan_closed ( false ) ) ; 
247250
248251	// Rebalance the channel so the second half of the payment can succeed. 
249252	send_payment ( & nodes[ 3 ] ,  & vec ! ( & nodes[ 2 ] ) [ ..] ,  38_000_000 ) ; 
@@ -254,7 +257,8 @@ fn mpp_retry_overpay() {
254257
255258	route. paths . remove ( 0 ) ; 
256259	route_params. final_value_msat  -= first_path_value; 
257- 	route_params. payment_params . previously_failed_channels . push ( chan_4_update. contents . short_channel_id ) ; 
260+ 	route_params. payment_params . previously_failed_channels . push ( 
261+ 		( chan_4_update. contents . short_channel_id ,  channel_update) ) ; 
258262	// Check the remaining max total routing fee for the second attempt accounts only for 1_000 msat 
259263	// base fee, but not for overpaid value of the first try. 
260264	route_params. max_total_routing_fee_msat . as_mut ( ) . map ( |m| * m -= 1000 ) ; 
@@ -2429,7 +2433,7 @@ fn auto_retry_partial_failure() {
24292433
24302434	// Configure the retry1 paths 
24312435	let  mut  payment_params = route_params. payment_params . clone ( ) ; 
2432- 	payment_params. previously_failed_channels . push ( chan_2_id) ; 
2436+ 	payment_params. previously_failed_channels . push ( ( chan_2_id,   None ) ) ; 
24332437	let  mut  retry_1_params = RouteParameters :: from_payment_params_and_value ( payment_params,  amt_msat / 2 ) ; 
24342438	retry_1_params. max_total_routing_fee_msat  = None ; 
24352439
@@ -2460,7 +2464,7 @@ fn auto_retry_partial_failure() {
24602464
24612465	// Configure the retry2 path 
24622466	let  mut  payment_params = retry_1_params. payment_params . clone ( ) ; 
2463- 	payment_params. previously_failed_channels . push ( chan_3_id) ; 
2467+ 	payment_params. previously_failed_channels . push ( ( chan_3_id,   None ) ) ; 
24642468	let  mut  retry_2_params = RouteParameters :: from_payment_params_and_value ( payment_params,  amt_msat / 4 ) ; 
24652469	retry_2_params. max_total_routing_fee_msat  = None ; 
24662470
@@ -2735,7 +2739,7 @@ fn retry_multi_path_single_failed_payment() {
27352739	route. paths [ 0 ] . hops [ 0 ] . fee_msat  = 50_000_001 ; 
27362740	route. paths [ 1 ] . hops [ 0 ] . fee_msat  = 50_000_000 ; 
27372741	let  mut  pay_params = route. route_params . clone ( ) . unwrap ( ) . payment_params ; 
2738- 	pay_params. previously_failed_channels . push ( chans[ 1 ] . short_channel_id . unwrap ( ) ) ; 
2742+ 	pay_params. previously_failed_channels . push ( ( chans[ 1 ] . short_channel_id . unwrap ( ) ,   None ) ) ; 
27392743
27402744	let  mut  retry_params = RouteParameters :: from_payment_params_and_value ( pay_params,  100_000_000 ) ; 
27412745	retry_params. max_total_routing_fee_msat  = None ; 
@@ -2819,7 +2823,7 @@ fn immediate_retry_on_failure() {
28192823	route. paths [ 0 ] . hops [ 0 ] . fee_msat  = 50_000_000 ; 
28202824	route. paths [ 1 ] . hops [ 0 ] . fee_msat  = 50_000_001 ; 
28212825	let  mut  pay_params = route_params. payment_params . clone ( ) ; 
2822- 	pay_params. previously_failed_channels . push ( chans[ 0 ] . short_channel_id . unwrap ( ) ) ; 
2826+ 	pay_params. previously_failed_channels . push ( ( chans[ 0 ] . short_channel_id . unwrap ( ) ,   None ) ) ; 
28232827	let  retry_params = RouteParameters :: from_payment_params_and_value ( pay_params,  amt_msat) ; 
28242828	route. route_params  = Some ( retry_params. clone ( ) ) ; 
28252829	nodes[ 0 ] . router . expect_find_route ( retry_params,  Ok ( route. clone ( ) ) ) ; 
@@ -2865,8 +2869,11 @@ fn no_extra_retries_on_back_to_back_fail() {
28652869	let  node_chanmgrs = create_node_chanmgrs ( 3 ,  & node_cfgs,  & [ None ,  None ,  None ] ) ; 
28662870	let  nodes = create_network ( 3 ,  & node_cfgs,  & node_chanmgrs) ; 
28672871
2868- 	let  chan_1_scid = create_announced_chan_between_nodes_with_value ( & nodes,  0 ,  1 ,  10_000_000 ,  0 ) . 0 . contents . short_channel_id ; 
2869- 	let  chan_2_scid = create_announced_chan_between_nodes_with_value ( & nodes,  1 ,  2 ,  10_000_000 ,  0 ) . 0 . contents . short_channel_id ; 
2872+ 	let  chan_1_update = create_announced_chan_between_nodes_with_value ( & nodes,  0 ,  1 ,  10_000_000 ,  0 ) . 0 ; 
2873+ 	let  chan_2_update = create_announced_chan_between_nodes_with_value ( & nodes,  1 ,  2 ,  10_000_000 ,  0 ) . 0 ; 
2874+ 
2875+ 	let  chan_1_scid = chan_1_update. contents . short_channel_id ; 
2876+ 	let  chan_2_scid = chan_2_update. contents . short_channel_id ; 
28702877
28712878	let  amt_msat = 200_000_000 ; 
28722879	let  ( _,  payment_hash,  _,  payment_secret)  = get_route_and_payment_hash ! ( & nodes[ 0 ] ,  nodes[ 1 ] ,  amt_msat) ; 
@@ -2926,7 +2933,8 @@ fn no_extra_retries_on_back_to_back_fail() {
29262933	route. route_params . as_mut ( ) . unwrap ( ) . max_total_routing_fee_msat  = None ; 
29272934	nodes[ 0 ] . router . expect_find_route ( route_params. clone ( ) ,  Ok ( route. clone ( ) ) ) ; 
29282935	let  mut  second_payment_params = route_params. payment_params . clone ( ) ; 
2929- 	second_payment_params. previously_failed_channels  = vec ! [ chan_2_scid,  chan_2_scid] ; 
2936+ 	second_payment_params. previously_failed_channels  = vec ! [ 
2937+ 		( chan_2_scid,  Some ( chan_2_update. clone( ) ) ) ,  ( chan_2_scid,  Some ( chan_2_update) ) ] ; 
29302938	// On retry, we'll only return one path 
29312939	route. paths . remove ( 1 ) ; 
29322940	route. paths [ 0 ] . hops [ 1 ] . fee_msat  = amt_msat; 
@@ -3070,8 +3078,11 @@ fn test_simple_partial_retry() {
30703078	let  node_chanmgrs = create_node_chanmgrs ( 3 ,  & node_cfgs,  & [ None ,  None ,  None ] ) ; 
30713079	let  nodes = create_network ( 3 ,  & node_cfgs,  & node_chanmgrs) ; 
30723080
3073- 	let  chan_1_scid = create_announced_chan_between_nodes_with_value ( & nodes,  0 ,  1 ,  10_000_000 ,  0 ) . 0 . contents . short_channel_id ; 
3074- 	let  chan_2_scid = create_announced_chan_between_nodes_with_value ( & nodes,  1 ,  2 ,  10_000_000 ,  0 ) . 0 . contents . short_channel_id ; 
3081+ 	let  chan_1_update = create_announced_chan_between_nodes_with_value ( & nodes,  0 ,  1 ,  10_000_000 ,  0 ) . 0 ; 
3082+ 	let  chan_2_update = create_announced_chan_between_nodes_with_value ( & nodes,  1 ,  2 ,  10_000_000 ,  0 ) . 0 ; 
3083+ 
3084+ 	let  chan_1_scid = chan_1_update. contents . short_channel_id ; 
3085+ 	let  chan_2_scid = chan_2_update. contents . short_channel_id ; 
30753086
30763087	let  amt_msat = 200_000_000 ; 
30773088	let  ( _,  payment_hash,  _,  payment_secret)  = get_route_and_payment_hash ! ( & nodes[ 0 ] ,  nodes[ 2 ] ,  amt_msat) ; 
@@ -3132,7 +3143,7 @@ fn test_simple_partial_retry() {
31323143	nodes[ 0 ] . router . expect_find_route ( route_params. clone ( ) ,  Ok ( route. clone ( ) ) ) ; 
31333144
31343145	let  mut  second_payment_params = route_params. payment_params . clone ( ) ; 
3135- 	second_payment_params. previously_failed_channels  = vec ! [ chan_2_scid] ; 
3146+ 	second_payment_params. previously_failed_channels  = vec ! [ ( chan_2_scid,   Some ( chan_2_update ) ) ] ; 
31363147	// On retry, we'll only be asked for one path (or 100k sats) 
31373148	route. paths . remove ( 0 ) ; 
31383149	let  mut  retry_params = RouteParameters :: from_payment_params_and_value ( second_payment_params,  amt_msat / 2 ) ; 
@@ -3354,7 +3365,7 @@ fn test_threaded_payment_retries() {
33543365		// we should still ultimately fail for the same reason - because we're trying to send too 
33553366		// many HTLCs at once. 
33563367		let  mut  new_route_params = route_params. clone ( ) ; 
3357- 		previously_failed_channels. push ( route. paths [ 0 ] . hops [ 1 ] . short_channel_id ) ; 
3368+ 		previously_failed_channels. push ( ( route. paths [ 0 ] . hops [ 1 ] . short_channel_id ,   None ) ) ; 
33583369		new_route_params. payment_params . previously_failed_channels  = previously_failed_channels. clone ( ) ; 
33593370		new_route_params. max_total_routing_fee_msat . as_mut ( ) . map ( |m| * m -= 100_000 ) ; 
33603371		route. paths [ 0 ] . hops [ 1 ] . short_channel_id  += 1 ; 
@@ -3765,14 +3776,15 @@ fn test_retry_custom_tlvs() {
37653776		_ => panic ! ( "Unexpected event" ) 
37663777	} 
37673778	events. remove ( 1 ) ; 
3768- 	expect_payment_failed_conditions_event ( events,  payment_hash,  false , 
3769- 		PaymentFailedConditions :: new ( ) . mpp_parts_remain ( ) ) ; 
3779+ 	let  channel_update =  expect_payment_failed_conditions_event ( events,  payment_hash,  false , 
3780+ 		PaymentFailedConditions :: new ( ) . mpp_parts_remain ( ) . blamed_chan_closed ( false ) ) ; 
37703781
37713782	// Rebalance the channel so the retry of the payment can succeed. 
37723783	send_payment ( & nodes[ 2 ] ,  & vec ! ( & nodes[ 1 ] ) [ ..] ,  1_500_000 ) ; 
37733784
37743785	// Retry the payment and make sure it succeeds 
3775- 	route_params. payment_params . previously_failed_channels . push ( chan_2_update. contents . short_channel_id ) ; 
3786+ 	route_params. payment_params . previously_failed_channels . push ( 
3787+ 		( chan_2_update. contents . short_channel_id ,  channel_update) ) ; 
37763788	route. route_params  = Some ( route_params. clone ( ) ) ; 
37773789	nodes[ 0 ] . router . expect_find_route ( route_params,  Ok ( route) ) ; 
37783790	nodes[ 0 ] . node . process_pending_htlc_forwards ( ) ; 
0 commit comments