X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=lightning%2Fsrc%2Fln%2Fchannelmanager.rs;h=a471ca3f3675fcab67677381164c7dc69dd8903a;hb=42587500d02e3d403fab4068693c2b0341ddeba4;hp=e9dfe5a5680c60249d02954865141a8054e0cc96;hpb=86143fd69ddf88a03fc19244aca33ec598ee1720;p=rust-lightning diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs index e9dfe5a5..a471ca3f 100644 --- a/lightning/src/ln/channelmanager.rs +++ b/lightning/src/ln/channelmanager.rs @@ -3417,10 +3417,17 @@ impl<'a, ChanSigner: ChannelKeys + Readable, M: Deref, T: Deref, K: Deref, F: De let funding_txo = channel.get_funding_txo().ok_or(DecodeError::InvalidValue)?; funding_txo_set.insert(funding_txo.clone()); if let Some(ref mut monitor) = args.channel_monitors.get_mut(&funding_txo) { - if channel.get_cur_local_commitment_transaction_number() != monitor.get_cur_local_commitment_number() || - channel.get_revoked_remote_commitment_transaction_number() != monitor.get_min_seen_secret() || - channel.get_cur_remote_commitment_transaction_number() != monitor.get_cur_remote_commitment_number() || - channel.get_latest_monitor_update_id() != monitor.get_latest_update_id() { + if channel.get_cur_local_commitment_transaction_number() < monitor.get_cur_local_commitment_number() || + channel.get_revoked_remote_commitment_transaction_number() < monitor.get_min_seen_secret() || + channel.get_cur_remote_commitment_transaction_number() < monitor.get_cur_remote_commitment_number() || + channel.get_latest_monitor_update_id() > monitor.get_latest_update_id() { + // If the channel is ahead of the monitor, return InvalidValue: + return Err(DecodeError::InvalidValue); + } else if channel.get_cur_local_commitment_transaction_number() > monitor.get_cur_local_commitment_number() || + channel.get_revoked_remote_commitment_transaction_number() > monitor.get_min_seen_secret() || + channel.get_cur_remote_commitment_transaction_number() > monitor.get_cur_remote_commitment_number() || + channel.get_latest_monitor_update_id() < monitor.get_latest_update_id() { + // But if the channel is behind of the monitor, close the channel: let (_, _, mut new_failed_htlcs) = channel.force_shutdown(true); failed_htlcs.append(&mut new_failed_htlcs); monitor.broadcast_latest_local_commitment_txn(&args.tx_broadcaster);