@@ -10002,6 +10002,61 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1000210002 Err(MsgHandleErrInternal::send_err_msg_no_close("TODO(splicing): Splicing is not implemented (splice_ack)".to_owned(), msg.channel_id))
1000310003 }
1000410004
10005+ #[cfg(splicing)]
10006+ fn internal_splice_locked(
10007+ &self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceLocked,
10008+ ) -> Result<(), MsgHandleErrInternal> {
10009+ let per_peer_state = self.per_peer_state.read().unwrap();
10010+ let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
10011+ debug_assert!(false);
10012+ MsgHandleErrInternal::send_err_msg_no_close(
10013+ format!(
10014+ "Can't find a peer matching the passed counterparty node_id {}",
10015+ counterparty_node_id
10016+ ),
10017+ msg.channel_id,
10018+ )
10019+ })?;
10020+ let mut peer_state_lock = peer_state_mutex.lock().unwrap();
10021+ let peer_state = &mut *peer_state_lock;
10022+
10023+ // Look for the channel
10024+ match peer_state.channel_by_id.entry(msg.channel_id) {
10025+ hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!(
10026+ "Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}",
10027+ counterparty_node_id
10028+ ), msg.channel_id)),
10029+ hash_map::Entry::Occupied(mut chan_entry) => {
10030+ if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10031+ let logger = WithChannelContext::from(&self.logger, &chan.context, None);
10032+ let announcement_sigs_opt = try_channel_entry!(
10033+ self, peer_state, chan.splice_locked(
10034+ msg, &self.node_signer, self.chain_hash, &self.default_configuration,
10035+ &self.best_block.read().unwrap(), &&logger,
10036+ ), chan_entry
10037+ );
10038+
10039+ if !chan.has_pending_splice() {
10040+ let mut short_to_chan_info = self.short_to_chan_info.write().unwrap();
10041+ insert_short_channel_id!(short_to_chan_info, chan);
10042+ }
10043+
10044+ if let Some(announcement_sigs) = announcement_sigs_opt {
10045+ log_trace!(logger, "Sending announcement_signatures for channel {}", chan.context.channel_id());
10046+ peer_state.pending_msg_events.push(MessageSendEvent::SendAnnouncementSignatures {
10047+ node_id: counterparty_node_id.clone(),
10048+ msg: announcement_sigs,
10049+ });
10050+ }
10051+ } else {
10052+ return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot splice".to_owned(), msg.channel_id));
10053+ }
10054+ },
10055+ };
10056+
10057+ Ok(())
10058+ }
10059+
1000510060 /// Process pending events from the [`chain::Watch`], returning whether any events were processed.
1000610061 #[rustfmt::skip]
1000710062 fn process_pending_monitor_events(&self) -> bool {
@@ -12455,9 +12510,16 @@ where
1245512510 #[cfg(splicing)]
1245612511 #[rustfmt::skip]
1245712512 fn handle_splice_locked(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceLocked) {
12458- let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
12459- "Splicing not supported (splice_locked)".to_owned(),
12460- msg.channel_id)), counterparty_node_id);
12513+ let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
12514+ let res = self.internal_splice_locked(&counterparty_node_id, msg);
12515+ let persist = match &res {
12516+ Err(e) if e.closes_channel() => NotifyOption::DoPersist,
12517+ Err(_) => NotifyOption::SkipPersistHandleEvents,
12518+ Ok(()) => NotifyOption::DoPersist,
12519+ };
12520+ let _ = handle_error!(self, res, counterparty_node_id);
12521+ persist
12522+ });
1246112523 }
1246212524
1246312525 fn handle_shutdown(&self, counterparty_node_id: PublicKey, msg: &msgs::Shutdown) {
0 commit comments