+ }
+ }
+ if non_shutdown_state & !(ChannelState::TheirFundingLocked as u32) == ChannelState::FundingSent as u32 {
+ for (ref tx, index_in_block) in txn_matched.iter().zip(indexes_of_txn_matched) {
+ if tx.txid() == self.funding_txo.unwrap().txid {
+ let txo_idx = self.funding_txo.unwrap().index as usize;
+ if txo_idx >= tx.output.len() || tx.output[txo_idx].script_pubkey != self.get_funding_redeemscript().to_v0_p2wsh() ||
+ tx.output[txo_idx].value != self.channel_value_satoshis {
+ if self.channel_outbound {
+ // If we generated the funding transaction and it doesn't match what it
+ // should, the client is really broken and we should just panic and
+ // tell them off. That said, because hash collisions happen with high
+ // probability in fuzztarget mode, if we're fuzzing we just close the
+ // channel and move on.
+ #[cfg(not(feature = "fuzztarget"))]
+ panic!("Client called ChannelManager::funding_transaction_generated with bogus transaction!");
+ }
+ self.channel_state = ChannelState::ShutdownComplete as u32;
+ self.channel_update_count += 1;
+ return Err(msgs::ErrorMessage {
+ channel_id: self.channel_id(),
+ data: "funding tx had wrong script/value".to_owned()
+ });
+ } else {
+ if self.channel_outbound {
+ for input in tx.input.iter() {
+ if input.witness.is_empty() {
+ // We generated a malleable funding transaction, implying we've
+ // just exposed ourselves to funds loss to our counterparty.
+ #[cfg(not(feature = "fuzztarget"))]
+ panic!("Client called ChannelManager::funding_transaction_generated with bogus transaction!");
+ }
+ }
+ }
+ self.funding_tx_confirmations = 1;
+ self.short_channel_id = Some(((height as u64) << (5*8)) |
+ ((*index_in_block as u64) << (2*8)) |
+ ((txo_idx as u64) << (0*8)));
+ }
+ }
+ }
+ }
+ if header.bitcoin_hash() != self.last_block_connected {
+ self.last_block_connected = header.bitcoin_hash();
+ if let Some(channel_monitor) = self.channel_monitor.as_mut() {
+ channel_monitor.last_block_hash = self.last_block_connected;
+ }
+ if self.funding_tx_confirmations > 0 {