@@ -60,9 +60,9 @@ use crate::ln::chan_utils::selected_commitment_sat_per_1000_weight;
6060// Since this struct is returned in `list_channels` methods, expose it here in case users want to
6161// construct one themselves.
6262use crate::ln::channel::{
63- self, hold_time_since, Channel, ChannelError, ChannelUpdateStatus, FundedChannel ,
64- InboundV1Channel, OutboundV1Channel, PendingV2Channel, ReconnectionMsg, ShutdownResult ,
65- UpdateFulfillCommitFetch, WithChannelContext,
63+ self, hold_time_since, Channel, ChannelError, ChannelUpdateStatus, CommitmentSignedResult ,
64+ FundedChannel, InboundV1Channel, OutboundV1Channel, PendingV2Channel, ReconnectionMsg,
65+ ShutdownResult, UpdateFulfillCommitFetch, WithChannelContext,
6666};
6767use crate::ln::channel_state::ChannelDetails;
6868use crate::ln::inbound_payment;
@@ -135,6 +135,7 @@ use crate::util::wakers::{Future, Notifier};
135135
136136#[cfg(all(test, async_payments))]
137137use crate::blinded_path::payment::BlindedPaymentPath;
138+
138139#[cfg(async_payments)]
139140use {
140141 crate::blinded_path::message::BlindedMessagePath,
@@ -10346,27 +10347,32 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
1034610347 let chan = chan_entry.get_mut();
1034710348 let logger = WithChannelContext::from(&self.logger, &chan.context(), None);
1034810349 let funding_txo = chan.funding().get_funding_txo();
10349- let (monitor_opt, monitor_update_opt, _) = try_channel_entry!(
10350+ let res = try_channel_entry!(
1035010351 self, peer_state, chan.commitment_signed(msg, best_block, &self.signer_provider, &&logger),
1035110352 chan_entry);
1035210353
1035310354 if let Some(chan) = chan.as_funded_mut() {
10354- if let Some(monitor) = monitor_opt {
10355- let monitor_res = self.chain_monitor.watch_channel(monitor.channel_id(), monitor);
10356- if let Ok(persist_state) = monitor_res {
10357- handle_new_monitor_update!(self, persist_state, peer_state_lock, peer_state,
10358- per_peer_state, chan, INITIAL_MONITOR);
10359- } else {
10360- let logger = WithChannelContext::from(&self.logger, &chan.context, None);
10361- log_error!(logger, "Persisting initial ChannelMonitor failed, implying the channel ID was duplicated");
10362- let msg = "Channel ID was a duplicate";
10363- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
10364- let err = ChannelError::Close((msg.to_owned(), reason));
10365- try_channel_entry!(self, peer_state, Err(err), chan_entry)
10366- }
10367- } else if let Some(monitor_update) = monitor_update_opt {
10368- handle_new_monitor_update!(self, funding_txo.unwrap(), monitor_update, peer_state_lock,
10369- peer_state, per_peer_state, chan);
10355+ let monitor = match res {
10356+ CommitmentSignedResult::ChannelMonitor(monitor) => monitor,
10357+ CommitmentSignedResult::ChannelMonitorUpdate(monitor_update) => {
10358+ handle_new_monitor_update!(self, funding_txo.unwrap(), monitor_update, peer_state_lock,
10359+ peer_state, per_peer_state, chan);
10360+ return Ok(());
10361+ },
10362+ CommitmentSignedResult::None => return Ok(()),
10363+ };
10364+
10365+ let monitor_res = self.chain_monitor.watch_channel(monitor.channel_id(), monitor);
10366+ if let Ok(persist_state) = monitor_res {
10367+ handle_new_monitor_update!(self, persist_state, peer_state_lock, peer_state,
10368+ per_peer_state, chan, INITIAL_MONITOR);
10369+ } else {
10370+ let logger = WithChannelContext::from(&self.logger, &chan.context, None);
10371+ log_error!(logger, "Persisting initial ChannelMonitor failed, implying the channel ID was duplicated");
10372+ let msg = "Channel ID was a duplicate";
10373+ let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
10374+ let err = ChannelError::Close((msg.to_owned(), reason));
10375+ try_channel_entry!(self, peer_state, Err(err), chan_entry)
1037010376 }
1037110377 }
1037210378 Ok(())
0 commit comments