Skip to content

Commit 2dd627d

Browse files
committed
Add a TODO for an important issue for making async mon updates safe
If we receive a monitor event from a forwarded-to channel which contains a preimage for an HTLC, we have to propogate that preimage back to the forwarded-from channel monitor. However, once we have that update, we're running in a relatively unsafe state - we have the preimage in memory, but if we were to crash the forwarded-to channel monitor will not regenerate the update with the preimage for us. If we haven't managed to write the monitor update to the forwarded-from channel by that point, we've lost the preimage, and, thus, money!
1 parent 882f1d8 commit 2dd627d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4318,8 +4318,12 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
43184318
// event being update_fulfill_htlc).
43194319
let update_res = self.chain_monitor.update_channel(prev_outpoint, preimage_update);
43204320
if update_res != ChannelMonitorUpdateResult::UpdateComplete {
4321+
// TODO: This needs to be handled somehow - if we receive a monitor update
4322+
// with a preimage we *must* somehow manage to propagate it to the upstream
4323+
// channel, or we must have an ability to receive the same event and try
4324+
// again on restart.
43214325
log_error!(self.logger, "Critical error: failed to update channel monitor with preimage {:?}: {:?}",
4322-
payment_preimage, update_res);
4326+
payment_preimage, update_res);
43234327
}
43244328
// Note that we do *not* set `claimed_htlc` to false here. In fact, this
43254329
// totally could be a duplicate claim, but we have no way of knowing

0 commit comments

Comments
 (0)