@@ -11457,90 +11457,106 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1145711457 fn internal_tx_signatures(
1145811458 &self, counterparty_node_id: &PublicKey, msg: &msgs::TxSignatures,
1145911459 ) -> Result<(), MsgHandleErrInternal> {
11460- let per_peer_state = self.per_peer_state.read().unwrap();
11461- let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
11462- debug_assert!(false);
11463- MsgHandleErrInternal::no_such_peer(counterparty_node_id, msg.channel_id)
11464- })?;
11465- let mut peer_state_lock = peer_state_mutex.lock().unwrap();
11466- let peer_state = &mut *peer_state_lock;
11467- match peer_state.channel_by_id.entry(msg.channel_id) {
11468- hash_map::Entry::Occupied(mut chan_entry) => {
11469- match chan_entry.get_mut().as_funded_mut() {
11470- Some(chan) => {
11471- let best_block_height = self.best_block.read().unwrap().height;
11472- let FundingTxSigned {
11473- commitment_signed,
11474- counterparty_initial_commitment_signed_result,
11475- tx_signatures,
11476- funding_tx,
11477- splice_negotiated,
11478- splice_locked,
11479- } = try_channel_entry!(
11480- self,
11481- peer_state,
11482- chan.tx_signatures(msg, best_block_height, &self.logger),
11483- chan_entry
11484- );
11485-
11486- // We should never be sending a `commitment_signed` in response to their
11487- // `tx_signatures`.
11488- debug_assert!(commitment_signed.is_none());
11489- debug_assert!(counterparty_initial_commitment_signed_result.is_none());
11490-
11491- if let Some(tx_signatures) = tx_signatures {
11492- peer_state.pending_msg_events.push(
11493- MessageSendEvent::SendTxSignatures {
11494- node_id: *counterparty_node_id,
11495- msg: tx_signatures,
11496- },
11497- );
11498- }
11499- if let Some(splice_locked) = splice_locked {
11500- peer_state.pending_msg_events.push(
11501- MessageSendEvent::SendSpliceLocked {
11502- node_id: *counterparty_node_id,
11503- msg: splice_locked,
11504- },
11505- );
11506- }
11507- if let Some((ref funding_tx, ref tx_type)) = funding_tx {
11508- self.broadcast_interactive_funding(
11509- chan,
11460+ let (result, holding_cell_res) = {
11461+ let per_peer_state = self.per_peer_state.read().unwrap();
11462+ let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
11463+ debug_assert!(false);
11464+ MsgHandleErrInternal::no_such_peer(counterparty_node_id, msg.channel_id)
11465+ })?;
11466+ let mut peer_state_lock = peer_state_mutex.lock().unwrap();
11467+ let peer_state = &mut *peer_state_lock;
11468+ match peer_state.channel_by_id.entry(msg.channel_id) {
11469+ hash_map::Entry::Occupied(mut chan_entry) => {
11470+ match chan_entry.get_mut().as_funded_mut() {
11471+ Some(chan) => {
11472+ let best_block_height = self.best_block.read().unwrap().height;
11473+ let FundingTxSigned {
11474+ commitment_signed,
11475+ counterparty_initial_commitment_signed_result,
11476+ tx_signatures,
1151011477 funding_tx,
11511- Some(tx_type.clone()),
11512- &self.logger,
11478+ splice_negotiated,
11479+ splice_locked,
11480+ } = try_channel_entry!(
11481+ self,
11482+ peer_state,
11483+ chan.tx_signatures(msg, best_block_height, &self.logger),
11484+ chan_entry
1151311485 );
11514- }
11515- if let Some(splice_negotiated) = splice_negotiated {
11516- self.pending_events.lock().unwrap().push_back((
11517- events::Event::SplicePending {
11518- channel_id: msg.channel_id,
11519- counterparty_node_id: *counterparty_node_id,
11520- user_channel_id: chan.context.get_user_id(),
11521- new_funding_txo: splice_negotiated.funding_txo,
11522- channel_type: splice_negotiated.channel_type,
11523- new_funding_redeem_script: splice_negotiated
11524- .funding_redeem_script,
11525- },
11526- None,
11527- ));
11528- }
11529- },
11530- None => {
11531- let msg = "Got an unexpected tx_signatures message";
11532- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
11533- let err = ChannelError::Close((msg.to_owned(), reason));
11534- try_channel_entry!(self, peer_state, Err(err), chan_entry)
11535- },
11536- }
11537- Ok(())
11538- },
11539- hash_map::Entry::Vacant(_) => Err(MsgHandleErrInternal::no_such_channel_for_peer(
11540- counterparty_node_id,
11541- msg.channel_id,
11542- )),
11543- }
11486+
11487+ // We should never be sending a `commitment_signed` in response to their
11488+ // `tx_signatures`.
11489+ debug_assert!(commitment_signed.is_none());
11490+ debug_assert!(counterparty_initial_commitment_signed_result.is_none());
11491+
11492+ if let Some(tx_signatures) = tx_signatures {
11493+ peer_state.pending_msg_events.push(
11494+ MessageSendEvent::SendTxSignatures {
11495+ node_id: *counterparty_node_id,
11496+ msg: tx_signatures,
11497+ },
11498+ );
11499+ }
11500+ if let Some(splice_locked) = splice_locked {
11501+ peer_state.pending_msg_events.push(
11502+ MessageSendEvent::SendSpliceLocked {
11503+ node_id: *counterparty_node_id,
11504+ msg: splice_locked,
11505+ },
11506+ );
11507+ }
11508+ if let Some((ref funding_tx, ref tx_type)) = funding_tx {
11509+ self.broadcast_interactive_funding(
11510+ chan,
11511+ funding_tx,
11512+ Some(tx_type.clone()),
11513+ &self.logger,
11514+ );
11515+ }
11516+ // We consider a splice negotiated when we exchange `tx_signatures`,
11517+ // which also terminates quiescence.
11518+ let exited_quiescence = splice_negotiated.is_some();
11519+ if let Some(splice_negotiated) = splice_negotiated {
11520+ self.pending_events.lock().unwrap().push_back((
11521+ events::Event::SplicePending {
11522+ channel_id: msg.channel_id,
11523+ counterparty_node_id: *counterparty_node_id,
11524+ user_channel_id: chan.context.get_user_id(),
11525+ new_funding_txo: splice_negotiated.funding_txo,
11526+ channel_type: splice_negotiated.channel_type,
11527+ new_funding_redeem_script: splice_negotiated
11528+ .funding_redeem_script,
11529+ },
11530+ None,
11531+ ));
11532+ }
11533+ let holding_cell_res = if exited_quiescence {
11534+ self.check_free_peer_holding_cells(peer_state)
11535+ } else {
11536+ Vec::new()
11537+ };
11538+ (Ok(()), holding_cell_res)
11539+ },
11540+ None => {
11541+ let msg = "Got an unexpected tx_signatures message";
11542+ let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
11543+ let err = ChannelError::Close((msg.to_owned(), reason));
11544+ try_channel_entry!(self, peer_state, Err(err), chan_entry)
11545+ },
11546+ }
11547+ },
11548+ hash_map::Entry::Vacant(_) => (
11549+ Err(MsgHandleErrInternal::no_such_channel_for_peer(
11550+ counterparty_node_id,
11551+ msg.channel_id,
11552+ )),
11553+ Vec::new(),
11554+ ),
11555+ }
11556+ };
11557+
11558+ self.handle_holding_cell_free_result(holding_cell_res);
11559+ result
1154411560 }
1154511561
1154611562 fn internal_tx_abort(
0 commit comments