@@ -3812,62 +3812,17 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
3812
3812
counterparty_node_id : & PublicKey
3813
3813
) {
3814
3814
for ( htlc_src, payment_hash) in htlcs_to_fail. drain ( ..) {
3815
- match htlc_src {
3816
- HTLCSource :: PreviousHopData ( HTLCPreviousHopData { .. } ) => {
3817
- let ( failure_code, onion_failure_data) =
3818
- match self . channel_state . lock ( ) . unwrap ( ) . by_id . entry ( channel_id) {
3819
- hash_map:: Entry :: Occupied ( chan_entry) => {
3820
- self . get_htlc_inbound_temp_fail_err_and_data ( 0x1000 |7 , & chan_entry. get ( ) )
3821
- } ,
3822
- hash_map:: Entry :: Vacant ( _) => ( 0x4000 |10 , Vec :: new ( ) )
3823
- } ;
3824
- let channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3815
+ let mut channel_state = self . channel_state . lock ( ) . unwrap ( ) ;
3816
+ let ( failure_code, onion_failure_data) =
3817
+ match channel_state. by_id . entry ( channel_id) {
3818
+ hash_map:: Entry :: Occupied ( chan_entry) => {
3819
+ self . get_htlc_inbound_temp_fail_err_and_data ( 0x1000 |7 , & chan_entry. get ( ) )
3820
+ } ,
3821
+ hash_map:: Entry :: Vacant ( _) => ( 0x4000 |10 , Vec :: new ( ) )
3822
+ } ;
3825
3823
3826
- let receiver = HTLCDestination :: NextHopChannel { node_id : Some ( counterparty_node_id. clone ( ) ) , channel_id } ;
3827
- self . fail_htlc_backwards_internal ( channel_state, htlc_src, & payment_hash, HTLCFailReason :: Reason { failure_code, data : onion_failure_data } , receiver)
3828
- } ,
3829
- HTLCSource :: OutboundRoute { session_priv, payment_id, path, payment_params, .. } => {
3830
- let mut session_priv_bytes = [ 0 ; 32 ] ;
3831
- session_priv_bytes. copy_from_slice ( & session_priv[ ..] ) ;
3832
- let mut outbounds = self . pending_outbound_payments . lock ( ) . unwrap ( ) ;
3833
- if let hash_map:: Entry :: Occupied ( mut payment) = outbounds. entry ( payment_id) {
3834
- if payment. get_mut ( ) . remove ( & session_priv_bytes, Some ( & path) ) && !payment. get ( ) . is_fulfilled ( ) {
3835
- let retry = if let Some ( payment_params_data) = payment_params {
3836
- let path_last_hop = path. last ( ) . expect ( "Outbound payments must have had a valid path" ) ;
3837
- Some ( RouteParameters {
3838
- payment_params : payment_params_data,
3839
- final_value_msat : path_last_hop. fee_msat ,
3840
- final_cltv_expiry_delta : path_last_hop. cltv_expiry_delta ,
3841
- } )
3842
- } else { None } ;
3843
- let mut pending_events = self . pending_events . lock ( ) . unwrap ( ) ;
3844
- pending_events. push ( events:: Event :: PaymentPathFailed {
3845
- payment_id : Some ( payment_id) ,
3846
- payment_hash,
3847
- payment_failed_permanently : false ,
3848
- network_update : None ,
3849
- all_paths_failed : payment. get ( ) . remaining_parts ( ) == 0 ,
3850
- path : path. clone ( ) ,
3851
- short_channel_id : None ,
3852
- retry,
3853
- #[ cfg( test) ]
3854
- error_code : None ,
3855
- #[ cfg( test) ]
3856
- error_data : None ,
3857
- } ) ;
3858
- if payment. get ( ) . abandoned ( ) && payment. get ( ) . remaining_parts ( ) == 0 {
3859
- pending_events. push ( events:: Event :: PaymentFailed {
3860
- payment_id,
3861
- payment_hash : payment. get ( ) . payment_hash ( ) . expect ( "PendingOutboundPayments::RetriesExceeded always has a payment hash set" ) ,
3862
- } ) ;
3863
- payment. remove ( ) ;
3864
- }
3865
- }
3866
- } else {
3867
- log_trace ! ( self . logger, "Received duplicative fail for HTLC with payment_hash {}" , log_bytes!( payment_hash. 0 ) ) ;
3868
- }
3869
- } ,
3870
- } ;
3824
+ let receiver = HTLCDestination :: NextHopChannel { node_id : Some ( counterparty_node_id. clone ( ) ) , channel_id } ;
3825
+ self . fail_htlc_backwards_internal ( channel_state, htlc_src, & payment_hash, HTLCFailReason :: Reason { failure_code, data : onion_failure_data } , receiver) ;
3871
3826
}
3872
3827
}
3873
3828
0 commit comments