Fix fee addition overflow in get_route
[rust-lightning] / src / ln / channelmonitor.rs
index 1e8f8038c4c1846ff5c5108606ba6a5c62c83ba1..3fb1d8ad836e590dd54c6c5f09e34f9c767fdea9 100644 (file)
@@ -94,7 +94,10 @@ impl<Key : Send + cmp::Eq + hash::Hash + 'static> SimpleManyChannelMonitor<Key>
                };
                match &monitor.funding_txo {
                        &None => self.chain_monitor.watch_all_txn(),
-                       &Some((ref outpoint, ref script)) => self.chain_monitor.install_watch_outpoint((outpoint.txid, outpoint.index as u32), script),
+                       &Some((ref outpoint, ref script)) => {
+                               self.chain_monitor.install_watch_script(script);
+                               self.chain_monitor.install_watch_outpoint((outpoint.txid, outpoint.index as u32), script);
+                       },
                }
                monitors.insert(key, monitor);
                Ok(())
@@ -316,7 +319,7 @@ impl ChannelMonitor {
                for i in 0..pos {
                        let (old_secret, old_idx) = self.old_secrets[i as usize];
                        if ChannelMonitor::derive_secret(secret, pos, old_idx) != old_secret {
-                               return Err(HandleError{err: "Previous secret did not match new one", msg: None})
+                               return Err(HandleError{err: "Previous secret did not match new one", action: None})
                        }
                }
                self.old_secrets[pos as usize] = (secret, idx);
@@ -421,7 +424,7 @@ impl ChannelMonitor {
        pub fn insert_combine(&mut self, mut other: ChannelMonitor) -> Result<(), HandleError> {
                if self.funding_txo.is_some() {
                        if other.funding_txo.is_some() && other.funding_txo.as_ref().unwrap() != self.funding_txo.as_ref().unwrap() {
-                               return Err(HandleError{err: "Funding transaction outputs are not identical!", msg: None});
+                               return Err(HandleError{err: "Funding transaction outputs are not identical!", action: None});
                        }
                } else {
                        self.funding_txo = other.funding_txo.take();
@@ -740,7 +743,7 @@ impl ChannelMonitor {
                for _ in 0..remote_claimable_outpoints_len {
                        let txid = Sha256dHash::from(read_bytes!(32));
                        let outputs_count = byte_utils::slice_to_be64(read_bytes!(8));
-                       if outputs_count > data.len() as u64 * 32 { return None; }
+                       if outputs_count > data.len() as u64 / 32 { return None; }
                        let mut outputs = Vec::with_capacity(outputs_count as usize);
                        for _ in 0..outputs_count {
                                outputs.push(read_htlc_in_commitment!());
@@ -882,7 +885,7 @@ impl ChannelMonitor {
                        }
                }
                assert!(idx < self.get_min_seen_secret());
-               Err(HandleError{err: "idx too low", msg: None})
+               Err(HandleError{err: "idx too low", action: None})
        }
 
        pub fn get_min_seen_secret(&self) -> u64 {