@@ -15,7 +15,7 @@ use bitcoin::secp256k1::{self, Secp256k1, SecretKey};
1515
1616use crate :: chain:: keysinterface:: { EntropySource , NodeSigner , Recipient } ;
1717use crate :: ln:: { PaymentHash , PaymentPreimage , PaymentSecret } ;
18- use crate :: ln:: channelmanager:: { ChannelDetails , HTLCSource , IDEMPOTENCY_TIMEOUT_TICKS , MIN_HTLC_RELAY_HOLDING_CELL_MILLIS , PaymentId } ;
18+ use crate :: ln:: channelmanager:: { ChannelDetails , HTLCSource , IDEMPOTENCY_TIMEOUT_TICKS , PaymentId } ;
1919use crate :: ln:: channelmanager:: MIN_FINAL_CLTV_EXPIRY_DELTA as LDK_DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA ;
2020use crate :: ln:: msgs:: DecodeError ;
2121use crate :: ln:: onion_utils:: HTLCFailReason ;
@@ -30,7 +30,6 @@ use crate::util::time::tests::SinceEpoch;
3030use core:: cmp;
3131use core:: fmt:: { self , Display , Formatter } ;
3232use core:: ops:: Deref ;
33- use core:: time:: Duration ;
3433
3534use crate :: prelude:: * ;
3635use crate :: sync:: Mutex ;
@@ -990,12 +989,13 @@ impl OutboundPayments {
990989 } ) ;
991990 }
992991
992+ // Returns a bool indicating whether a PendingHTLCsForwardable event should be generated.
993993 pub ( super ) fn fail_htlc < L : Deref > (
994994 & self , source : & HTLCSource , payment_hash : & PaymentHash , onion_error : & HTLCFailReason ,
995995 path : & Vec < RouteHop > , session_priv : & SecretKey , payment_id : & PaymentId ,
996996 payment_params : & Option < PaymentParameters > , probing_cookie_secret : [ u8 ; 32 ] ,
997997 secp_ctx : & Secp256k1 < secp256k1:: All > , pending_events : & Mutex < Vec < events:: Event > > , logger : & L
998- ) where L :: Target : Logger {
998+ ) -> Option < ( ) > where L :: Target : Logger {
999999 #[ cfg( test) ]
10001000 let ( network_update, short_channel_id, payment_retryable, onion_error_code, onion_error_data) = onion_error. decode_onion_failure ( secp_ctx, logger, & source) ;
10011001 #[ cfg( not( test) ) ]
@@ -1011,11 +1011,11 @@ impl OutboundPayments {
10111011 let attempts_remaining = if let hash_map:: Entry :: Occupied ( mut payment) = outbounds. entry ( * payment_id) {
10121012 if !payment. get_mut ( ) . remove ( & session_priv_bytes, Some ( & path) ) {
10131013 log_trace ! ( logger, "Received duplicative fail for HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
1014- return
1014+ return None
10151015 }
10161016 if payment. get ( ) . is_fulfilled ( ) {
10171017 log_trace ! ( logger, "Received failure of HTLC with payment_hash {} after payment completion" , log_bytes!( payment_hash. 0 ) ) ;
1018- return
1018+ return None
10191019 }
10201020 let is_retryable_now = payment. get ( ) . is_auto_retryable_now ( ) ;
10211021 if let Some ( scid) = short_channel_id {
@@ -1061,7 +1061,7 @@ impl OutboundPayments {
10611061 is_retryable_now
10621062 } else {
10631063 log_trace ! ( logger, "Received duplicative fail for HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
1064- return
1064+ return None
10651065 } ;
10661066 core:: mem:: drop ( outbounds) ;
10671067 log_trace ! ( logger, "Failing outbound payment HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
@@ -1091,9 +1091,7 @@ impl OutboundPayments {
10911091 }
10921092 if payment_retryable && attempts_remaining && retry. is_some ( ) {
10931093 debug_assert ! ( full_failure_ev. is_none( ) ) ;
1094- pending_retry_ev = Some ( events:: Event :: PendingHTLCsForwardable {
1095- time_forwardable : Duration :: from_millis ( MIN_HTLC_RELAY_HOLDING_CELL_MILLIS ) ,
1096- } ) ;
1094+ pending_retry_ev = Some ( ( ) ) ;
10971095 }
10981096 events:: Event :: PaymentPathFailed {
10991097 payment_id : Some ( * payment_id) ,
@@ -1114,7 +1112,7 @@ impl OutboundPayments {
11141112 let mut pending_events = pending_events. lock ( ) . unwrap ( ) ;
11151113 pending_events. push ( path_failure) ;
11161114 if let Some ( ev) = full_failure_ev { pending_events. push ( ev) ; }
1117- if let Some ( ev ) = pending_retry_ev { pending_events . push ( ev ) ; }
1115+ pending_retry_ev
11181116 }
11191117
11201118 pub ( super ) fn abandon_payment ( & self , payment_id : PaymentId ) -> Option < events:: Event > {
0 commit comments