@@ -11434,90 +11434,106 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1143411434 fn internal_tx_signatures(
1143511435 &self, counterparty_node_id: &PublicKey, msg: &msgs::TxSignatures,
1143611436 ) -> Result<(), MsgHandleErrInternal> {
11437- let per_peer_state = self.per_peer_state.read().unwrap();
11438- let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
11439- debug_assert!(false);
11440- MsgHandleErrInternal::no_such_peer(counterparty_node_id, msg.channel_id)
11441- })?;
11442- let mut peer_state_lock = peer_state_mutex.lock().unwrap();
11443- let peer_state = &mut *peer_state_lock;
11444- match peer_state.channel_by_id.entry(msg.channel_id) {
11445- hash_map::Entry::Occupied(mut chan_entry) => {
11446- match chan_entry.get_mut().as_funded_mut() {
11447- Some(chan) => {
11448- let best_block_height = self.best_block.read().unwrap().height;
11449- let FundingTxSigned {
11450- commitment_signed,
11451- counterparty_initial_commitment_signed_result,
11452- tx_signatures,
11453- funding_tx,
11454- splice_negotiated,
11455- splice_locked,
11456- } = try_channel_entry!(
11457- self,
11458- peer_state,
11459- chan.tx_signatures(msg, best_block_height, &self.logger),
11460- chan_entry
11461- );
11462-
11463- // We should never be sending a `commitment_signed` in response to their
11464- // `tx_signatures`.
11465- debug_assert!(commitment_signed.is_none());
11466- debug_assert!(counterparty_initial_commitment_signed_result.is_none());
11467-
11468- if let Some(tx_signatures) = tx_signatures {
11469- peer_state.pending_msg_events.push(
11470- MessageSendEvent::SendTxSignatures {
11471- node_id: *counterparty_node_id,
11472- msg: tx_signatures,
11473- },
11474- );
11475- }
11476- if let Some(splice_locked) = splice_locked {
11477- peer_state.pending_msg_events.push(
11478- MessageSendEvent::SendSpliceLocked {
11479- node_id: *counterparty_node_id,
11480- msg: splice_locked,
11481- },
11482- );
11483- }
11484- if let Some((ref funding_tx, ref tx_type)) = funding_tx {
11485- self.broadcast_interactive_funding(
11486- chan,
11437+ let (result, holding_cell_res) = {
11438+ let per_peer_state = self.per_peer_state.read().unwrap();
11439+ let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
11440+ debug_assert!(false);
11441+ MsgHandleErrInternal::no_such_peer(counterparty_node_id, msg.channel_id)
11442+ })?;
11443+ let mut peer_state_lock = peer_state_mutex.lock().unwrap();
11444+ let peer_state = &mut *peer_state_lock;
11445+ match peer_state.channel_by_id.entry(msg.channel_id) {
11446+ hash_map::Entry::Occupied(mut chan_entry) => {
11447+ match chan_entry.get_mut().as_funded_mut() {
11448+ Some(chan) => {
11449+ let best_block_height = self.best_block.read().unwrap().height;
11450+ let FundingTxSigned {
11451+ commitment_signed,
11452+ counterparty_initial_commitment_signed_result,
11453+ tx_signatures,
1148711454 funding_tx,
11488- Some(tx_type.clone()),
11489- &self.logger,
11455+ splice_negotiated,
11456+ splice_locked,
11457+ } = try_channel_entry!(
11458+ self,
11459+ peer_state,
11460+ chan.tx_signatures(msg, best_block_height, &self.logger),
11461+ chan_entry
1149011462 );
11491- }
11492- if let Some(splice_negotiated) = splice_negotiated {
11493- self.pending_events.lock().unwrap().push_back((
11494- events::Event::SplicePending {
11495- channel_id: msg.channel_id,
11496- counterparty_node_id: *counterparty_node_id,
11497- user_channel_id: chan.context.get_user_id(),
11498- new_funding_txo: splice_negotiated.funding_txo,
11499- channel_type: splice_negotiated.channel_type,
11500- new_funding_redeem_script: splice_negotiated
11501- .funding_redeem_script,
11502- },
11503- None,
11504- ));
11505- }
11506- },
11507- None => {
11508- let msg = "Got an unexpected tx_signatures message";
11509- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
11510- let err = ChannelError::Close((msg.to_owned(), reason));
11511- try_channel_entry!(self, peer_state, Err(err), chan_entry)
11512- },
11513- }
11514- Ok(())
11515- },
11516- hash_map::Entry::Vacant(_) => Err(MsgHandleErrInternal::no_such_channel_for_peer(
11517- counterparty_node_id,
11518- msg.channel_id,
11519- )),
11520- }
11463+
11464+ // We should never be sending a `commitment_signed` in response to their
11465+ // `tx_signatures`.
11466+ debug_assert!(commitment_signed.is_none());
11467+ debug_assert!(counterparty_initial_commitment_signed_result.is_none());
11468+
11469+ if let Some(tx_signatures) = tx_signatures {
11470+ peer_state.pending_msg_events.push(
11471+ MessageSendEvent::SendTxSignatures {
11472+ node_id: *counterparty_node_id,
11473+ msg: tx_signatures,
11474+ },
11475+ );
11476+ }
11477+ if let Some(splice_locked) = splice_locked {
11478+ peer_state.pending_msg_events.push(
11479+ MessageSendEvent::SendSpliceLocked {
11480+ node_id: *counterparty_node_id,
11481+ msg: splice_locked,
11482+ },
11483+ );
11484+ }
11485+ if let Some((ref funding_tx, ref tx_type)) = funding_tx {
11486+ self.broadcast_interactive_funding(
11487+ chan,
11488+ funding_tx,
11489+ Some(tx_type.clone()),
11490+ &self.logger,
11491+ );
11492+ }
11493+ // We consider a splice negotiated when we exchange `tx_signatures`,
11494+ // which also terminates quiescence.
11495+ let exited_quiescence = splice_negotiated.is_some();
11496+ if let Some(splice_negotiated) = splice_negotiated {
11497+ self.pending_events.lock().unwrap().push_back((
11498+ events::Event::SplicePending {
11499+ channel_id: msg.channel_id,
11500+ counterparty_node_id: *counterparty_node_id,
11501+ user_channel_id: chan.context.get_user_id(),
11502+ new_funding_txo: splice_negotiated.funding_txo,
11503+ channel_type: splice_negotiated.channel_type,
11504+ new_funding_redeem_script: splice_negotiated
11505+ .funding_redeem_script,
11506+ },
11507+ None,
11508+ ));
11509+ }
11510+ let holding_cell_res = if exited_quiescence {
11511+ self.check_free_peer_holding_cells(peer_state)
11512+ } else {
11513+ Vec::new()
11514+ };
11515+ (Ok(()), holding_cell_res)
11516+ },
11517+ None => {
11518+ let msg = "Got an unexpected tx_signatures message";
11519+ let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
11520+ let err = ChannelError::Close((msg.to_owned(), reason));
11521+ try_channel_entry!(self, peer_state, Err(err), chan_entry)
11522+ },
11523+ }
11524+ },
11525+ hash_map::Entry::Vacant(_) => (
11526+ Err(MsgHandleErrInternal::no_such_channel_for_peer(
11527+ counterparty_node_id,
11528+ msg.channel_id,
11529+ )),
11530+ Vec::new(),
11531+ ),
11532+ }
11533+ };
11534+
11535+ self.handle_holding_cell_free_result(holding_cell_res);
11536+ result
1152111537 }
1152211538
1152311539 fn internal_tx_abort(
0 commit comments