X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannelmonitor.rs;h=7a6bac9c7fba4bf30da188ef8842a569f986c4da;hb=c89514c37c8c2632cb32f1fb00764f9d7f2ce7f8;hp=950b50f3a386bbaa6c582bc2d550df7902b09960;hpb=3c5ba6b619fdb02582a71081f0a2c2ef57990365;p=rust-lightning diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 950b50f3..7a6bac9c 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -290,16 +290,9 @@ impl return Err(MonitorUpdateError("Channel monitor for given key is already present")), hash_map::Entry::Vacant(e) => e, }; - match monitor.onchain_detection.funding_info { - None => { - return Err(MonitorUpdateError("Try to update a useless monitor without funding_txo !")); - }, - Some((ref outpoint, ref script)) => { - log_trace!(self, "Got new Channel Monitor for channel {}", log_bytes!(outpoint.to_channel_id()[..])); - self.chain_monitor.install_watch_tx(&outpoint.txid, script); - self.chain_monitor.install_watch_outpoint((outpoint.txid, outpoint.index as u32), script); - }, - } + log_trace!(self, "Got new Channel Monitor for channel {}", log_bytes!(monitor.funding_info.0.to_channel_id()[..])); + self.chain_monitor.install_watch_tx(&monitor.funding_info.0.txid, &monitor.funding_info.1); + self.chain_monitor.install_watch_outpoint((monitor.funding_info.0.txid, monitor.funding_info.0.index as u32), &monitor.funding_info.1); for (txid, outputs) in monitor.get_outputs_to_watch().iter() { for (idx, script) in outputs.iter().enumerate() { self.chain_monitor.install_watch_outpoint((*txid, idx as u32), script); @@ -314,7 +307,7 @@ impl { - log_trace!(self, "Updating Channel Monitor for channel {}", log_funding_info!(orig_monitor.onchain_detection)); + log_trace!(self, "Updating Channel Monitor for channel {}", log_funding_info!(orig_monitor)); orig_monitor.update_monitor(update, &self.broadcaster) }, None => Err(MonitorUpdateError("No such monitor registered")) @@ -391,20 +384,6 @@ pub(crate) const LATENCY_GRACE_PERIOD_BLOCKS: u32 = 3; /// keeping bumping another claim tx to solve the outpoint. pub(crate) const ANTI_REORG_DELAY: u32 = 6; -struct OnchainDetection { - keys: ChanSigner, - funding_info: Option<(OutPoint, Script)>, - current_remote_commitment_txid: Option, - prev_remote_commitment_txid: Option, -} - -#[cfg(any(test, feature = "fuzztarget"))] -impl PartialEq for OnchainDetection { - fn eq(&self, other: &Self) -> bool { - self.keys.pubkeys() == other.keys.pubkeys() - } -} - #[derive(Clone, PartialEq)] struct LocalSignedTx { /// txid of the transaction in tx, just used to make comparison faster @@ -734,16 +713,20 @@ pub struct ChannelMonitor { broadcasted_remote_payment_script: Option<(Script, SecretKey)>, shutdown_script: Script, - onchain_detection: OnchainDetection, - their_htlc_base_key: Option, - their_delayed_payment_base_key: Option, - funding_redeemscript: Option