X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=inline;f=src%2Fln%2Fchannel.rs;h=0d4f1c6c57b5ac3c66f832bcecef36f95cc67f0e;hb=aec0fa485c8e1113f0a6d24c2f18e4ba90fe568d;hp=7c9e69074e9848e9ffa461225518c598bd76641e;hpb=3057df26566f9b111db0470563689f5633ebfaec;p=rust-lightning diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 7c9e6907..0d4f1c6c 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -608,7 +608,7 @@ impl Channel { ins }; - let mut txouts: Vec<(TxOut, Option)> = Vec::new(); + let mut txouts: Vec<(TxOut, Option)> = Vec::with_capacity(self.pending_htlcs.len() + 2); let dust_limit_satoshis = if local { self.our_dust_limit_satoshis } else { self.their_dust_limit_satoshis }; let mut remote_htlc_total_msat = 0; @@ -699,8 +699,8 @@ impl Channel { transaction_utils::sort_outputs(&mut txouts); - let mut outputs: Vec = Vec::new(); - let mut htlcs_used: Vec = Vec::new(); + let mut outputs: Vec = Vec::with_capacity(txouts.len()); + let mut htlcs_used: Vec = Vec::with_capacity(txouts.len()); for (idx, out) in txouts.drain(..).enumerate() { outputs.push(out.0); if let Some(out_htlc) = out.1 { @@ -1162,7 +1162,7 @@ impl Channel { // Now that we're past error-generating stuff, update our local state: - self.channel_monitor.provide_latest_remote_commitment_tx_info(&remote_initial_commitment_tx, Vec::new()); + self.channel_monitor.provide_latest_remote_commitment_tx_info(&remote_initial_commitment_tx, Vec::new(), self.cur_remote_commitment_transaction_number); self.channel_state = ChannelState::FundingSent as u32; let funding_txo = self.channel_monitor.get_funding_txo().unwrap(); self.channel_id = funding_txo.0.into_be() ^ Uint256::from_u64(funding_txo.1 as u64).unwrap(); //TODO: or le? @@ -2067,7 +2067,7 @@ impl Channel { let temporary_channel_id = self.channel_id; // Now that we're past error-generating stuff, update our local state: - self.channel_monitor.provide_latest_remote_commitment_tx_info(&commitment_tx, Vec::new()); + self.channel_monitor.provide_latest_remote_commitment_tx_info(&commitment_tx, Vec::new(), self.cur_remote_commitment_transaction_number); self.channel_state = ChannelState::FundingCreated as u32; let funding_txo = self.channel_monitor.get_funding_txo().unwrap(); self.channel_id = funding_txo.0.into_be() ^ Uint256::from_u64(funding_txo.1 as u64).unwrap(); //TODO: or le? @@ -2241,7 +2241,7 @@ impl Channel { } // Update state now that we've passed all the can-fail calls... - self.channel_monitor.provide_latest_remote_commitment_tx_info(&remote_commitment_tx.0, remote_commitment_tx.1); + self.channel_monitor.provide_latest_remote_commitment_tx_info(&remote_commitment_tx.0, remote_commitment_tx.1, self.cur_remote_commitment_transaction_number); self.channel_state |= ChannelState::AwaitingRemoteRevoke as u32; Ok((msgs::CommitmentSigned {