@@ -4406,6 +4406,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4406
4406
let chan_id = prev_hop. outpoint . to_channel_id ( ) ;
4407
4407
let channel_state = & mut * channel_state_lock;
4408
4408
if let hash_map:: Entry :: Occupied ( mut chan) = channel_state. by_id . entry ( chan_id) {
4409
+ let counterparty_node_id = chan. get ( ) . get_counterparty_node_id ( ) ;
4409
4410
match chan. get_mut ( ) . get_update_fulfill_htlc_and_commit ( prev_hop. htlc_id , payment_preimage, & self . logger ) {
4410
4411
Ok ( msgs_monitor_option) => {
4411
4412
if let UpdateFulfillCommitFetch :: NewClaim { msgs, htlc_value_msat, monitor_update } = msgs_monitor_option {
@@ -4415,11 +4416,11 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4415
4416
log_given_level ! ( self . logger, if e == ChannelMonitorUpdateStatus :: PermanentFailure { Level :: Error } else { Level :: Debug } ,
4416
4417
"Failed to update channel monitor with preimage {:?}: {:?}" ,
4417
4418
payment_preimage, e) ;
4419
+ let err = handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , false , msgs. is_some( ) ) . unwrap_err ( ) ;
4420
+ mem:: drop ( channel_state_lock) ;
4418
4421
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4419
4422
return ClaimFundsFromHop :: MonitorUpdateFail (
4420
- chan. get ( ) . get_counterparty_node_id ( ) ,
4421
- handle_monitor_update_res ! ( self , e, chan, RAACommitmentOrder :: CommitmentFirst , false , msgs. is_some( ) ) . unwrap_err ( ) ,
4422
- Some ( htlc_value_msat)
4423
+ counterparty_node_id, err, Some ( htlc_value_msat)
4423
4424
) ;
4424
4425
}
4425
4426
}
@@ -4438,6 +4439,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4438
4439
}
4439
4440
} ) ;
4440
4441
}
4442
+ mem:: drop ( channel_state_lock) ;
4441
4443
self . handle_monitor_update_completion_actions ( completion_action ( Some ( htlc_value_msat) ) ) ;
4442
4444
return ClaimFundsFromHop :: Success ( htlc_value_msat) ;
4443
4445
} else {
@@ -4453,11 +4455,11 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4453
4455
payment_preimage, e) ;
4454
4456
} ,
4455
4457
}
4456
- let counterparty_node_id = chan. get ( ) . get_counterparty_node_id ( ) ;
4457
4458
let ( drop, res) = convert_chan_err ! ( self , e, chan. get_mut( ) , & chan_id) ;
4458
4459
if drop {
4459
4460
chan. remove_entry ( ) ;
4460
4461
}
4462
+ mem:: drop ( channel_state_lock) ;
4461
4463
self . handle_monitor_update_completion_actions ( completion_action ( None ) ) ;
4462
4464
return ClaimFundsFromHop :: MonitorUpdateFail ( counterparty_node_id, res, None ) ;
4463
4465
} ,
@@ -4480,6 +4482,7 @@ impl<M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelManager<M, T, K, F
4480
4482
log_error ! ( self . logger, "Critical error: failed to update channel monitor with preimage {:?}: {:?}" ,
4481
4483
payment_preimage, update_res) ;
4482
4484
}
4485
+ mem:: drop ( channel_state_lock) ;
4483
4486
// Note that we do process the completion action here. This totally could be a
4484
4487
// duplicate claim, but we have no way of knowing without interrogating the
4485
4488
// `ChannelMonitor` we've provided the above update to. Instead, note that `Event`s are
0 commit comments