@@ -10121,6 +10121,61 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
10121
10121
Err(MsgHandleErrInternal::send_err_msg_no_close("TODO(splicing): Splicing is not implemented (splice_ack)".to_owned(), msg.channel_id))
10122
10122
}
10123
10123
10124
+ #[cfg(splicing)]
10125
+ fn internal_splice_locked(
10126
+ &self, counterparty_node_id: &PublicKey, msg: &msgs::SpliceLocked,
10127
+ ) -> Result<(), MsgHandleErrInternal> {
10128
+ let per_peer_state = self.per_peer_state.read().unwrap();
10129
+ let peer_state_mutex = per_peer_state.get(counterparty_node_id).ok_or_else(|| {
10130
+ debug_assert!(false);
10131
+ MsgHandleErrInternal::send_err_msg_no_close(
10132
+ format!(
10133
+ "Can't find a peer matching the passed counterparty node_id {}",
10134
+ counterparty_node_id
10135
+ ),
10136
+ msg.channel_id,
10137
+ )
10138
+ })?;
10139
+ let mut peer_state_lock = peer_state_mutex.lock().unwrap();
10140
+ let peer_state = &mut *peer_state_lock;
10141
+
10142
+ // Look for the channel
10143
+ match peer_state.channel_by_id.entry(msg.channel_id) {
10144
+ hash_map::Entry::Vacant(_) => return Err(MsgHandleErrInternal::send_err_msg_no_close(format!(
10145
+ "Got a message for a channel from the wrong node! No such channel for the passed counterparty_node_id {}",
10146
+ counterparty_node_id
10147
+ ), msg.channel_id)),
10148
+ hash_map::Entry::Occupied(mut chan_entry) => {
10149
+ if let Some(chan) = chan_entry.get_mut().as_funded_mut() {
10150
+ let logger = WithChannelContext::from(&self.logger, &chan.context, None);
10151
+ let announcement_sigs_opt = try_channel_entry!(
10152
+ self, peer_state, chan.splice_locked(
10153
+ msg, &self.node_signer, self.chain_hash, &self.default_configuration,
10154
+ &self.best_block.read().unwrap(), &&logger,
10155
+ ), chan_entry
10156
+ );
10157
+
10158
+ if !chan.has_pending_splice() {
10159
+ let mut short_to_chan_info = self.short_to_chan_info.write().unwrap();
10160
+ insert_short_channel_id!(short_to_chan_info, chan);
10161
+ }
10162
+
10163
+ if let Some(announcement_sigs) = announcement_sigs_opt {
10164
+ log_trace!(logger, "Sending announcement_signatures for channel {}", chan.context.channel_id());
10165
+ peer_state.pending_msg_events.push(MessageSendEvent::SendAnnouncementSignatures {
10166
+ node_id: counterparty_node_id.clone(),
10167
+ msg: announcement_sigs,
10168
+ });
10169
+ }
10170
+ } else {
10171
+ return Err(MsgHandleErrInternal::send_err_msg_no_close("Channel is not funded, cannot splice".to_owned(), msg.channel_id));
10172
+ }
10173
+ },
10174
+ };
10175
+
10176
+ Ok(())
10177
+ }
10178
+
10124
10179
/// Process pending events from the [`chain::Watch`], returning whether any events were processed.
10125
10180
#[rustfmt::skip]
10126
10181
fn process_pending_monitor_events(&self) -> bool {
@@ -12612,9 +12667,16 @@ where
12612
12667
#[cfg(splicing)]
12613
12668
#[rustfmt::skip]
12614
12669
fn handle_splice_locked(&self, counterparty_node_id: PublicKey, msg: &msgs::SpliceLocked) {
12615
- let _: Result<(), _> = handle_error!(self, Err(MsgHandleErrInternal::send_err_msg_no_close(
12616
- "Splicing not supported (splice_locked)".to_owned(),
12617
- msg.channel_id)), counterparty_node_id);
12670
+ let _persistence_guard = PersistenceNotifierGuard::optionally_notify(self, || {
12671
+ let res = self.internal_splice_locked(&counterparty_node_id, msg);
12672
+ let persist = match &res {
12673
+ Err(e) if e.closes_channel() => NotifyOption::DoPersist,
12674
+ Err(_) => NotifyOption::SkipPersistHandleEvents,
12675
+ Ok(()) => NotifyOption::DoPersist,
12676
+ };
12677
+ let _ = handle_error!(self, res, counterparty_node_id);
12678
+ persist
12679
+ });
12618
12680
}
12619
12681
12620
12682
fn handle_shutdown(&self, counterparty_node_id: PublicKey, msg: &msgs::Shutdown) {
0 commit comments