+ let checked_utxo = match self.chain_monitor.get_chain_utxo(msg.contents.chain_hash, msg.contents.short_channel_id) {
+ Ok((script_pubkey, _value)) => {
+ let expected_script = Builder::new().push_opcode(opcodes::All::OP_PUSHNUM_2)
+ .push_slice(&msg.contents.bitcoin_key_1.serialize())
+ .push_slice(&msg.contents.bitcoin_key_2.serialize())
+ .push_opcode(opcodes::All::OP_PUSHNUM_2).push_opcode(opcodes::All::OP_CHECKMULTISIG).into_script().to_v0_p2wsh();
+ if script_pubkey != expected_script {
+ return Err(HandleError{err: "Channel announcement keys didn't match on-chain script", action: Some(ErrorAction::IgnoreError)});
+ }
+ //TODO: Check if value is worth storing, use it to inform routing, and compare it
+ //to the new HTLC max field in channel_update
+ true
+ },
+ Err(ChainError::NotSupported) => {
+ // Tentatively accept, potentially exposing us to DoS attacks
+ false
+ },
+ Err(ChainError::NotWatched) => {
+ return Err(HandleError{err: "Channel announced on an unknown chain", action: Some(ErrorAction::IgnoreError)});
+ },
+ Err(ChainError::UnknownTx) => {
+ return Err(HandleError{err: "Channel announced without corresponding UTXO entry", action: Some(ErrorAction::IgnoreError)});
+ },
+ };
+
+ let mut network_lock = self.network_map.write().unwrap();
+ let network = network_lock.borrow_parts();
+
+ let should_relay = msg.contents.excess_data.is_empty() && !msg.contents.features.supports_unknown_bits();
+
+ let chan_info = ChannelInfo {
+ features: msg.contents.features.clone(),
+ one_to_two: DirectionalChannelInfo {
+ src_node_id: msg.contents.node_id_1.clone(),
+ last_update: 0,
+ enabled: false,
+ cltv_expiry_delta: u16::max_value(),
+ htlc_minimum_msat: u64::max_value(),
+ fee_base_msat: u32::max_value(),
+ fee_proportional_millionths: u32::max_value(),
+ last_update_message: None,
+ },
+ two_to_one: DirectionalChannelInfo {
+ src_node_id: msg.contents.node_id_2.clone(),
+ last_update: 0,
+ enabled: false,
+ cltv_expiry_delta: u16::max_value(),
+ htlc_minimum_msat: u64::max_value(),
+ fee_base_msat: u32::max_value(),
+ fee_proportional_millionths: u32::max_value(),
+ last_update_message: None,
+ },
+ announcement_message: if should_relay { Some(msg.clone()) } else { None },
+ };