@@ -10011,6 +10011,61 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10011
10011
Err(MsgHandleErrInternal::send_err_msg_no_close("TODO(splicing): Splicing is not implemented (splice_ack)".to_owned(), msg.channel_id))
10012
10012
}
10013
10013
10014
+ #[cfg(splicing)]
10015
+ fn internal_splice_locked(
10016
+ &self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceLocked,
10017
+ ) -> Result<(), MsgHandleErrInternal> {
10018
+ let per_peer_state = self.per_peer_state.read().unwrap();
10019
+ let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
10020
+ debug_assert!(false);
10021
+ MsgHandleErrInternal::send_err_msg_no_close(
10022
+ format!(
10023
+ "Can't find a peer matching the passed counterparty node_id {}",
10024
+ counterparty_node_id
10025
+ ),
10026
+ msg.channel_id,
10027
+ )
10028
+ })?;
10029
+ let mut peer_state_lock = peer_state_mutex.lock().unwrap();
10030
+ let peer_state = &mut *peer_state_lock;
10031
+
10032
+ // Look for the channel
10033
+ match peer_state.channel_by_id.entry(msg.channel_id) {
10034
+ hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!(
10035
+ "Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}",
10036
+ counterparty_node_id
10037
+ ), msg.channel_id)),
10038
+ hash_map::Entry::Occupied(mut chan_entry) => {
10039
+ if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10040
+ let logger = WithChannelContext::from(&self.logger, &chan.context, None);
10041
+ let announcement_sigs_opt = try_channel_entry!(
10042
+ self, peer_state, chan.splice_locked(
10043
+ msg, &self.node_signer, self.chain_hash, &self.default_configuration,
10044
+ &self.best_block.read().unwrap(), &&logger,
10045
+ ), chan_entry
10046
+ );
10047
+
10048
+ if !chan.has_pending_splice() {
10049
+ let mut short_to_chan_info = self.short_to_chan_info.write().unwrap();
10050
+ insert_short_channel_id!(short_to_chan_info, chan);
10051
+ }
10052
+
10053
+ if let Some(announcement_sigs) = announcement_sigs_opt {
10054
+ log_trace!(logger, "Sending announcement_signatures for channel {}", chan.context.channel_id());
10055
+ peer_state.pending_msg_events.push(MessageSendEvent::SendAnnouncementSignatures {
10056
+ node_id: counterparty_node_id.clone(),
10057
+ msg: announcement_sigs,
10058
+ });
10059
+ }
10060
+ } else {
10061
+ return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot splice".to_owned(), msg.channel_id));
10062
+ }
10063
+ },
10064
+ };
10065
+
10066
+ Ok(())
10067
+ }
10068
+
10014
10069
/// Process pending events from the [`chain::Watch`], returning whether any events were processed.
10015
10070
#[rustfmt::skip]
10016
10071
fn process_pending_monitor_events(&self) -> bool {
@@ -12464,9 +12519,16 @@ where
12464
12519
#[cfg(splicing)]
12465
12520
#[rustfmt::skip]
12466
12521
fn handle_splice_locked(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceLocked) {
12467
- let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
12468
- "Splicing not supported (splice_locked)".to_owned(),
12469
- msg.channel_id)), counterparty_node_id);
12522
+ let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
12523
+ let res = self.internal_splice_locked(&counterparty_node_id, msg);
12524
+ let persist = match &res {
12525
+ Err(e) if e.closes_channel() => NotifyOption::DoPersist,
12526
+ Err(_) => NotifyOption::SkipPersistHandleEvents,
12527
+ Ok(()) => NotifyOption::DoPersist,
12528
+ };
12529
+ let _ = handle_error!(self, res, counterparty_node_id);
12530
+ persist
12531
+ });
12470
12532
}
12471
12533
12472
12534
fn handle_shutdown(&self, counterparty_node_id: PublicKey, msg: &msgs::Shutdown) {
0 commit comments