Use core replacements for std members
[rust-lightning] / lightning / src / chain / channelmonitor.rs
index 004c23810b7fcb085681f4c9421fbb27d1c82678..8526ce51722afefa80d14657f095fbcbfdf41ab2 100644 (file)
@@ -52,9 +52,9 @@ use util::byte_utils;
 use util::events::Event;
 
 use std::collections::{HashMap, HashSet};
-use std::{cmp, mem};
+use core::{cmp, mem};
 use std::io::Error;
-use std::ops::Deref;
+use core::ops::Deref;
 use std::sync::Mutex;
 
 /// An update generated by the underlying Channel itself which contains some new information the
@@ -85,7 +85,7 @@ pub struct ChannelMonitorUpdate {
 /// then we allow the `ChannelManager` to send a `ChannelMonitorUpdate` with this update ID,
 /// with the update providing said payment preimage. No other update types are allowed after
 /// force-close.
-pub const CLOSED_CHANNEL_UPDATE_ID: u64 = std::u64::MAX;
+pub const CLOSED_CHANNEL_UPDATE_ID: u64 = core::u64::MAX;
 
 impl Writeable for ChannelMonitorUpdate {
        fn write<W: Writer>(&self, w: &mut W) -> Result<(), ::std::io::Error> {
@@ -101,7 +101,7 @@ impl Readable for ChannelMonitorUpdate {
        fn read<R: ::std::io::Read>(r: &mut R) -> Result<Self, DecodeError> {
                let update_id: u64 = Readable::read(r)?;
                let len: u64 = Readable::read(r)?;
-               let mut updates = Vec::with_capacity(cmp::min(len as usize, MAX_ALLOC_SIZE / ::std::mem::size_of::<ChannelMonitorUpdateStep>()));
+               let mut updates = Vec::with_capacity(cmp::min(len as usize, MAX_ALLOC_SIZE / ::core::mem::size_of::<ChannelMonitorUpdateStep>()));
                for _ in 0..len {
                        updates.push(Readable::read(r)?);
                }
@@ -206,7 +206,7 @@ pub(crate) const CLTV_SHARED_CLAIM_BUFFER: u32 = 12;
 /// HTLC-Success transaction.
 /// In other words, this is an upper bound on how many blocks we think it can take us to get a
 /// transaction confirmed (and we use it in a few more, equivalent, places).
-pub(crate) const CLTV_CLAIM_BUFFER: u32 = 6;
+pub(crate) const CLTV_CLAIM_BUFFER: u32 = 18;
 /// Number of blocks by which point we expect our counterparty to have seen new blocks on the
 /// network and done a full update_fail_htlc/commitment_signed dance (+ we've updated all our
 /// copies of ChannelMonitors, including watchtowers). We could enforce the contract by failing
@@ -1932,7 +1932,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
 
                for &(ref htlc, _, _) in holder_tx.htlc_outputs.iter() {
                        if let Some(transaction_output_index) = htlc.transaction_output_index {
-                               claim_requests.push(ClaimRequest { absolute_timelock: ::std::u32::MAX, aggregable: false, outpoint: BitcoinOutPoint { txid: holder_tx.txid, vout: transaction_output_index as u32 },
+                               claim_requests.push(ClaimRequest { absolute_timelock: ::core::u32::MAX, aggregable: false, outpoint: BitcoinOutPoint { txid: holder_tx.txid, vout: transaction_output_index as u32 },
                                        witness_data: InputMaterial::HolderHTLC {
                                                preimage: if !htlc.offered {
                                                                if let Some(preimage) = self.payment_preimages.get(&htlc.payment_hash) {
@@ -2594,7 +2594,7 @@ impl<Signer: Sign> ChannelMonitorImpl<Signer> {
        fn is_paying_spendable_output<L: Deref>(&mut self, tx: &Transaction, height: u32, logger: &L) where L::Target: Logger {
                let mut spendable_output = None;
                for (i, outp) in tx.output.iter().enumerate() { // There is max one spendable output for any channel tx, including ones generated by us
-                       if i > ::std::u16::MAX as usize {
+                       if i > ::core::u16::MAX as usize {
                                // While it is possible that an output exists on chain which is greater than the
                                // 2^16th output in a given transaction, this is only possible if the output is not
                                // in a lightning transaction and was instead placed there by some third party who