@@ -130,8 +130,10 @@ use crate::util::ser::{
130
130
};
131
131
use crate::util::wakers::{Future, Notifier};
132
132
133
+ use super::channel::CommitmentSignedResult;
133
134
#[cfg(all(test, async_payments))]
134
135
use crate::blinded_path::payment::BlindedPaymentPath;
136
+
135
137
#[cfg(async_payments)]
136
138
use {
137
139
crate::blinded_path::message::BlindedMessagePath,
@@ -9630,27 +9632,32 @@ This indicates a bug inside LDK. Please report this error at https://github.com/
9630
9632
let chan = chan_entry.get_mut();
9631
9633
let logger = WithChannelContext::from(&self.logger, &chan.context(), None);
9632
9634
let funding_txo = chan.funding().get_funding_txo();
9633
- let (monitor_opt, monitor_update_opt, _) = try_channel_entry!(
9635
+ let res = try_channel_entry!(
9634
9636
self, peer_state, chan.commitment_signed(msg, best_block, &self.signer_provider, &&logger),
9635
9637
chan_entry);
9636
9638
9637
9639
if let Some(chan) = chan.as_funded_mut() {
9638
- if let Some(monitor) = monitor_opt {
9639
- let monitor_res = self.chain_monitor.watch_channel(monitor.channel_id(), monitor);
9640
- if let Ok(persist_state) = monitor_res {
9641
- handle_new_monitor_update!(self, persist_state, peer_state_lock, peer_state,
9642
- per_peer_state, chan, INITIAL_MONITOR);
9643
- } else {
9644
- let logger = WithChannelContext::from(&self.logger, &chan.context, None);
9645
- log_error!(logger, "Persisting initial ChannelMonitor failed, implying the channel ID was duplicated");
9646
- let msg = "Channel ID was a duplicate";
9647
- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
9648
- let err = ChannelError::Close((msg.to_owned(), reason));
9649
- try_channel_entry!(self, peer_state, Err(err), chan_entry)
9650
- }
9651
- } else if let Some(monitor_update) = monitor_update_opt {
9652
- handle_new_monitor_update!(self, funding_txo.unwrap(), monitor_update, peer_state_lock,
9653
- peer_state, per_peer_state, chan);
9640
+ let monitor = match res {
9641
+ CommitmentSignedResult::ChannelMonitor(monitor) => monitor,
9642
+ CommitmentSignedResult::ChannelMonitorUpdate(monitor_update) => {
9643
+ handle_new_monitor_update!(self, funding_txo.unwrap(), monitor_update, peer_state_lock,
9644
+ peer_state, per_peer_state, chan);
9645
+ return Ok(());
9646
+ },
9647
+ CommitmentSignedResult::None => return Ok(()),
9648
+ };
9649
+
9650
+ let monitor_res = self.chain_monitor.watch_channel(monitor.channel_id(), monitor);
9651
+ if let Ok(persist_state) = monitor_res {
9652
+ handle_new_monitor_update!(self, persist_state, peer_state_lock, peer_state,
9653
+ per_peer_state, chan, INITIAL_MONITOR);
9654
+ } else {
9655
+ let logger = WithChannelContext::from(&self.logger, &chan.context, None);
9656
+ log_error!(logger, "Persisting initial ChannelMonitor failed, implying the channel ID was duplicated");
9657
+ let msg = "Channel ID was a duplicate";
9658
+ let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
9659
+ let err = ChannelError::Close((msg.to_owned(), reason));
9660
+ try_channel_entry!(self, peer_state, Err(err), chan_entry)
9654
9661
}
9655
9662
}
9656
9663
Ok(())
0 commit comments