@@ -11548,55 +11548,68 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1154811548 fn internal_tx_abort(
1154911549 &self, counterparty_node_id: &PublicKey, msg: &msgs::TxAbort,
1155011550 ) -> Result<NotifyOption, MsgHandleErrInternal> {
11551- let per_peer_state = self.per_peer_state.read().unwrap();
11552- let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
11553- debug_assert!(false);
11554- MsgHandleErrInternal::no_such_peer(counterparty_node_id, msg.channel_id)
11555- })?;
11556- let mut peer_state_lock = peer_state_mutex.lock().unwrap();
11557- let peer_state = &mut *peer_state_lock;
11558- match peer_state.channel_by_id.entry(msg.channel_id) {
11559- hash_map::Entry::Occupied(mut chan_entry) => {
11560- let res = chan_entry.get_mut().tx_abort(msg, &self.logger);
11561- let (tx_abort, splice_failed) =
11562- try_channel_entry!(self, peer_state, res, chan_entry);
11551+ let (result, holding_cell_res) = {
11552+ let per_peer_state = self.per_peer_state.read().unwrap();
11553+ let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
11554+ debug_assert!(false);
11555+ MsgHandleErrInternal::no_such_peer(counterparty_node_id, msg.channel_id)
11556+ })?;
11557+ let mut peer_state_lock = peer_state_mutex.lock().unwrap();
11558+ let peer_state = &mut *peer_state_lock;
11559+ match peer_state.channel_by_id.entry(msg.channel_id) {
11560+ hash_map::Entry::Occupied(mut chan_entry) => {
11561+ let res = chan_entry.get_mut().tx_abort(msg, &self.logger);
11562+ let (tx_abort, splice_failed, exited_quiescence) =
11563+ try_channel_entry!(self, peer_state, res, chan_entry);
1156311564
11564- let persist = if tx_abort.is_some() || splice_failed.is_some() {
11565- NotifyOption::DoPersist
11566- } else {
11567- NotifyOption::SkipPersistNoEvents
11568- };
11565+ let persist = if tx_abort.is_some() || splice_failed.is_some() {
11566+ NotifyOption::DoPersist
11567+ } else {
11568+ NotifyOption::SkipPersistNoEvents
11569+ };
1156911570
11570- if let Some(tx_abort_msg) = tx_abort {
11571- peer_state.pending_msg_events.push(MessageSendEvent::SendTxAbort {
11572- node_id: *counterparty_node_id,
11573- msg: tx_abort_msg,
11574- });
11575- }
11571+ if let Some(tx_abort_msg) = tx_abort {
11572+ peer_state.pending_msg_events.push(MessageSendEvent::SendTxAbort {
11573+ node_id: *counterparty_node_id,
11574+ msg: tx_abort_msg,
11575+ });
11576+ }
1157611577
11577- if let Some(splice_funding_failed) = splice_failed {
11578- let pending_events = &mut self.pending_events.lock().unwrap();
11579- pending_events.push_back((
11580- events::Event::SpliceFailed {
11581- channel_id: msg.channel_id,
11582- counterparty_node_id: *counterparty_node_id,
11583- user_channel_id: chan_entry.get().context().get_user_id(),
11584- abandoned_funding_txo: splice_funding_failed.funding_txo,
11585- channel_type: splice_funding_failed.channel_type,
11586- contributed_inputs: splice_funding_failed.contributed_inputs,
11587- contributed_outputs: splice_funding_failed.contributed_outputs,
11588- },
11589- None,
11590- ));
11591- }
11578+ if let Some(splice_funding_failed) = splice_failed {
11579+ let pending_events = &mut self.pending_events.lock().unwrap();
11580+ pending_events.push_back((
11581+ events::Event::SpliceFailed {
11582+ channel_id: msg.channel_id,
11583+ counterparty_node_id: *counterparty_node_id,
11584+ user_channel_id: chan_entry.get().context().get_user_id(),
11585+ abandoned_funding_txo: splice_funding_failed.funding_txo,
11586+ channel_type: splice_funding_failed.channel_type,
11587+ contributed_inputs: splice_funding_failed.contributed_inputs,
11588+ contributed_outputs: splice_funding_failed.contributed_outputs,
11589+ },
11590+ None,
11591+ ));
11592+ }
1159211593
11593- Ok(persist)
11594- },
11595- hash_map::Entry::Vacant(_) => Err(MsgHandleErrInternal::no_such_channel_for_peer(
11596- counterparty_node_id,
11597- msg.channel_id,
11598- )),
11599- }
11594+ let holding_cell_res = if exited_quiescence {
11595+ self.check_free_peer_holding_cells(peer_state)
11596+ } else {
11597+ Vec::new()
11598+ };
11599+ (Ok(persist), holding_cell_res)
11600+ },
11601+ hash_map::Entry::Vacant(_) => (
11602+ Err(MsgHandleErrInternal::no_such_channel_for_peer(
11603+ counterparty_node_id,
11604+ msg.channel_id,
11605+ )),
11606+ Vec::new(),
11607+ ),
11608+ }
11609+ };
11610+
11611+ self.handle_holding_cell_free_result(holding_cell_res);
11612+ result
1160011613 }
1160111614
1160211615 #[rustfmt::skip]
0 commit comments