X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannel.rs;h=c4b6acb7d632708c322b15915cf2bdc240cdead9;hb=4e4fa56e2b52971271ccddf56e8195d96b1c69ba;hp=4a927119695ad0efa3a557fa22cb6d903da981e9;hpb=d84c084df7b7dae62ea6b1a51951fb01391a7ebd;p=rust-lightning diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 4a927119..c4b6acb7 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -1263,10 +1263,6 @@ impl Channel { fn funding_created_signature(&mut self, sig: &Signature) -> Result<(Transaction, Signature), HandleError> { let funding_script = self.get_funding_redeemscript(); - let remote_keys = self.build_remote_transaction_keys()?; - let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number, &remote_keys, false, false).0; - let remote_sighash = Message::from_slice(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0], &funding_script, self.channel_value_satoshis)[..]).unwrap(); - let local_keys = self.build_local_transaction_keys(self.cur_local_commitment_transaction_number)?; let local_initial_commitment_tx = self.build_commitment_transaction(self.cur_local_commitment_transaction_number, &local_keys, true, false).0; let local_sighash = Message::from_slice(&bip143::SighashComponents::new(&local_initial_commitment_tx).sighash_all(&local_initial_commitment_tx.input[0], &funding_script, self.channel_value_satoshis)[..]).unwrap(); @@ -1274,6 +1270,10 @@ impl Channel { // They sign the "local" commitment transaction, allowing us to broadcast the tx if we wish. secp_call!(self.secp_ctx.verify(&local_sighash, &sig, &self.their_funding_pubkey.unwrap()), "Invalid funding_created signature from peer", self.channel_id()); + let remote_keys = self.build_remote_transaction_keys()?; + let remote_initial_commitment_tx = self.build_commitment_transaction(self.cur_remote_commitment_transaction_number, &remote_keys, false, false).0; + let remote_sighash = Message::from_slice(&bip143::SighashComponents::new(&remote_initial_commitment_tx).sighash_all(&remote_initial_commitment_tx.input[0], &funding_script, self.channel_value_satoshis)[..]).unwrap(); + // We sign the "remote" commitment transaction, allowing them to broadcast the tx if they wish. Ok((remote_initial_commitment_tx, self.secp_ctx.sign(&remote_sighash, &self.local_keys.funding_key))) } @@ -2168,7 +2168,7 @@ impl Channel { // Methods to get unprompted messages to send to the remote end (or where we already returned // something in the handler for the message that prompted this message): - pub fn get_open_channel(&self, chain_hash: Sha256dHash, fee_estimator: &FeeEstimator) -> Result { + pub fn get_open_channel(&self, chain_hash: Sha256dHash, fee_estimator: &FeeEstimator) -> msgs::OpenChannel { if !self.channel_outbound { panic!("Tried to open a channel for an inbound channel?"); } @@ -2182,7 +2182,7 @@ impl Channel { let local_commitment_secret = self.build_local_commitment_secret(self.cur_local_commitment_transaction_number); - Ok(msgs::OpenChannel { + msgs::OpenChannel { chain_hash: chain_hash, temporary_channel_id: self.channel_id, funding_satoshis: self.channel_value_satoshis, @@ -2202,7 +2202,7 @@ impl Channel { first_per_commitment_point: PublicKey::from_secret_key(&self.secp_ctx, &local_commitment_secret), channel_flags: if self.announce_publicly {1} else {0}, shutdown_scriptpubkey: None, - }) + } } pub fn get_accept_channel(&self) -> msgs::AcceptChannel { @@ -2551,10 +2551,7 @@ impl Channel { } } - for htlc in self.pending_outbound_htlcs.drain(..) { - if htlc.state == OutboundHTLCState::LocalAnnounced { - dropped_outbound_htlcs.push((htlc.source, htlc.payment_hash)); - } + for _htlc in self.pending_outbound_htlcs.drain(..) { //TODO: Do something with the remaining HTLCs //(we need to have the ChannelManager monitor them so we can claim the inbound HTLCs //which correspond)