@@ -15,7 +15,7 @@ use bitcoin::secp256k1::{self, Secp256k1, SecretKey};
15
15
16
16
use crate :: chain:: keysinterface:: { EntropySource , NodeSigner , Recipient } ;
17
17
use 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 } ;
19
19
use crate :: ln:: channelmanager:: MIN_FINAL_CLTV_EXPIRY_DELTA as LDK_DEFAULT_MIN_FINAL_CLTV_EXPIRY_DELTA ;
20
20
use crate :: ln:: msgs:: DecodeError ;
21
21
use crate :: ln:: onion_utils:: HTLCFailReason ;
@@ -30,7 +30,6 @@ use crate::util::time::tests::SinceEpoch;
30
30
use core:: cmp;
31
31
use core:: fmt:: { self , Display , Formatter } ;
32
32
use core:: ops:: Deref ;
33
- use core:: time:: Duration ;
34
33
35
34
use crate :: prelude:: * ;
36
35
use crate :: sync:: Mutex ;
@@ -990,12 +989,13 @@ impl OutboundPayments {
990
989
} ) ;
991
990
}
992
991
992
+ // Returns a bool indicating whether a PendingHTLCsForwardable event should be generated.
993
993
pub ( super ) fn fail_htlc < L : Deref > (
994
994
& self , source : & HTLCSource , payment_hash : & PaymentHash , onion_error : & HTLCFailReason ,
995
995
path : & Vec < RouteHop > , session_priv : & SecretKey , payment_id : & PaymentId ,
996
996
payment_params : & Option < PaymentParameters > , probing_cookie_secret : [ u8 ; 32 ] ,
997
997
secp_ctx : & Secp256k1 < secp256k1:: All > , pending_events : & Mutex < Vec < events:: Event > > , logger : & L
998
- ) where L :: Target : Logger {
998
+ ) -> Option < ( ) > where L :: Target : Logger {
999
999
#[ cfg( test) ]
1000
1000
let ( network_update, short_channel_id, payment_retryable, onion_error_code, onion_error_data) = onion_error. decode_onion_failure ( secp_ctx, logger, & source) ;
1001
1001
#[ cfg( not( test) ) ]
@@ -1011,11 +1011,11 @@ impl OutboundPayments {
1011
1011
let attempts_remaining = if let hash_map:: Entry :: Occupied ( mut payment) = outbounds. entry ( * payment_id) {
1012
1012
if !payment. get_mut ( ) . remove ( & session_priv_bytes, Some ( & path) ) {
1013
1013
log_trace ! ( logger, "Received duplicative fail for HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
1014
- return
1014
+ return None
1015
1015
}
1016
1016
if payment. get ( ) . is_fulfilled ( ) {
1017
1017
log_trace ! ( logger, "Received failure of HTLC with payment_hash {} after payment completion" , log_bytes!( payment_hash. 0 ) ) ;
1018
- return
1018
+ return None
1019
1019
}
1020
1020
let is_retryable_now = payment. get ( ) . is_auto_retryable_now ( ) ;
1021
1021
if let Some ( scid) = short_channel_id {
@@ -1061,7 +1061,7 @@ impl OutboundPayments {
1061
1061
is_retryable_now
1062
1062
} else {
1063
1063
log_trace ! ( logger, "Received duplicative fail for HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
1064
- return
1064
+ return None
1065
1065
} ;
1066
1066
core:: mem:: drop ( outbounds) ;
1067
1067
log_trace ! ( logger, "Failing outbound payment HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
@@ -1091,9 +1091,7 @@ impl OutboundPayments {
1091
1091
}
1092
1092
if payment_retryable && attempts_remaining && retry. is_some ( ) {
1093
1093
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 ( ( ) ) ;
1097
1095
}
1098
1096
events:: Event :: PaymentPathFailed {
1099
1097
payment_id : Some ( * payment_id) ,
@@ -1114,7 +1112,7 @@ impl OutboundPayments {
1114
1112
let mut pending_events = pending_events. lock ( ) . unwrap ( ) ;
1115
1113
pending_events. push ( path_failure) ;
1116
1114
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
1118
1116
}
1119
1117
1120
1118
pub ( super ) fn abandon_payment ( & self , payment_id : PaymentId ) -> Option < events:: Event > {
0 commit comments