Skip to content

Commit 0e06f6c

Browse files
committed
Continue after a single failure in ChannelMonitor::update_monitor
`ChannelMonitorUpdate`s may contain multiple updates, including, eg a payment preimage after a commitment transaction update. While such updates are generally not generated today, we shouldn't return early out of the update loop, causing us to miss any updates after an earlier update fails.
1 parent 14dcc9b commit 0e06f6c

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,12 +1796,15 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
17961796
} else if self.latest_update_id + 1 != updates.update_id {
17971797
panic!("Attempted to apply ChannelMonitorUpdates out of order, check the update_id before passing an update to update_monitor!");
17981798
}
1799+
let mut ret = Ok(());
17991800
for update in updates.updates.iter() {
18001801
match update {
18011802
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs } => {
18021803
log_trace!(logger, "Updating ChannelMonitor with latest holder commitment transaction info");
18031804
if self.lockdown_from_offchain { panic!(); }
1804-
self.provide_latest_holder_commitment_tx(commitment_tx.clone(), htlc_outputs.clone())?
1805+
if let Err(e) = self.provide_latest_holder_commitment_tx(commitment_tx.clone(), htlc_outputs.clone()) {
1806+
ret = Err(e);
1807+
}
18051808
}
18061809
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { commitment_txid, htlc_outputs, commitment_number, their_revocation_point } => {
18071810
log_trace!(logger, "Updating ChannelMonitor with latest counterparty commitment transaction info");
@@ -1813,7 +1816,9 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
18131816
},
18141817
ChannelMonitorUpdateStep::CommitmentSecret { idx, secret } => {
18151818
log_trace!(logger, "Updating ChannelMonitor with commitment secret");
1816-
self.provide_secret(*idx, *secret)?
1819+
if let Err(e) = self.provide_secret(*idx, *secret) {
1820+
ret = Err(e);
1821+
}
18171822
},
18181823
ChannelMonitorUpdateStep::ChannelForceClosed { should_broadcast } => {
18191824
log_trace!(logger, "Updating ChannelMonitor: channel force closed, should broadcast: {}", should_broadcast);
@@ -1838,7 +1843,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
18381843
}
18391844
}
18401845
self.latest_update_id = updates.update_id;
1841-
Ok(())
1846+
ret
18421847
}
18431848

18441849
pub fn get_latest_update_id(&self) -> u64 {

0 commit comments

Comments
 (0)