Skip to content

Commit 62c1bd5

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 0cc2041 commit 62c1bd5

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1886,12 +1886,17 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
18861886
} else if self.latest_update_id + 1 != updates.update_id {
18871887
panic!("Attempted to apply ChannelMonitorUpdates out of order, check the update_id before passing an update to update_monitor!");
18881888
}
1889+
let mut ret = Ok(());
18891890
for update in updates.updates.iter() {
18901891
match update {
18911892
ChannelMonitorUpdateStep::LatestHolderCommitmentTXInfo { commitment_tx, htlc_outputs } => {
18921893
log_trace!(logger, "Updating ChannelMonitor with latest holder commitment transaction info");
18931894
if self.lockdown_from_offchain { panic!(); }
1894-
self.provide_latest_holder_commitment_tx(commitment_tx.clone(), htlc_outputs.clone())?
1895+
if let Err(e) = self.provide_latest_holder_commitment_tx(commitment_tx.clone(), htlc_outputs.clone()) {
1896+
log_error!(logger, "Providing latest holder commitment transaction failed/was refused:");
1897+
log_error!(logger, " {}", e.0);
1898+
ret = Err(e);
1899+
}
18951900
}
18961901
ChannelMonitorUpdateStep::LatestCounterpartyCommitmentTXInfo { commitment_txid, htlc_outputs, commitment_number, their_revocation_point } => {
18971902
log_trace!(logger, "Updating ChannelMonitor with latest counterparty commitment transaction info");
@@ -1903,7 +1908,11 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19031908
},
19041909
ChannelMonitorUpdateStep::CommitmentSecret { idx, secret } => {
19051910
log_trace!(logger, "Updating ChannelMonitor with commitment secret");
1906-
self.provide_secret(*idx, *secret)?
1911+
if let Err(e) = self.provide_secret(*idx, *secret) {
1912+
log_error!(logger, "Providing latest counterparty commitment secret failed/was refused:");
1913+
log_error!(logger, " {}", e.0);
1914+
ret = Err(e);
1915+
}
19071916
},
19081917
ChannelMonitorUpdateStep::ChannelForceClosed { should_broadcast } => {
19091918
log_trace!(logger, "Updating ChannelMonitor: channel force closed, should broadcast: {}", should_broadcast);
@@ -1928,7 +1937,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
19281937
}
19291938
}
19301939
self.latest_update_id = updates.update_id;
1931-
Ok(())
1940+
ret
19321941
}
19331942

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

0 commit comments

Comments
 (0)