@@ -675,11 +675,11 @@ impl OutboundPayments {
675
675
{
676
676
match err {
677
677
PaymentSendFailure :: AllFailedResendSafe ( errs) => {
678
- push_payment_path_failed_evs ( payment_id, payment_hash, route. paths , errs. into_iter ( ) . map ( |e| Err ( e) ) , pending_events) ;
678
+ Self :: push_payment_path_failed_evs ( payment_id, payment_hash, route. paths , errs. into_iter ( ) . map ( |e| Err ( e) ) , pending_events) ;
679
679
self . retry_payment_internal ( payment_id, payment_hash, route_params, router, first_hops, inflight_htlcs, entropy_source, node_signer, best_block_height, logger, pending_events, send_payment_along_path) ;
680
680
} ,
681
681
PaymentSendFailure :: PartialFailure { failed_paths_retry : Some ( retry) , results, .. } => {
682
- push_payment_path_failed_evs ( payment_id, payment_hash, route. paths , results. into_iter ( ) , pending_events) ;
682
+ Self :: push_payment_path_failed_evs ( payment_id, payment_hash, route. paths , results. into_iter ( ) , pending_events) ;
683
683
// Some paths were sent, even if we failed to send the full MPP value our recipient may
684
684
// misbehave and claim the funds, at which point we have to consider the payment sent, so
685
685
// return `Ok()` here, ignoring any retry errors.
@@ -691,14 +691,41 @@ impl OutboundPayments {
691
691
// initial HTLC-Add messages yet.
692
692
} ,
693
693
PaymentSendFailure :: PathParameterError ( results) => {
694
- push_payment_path_failed_evs ( payment_id, payment_hash, route. paths , results. into_iter ( ) , pending_events) ;
694
+ Self :: push_payment_path_failed_evs ( payment_id, payment_hash, route. paths , results. into_iter ( ) , pending_events) ;
695
695
self . abandon_payment ( payment_id, pending_events) ;
696
696
} ,
697
697
PaymentSendFailure :: ParameterError ( e) => {
698
698
log_error ! ( logger, "Failed to send to route due to parameter error: {:?}. Your router is buggy" , e) ;
699
699
self . abandon_payment ( payment_id, pending_events) ;
700
700
} ,
701
- PaymentSendFailure :: DuplicatePayment => { } , // unreachable
701
+ PaymentSendFailure :: DuplicatePayment => debug_assert ! ( false ) , // unreachable
702
+ }
703
+ }
704
+
705
+ fn push_payment_path_failed_evs < I : ExactSizeIterator + Iterator < Item = Result < ( ) , APIError > > > (
706
+ payment_id : PaymentId , payment_hash : PaymentHash , paths : Vec < Vec < RouteHop > > , path_results : I ,
707
+ pending_events : & Mutex < Vec < events:: Event > >
708
+ ) {
709
+ let mut events = pending_events. lock ( ) . unwrap ( ) ;
710
+ debug_assert_eq ! ( paths. len( ) , path_results. len( ) ) ;
711
+ for ( path, path_res) in paths. into_iter ( ) . zip ( path_results) {
712
+ if path_res. is_err ( ) {
713
+ let scid = path[ 0 ] . short_channel_id ;
714
+ events. push ( events:: Event :: PaymentPathFailed {
715
+ payment_id : Some ( payment_id) ,
716
+ payment_hash,
717
+ payment_failed_permanently : false ,
718
+ network_update : None ,
719
+ all_paths_failed : false ,
720
+ path,
721
+ short_channel_id : Some ( scid) ,
722
+ retry : None ,
723
+ #[ cfg( test) ]
724
+ error_code : None ,
725
+ #[ cfg( test) ]
726
+ error_data : None ,
727
+ } ) ;
728
+ }
702
729
}
703
730
}
704
731
@@ -1275,32 +1302,6 @@ impl OutboundPayments {
1275
1302
}
1276
1303
}
1277
1304
1278
- fn push_payment_path_failed_evs < I : Iterator < Item = Result < ( ) , APIError > > > (
1279
- payment_id : PaymentId , payment_hash : PaymentHash , paths : Vec < Vec < RouteHop > > , path_results : I ,
1280
- pending_events : & Mutex < Vec < events:: Event > >
1281
- ) {
1282
- let mut events = pending_events. lock ( ) . unwrap ( ) ;
1283
- for ( path, path_res) in paths. into_iter ( ) . zip ( path_results) {
1284
- if path_res. is_err ( ) {
1285
- let scid = path[ 0 ] . short_channel_id ;
1286
- events. push ( events:: Event :: PaymentPathFailed {
1287
- payment_id : Some ( payment_id) ,
1288
- payment_hash,
1289
- payment_failed_permanently : false ,
1290
- network_update : None ,
1291
- all_paths_failed : false ,
1292
- path,
1293
- short_channel_id : Some ( scid) ,
1294
- retry : None ,
1295
- #[ cfg( test) ]
1296
- error_code : None ,
1297
- #[ cfg( test) ]
1298
- error_data : None ,
1299
- } ) ;
1300
- }
1301
- }
1302
- }
1303
-
1304
1305
/// Returns whether a payment with the given [`PaymentHash`] and [`PaymentId`] is, in fact, a
1305
1306
/// payment probe.
1306
1307
pub ( super ) fn payment_is_probe ( payment_hash : & PaymentHash , payment_id : & PaymentId ,
0 commit comments