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