@@ -135,15 +135,18 @@ fn mpp_retry() {
135
135
_ => panic ! ( "Unexpected event" )
136
136
}
137
137
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 ) ) ;
139
141
140
142
// Rebalance the channel so the second half of the payment can succeed.
141
143
send_payment ( & nodes[ 3 ] , & vec ! ( & nodes[ 2 ] ) [ ..] , 1_500_000 ) ;
142
144
143
145
// Retry the second half of the payment and make sure it succeeds.
144
146
route. paths . remove ( 0 ) ;
145
147
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) ) ;
147
150
// Check the remaining max total routing fee for the second attempt is 50_000 - 1_000 msat fee
148
151
// used by the first path
149
152
route_params. max_total_routing_fee_msat = Some ( max_total_routing_fee_msat - 1_000 ) ;
@@ -242,8 +245,8 @@ fn mpp_retry_overpay() {
242
245
_ => panic ! ( "Unexpected event" )
243
246
}
244
247
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 ) ) ;
247
250
248
251
// Rebalance the channel so the second half of the payment can succeed.
249
252
send_payment ( & nodes[ 3 ] , & vec ! ( & nodes[ 2 ] ) [ ..] , 38_000_000 ) ;
@@ -254,7 +257,8 @@ fn mpp_retry_overpay() {
254
257
255
258
route. paths . remove ( 0 ) ;
256
259
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) ) ;
258
262
// Check the remaining max total routing fee for the second attempt accounts only for 1_000 msat
259
263
// base fee, but not for overpaid value of the first try.
260
264
route_params. max_total_routing_fee_msat . as_mut ( ) . map ( |m| * m -= 1000 ) ;
@@ -2429,7 +2433,7 @@ fn auto_retry_partial_failure() {
2429
2433
2430
2434
// Configure the retry1 paths
2431
2435
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 ) ) ;
2433
2437
let mut retry_1_params = RouteParameters :: from_payment_params_and_value ( payment_params, amt_msat / 2 ) ;
2434
2438
retry_1_params. max_total_routing_fee_msat = None ;
2435
2439
@@ -2460,7 +2464,7 @@ fn auto_retry_partial_failure() {
2460
2464
2461
2465
// Configure the retry2 path
2462
2466
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 ) ) ;
2464
2468
let mut retry_2_params = RouteParameters :: from_payment_params_and_value ( payment_params, amt_msat / 4 ) ;
2465
2469
retry_2_params. max_total_routing_fee_msat = None ;
2466
2470
@@ -2735,7 +2739,7 @@ fn retry_multi_path_single_failed_payment() {
2735
2739
route. paths [ 0 ] . hops [ 0 ] . fee_msat = 50_000_001 ;
2736
2740
route. paths [ 1 ] . hops [ 0 ] . fee_msat = 50_000_000 ;
2737
2741
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 ) ) ;
2739
2743
2740
2744
let mut retry_params = RouteParameters :: from_payment_params_and_value ( pay_params, 100_000_000 ) ;
2741
2745
retry_params. max_total_routing_fee_msat = None ;
@@ -2819,7 +2823,7 @@ fn immediate_retry_on_failure() {
2819
2823
route. paths [ 0 ] . hops [ 0 ] . fee_msat = 50_000_000 ;
2820
2824
route. paths [ 1 ] . hops [ 0 ] . fee_msat = 50_000_001 ;
2821
2825
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 ) ) ;
2823
2827
let retry_params = RouteParameters :: from_payment_params_and_value ( pay_params, amt_msat) ;
2824
2828
route. route_params = Some ( retry_params. clone ( ) ) ;
2825
2829
nodes[ 0 ] . router . expect_find_route ( retry_params, Ok ( route. clone ( ) ) ) ;
@@ -2865,8 +2869,11 @@ fn no_extra_retries_on_back_to_back_fail() {
2865
2869
let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
2866
2870
let nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
2867
2871
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 ;
2870
2877
2871
2878
let amt_msat = 200_000_000 ;
2872
2879
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() {
2926
2933
route. route_params . as_mut ( ) . unwrap ( ) . max_total_routing_fee_msat = None ;
2927
2934
nodes[ 0 ] . router . expect_find_route ( route_params. clone ( ) , Ok ( route. clone ( ) ) ) ;
2928
2935
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) ) ] ;
2930
2938
// On retry, we'll only return one path
2931
2939
route. paths . remove ( 1 ) ;
2932
2940
route. paths [ 0 ] . hops [ 1 ] . fee_msat = amt_msat;
@@ -3070,8 +3078,11 @@ fn test_simple_partial_retry() {
3070
3078
let node_chanmgrs = create_node_chanmgrs ( 3 , & node_cfgs, & [ None , None , None ] ) ;
3071
3079
let nodes = create_network ( 3 , & node_cfgs, & node_chanmgrs) ;
3072
3080
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 ;
3075
3086
3076
3087
let amt_msat = 200_000_000 ;
3077
3088
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() {
3132
3143
nodes[ 0 ] . router . expect_find_route ( route_params. clone ( ) , Ok ( route. clone ( ) ) ) ;
3133
3144
3134
3145
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 ) ) ] ;
3136
3147
// On retry, we'll only be asked for one path (or 100k sats)
3137
3148
route. paths . remove ( 0 ) ;
3138
3149
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() {
3354
3365
// we should still ultimately fail for the same reason - because we're trying to send too
3355
3366
// many HTLCs at once.
3356
3367
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 ) ) ;
3358
3369
new_route_params. payment_params . previously_failed_channels = previously_failed_channels. clone ( ) ;
3359
3370
new_route_params. max_total_routing_fee_msat . as_mut ( ) . map ( |m| * m -= 100_000 ) ;
3360
3371
route. paths [ 0 ] . hops [ 1 ] . short_channel_id += 1 ;
@@ -3765,14 +3776,15 @@ fn test_retry_custom_tlvs() {
3765
3776
_ => panic ! ( "Unexpected event" )
3766
3777
}
3767
3778
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 ) ) ;
3770
3781
3771
3782
// Rebalance the channel so the retry of the payment can succeed.
3772
3783
send_payment ( & nodes[ 2 ] , & vec ! ( & nodes[ 1 ] ) [ ..] , 1_500_000 ) ;
3773
3784
3774
3785
// 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) ) ;
3776
3788
route. route_params = Some ( route_params. clone ( ) ) ;
3777
3789
nodes[ 0 ] . router . expect_find_route ( route_params, Ok ( route) ) ;
3778
3790
nodes[ 0 ] . node . process_pending_htlc_forwards ( ) ;
0 commit comments