From: Gleb Naumenko Date: Sat, 2 May 2020 18:58:06 +0000 (-0400) Subject: Remove non-bitcoin chain helpers X-Git-Tag: v0.0.12~66^2~12 X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=rust-lightning;a=commitdiff_plain;h=6164a95267afe4047f62cf22968f1c47e577ff57 Remove non-bitcoin chain helpers --- diff --git a/lightning/Cargo.toml b/lightning/Cargo.toml index 50859aab..f89b5481 100644 --- a/lightning/Cargo.toml +++ b/lightning/Cargo.toml @@ -11,8 +11,6 @@ Still missing tons of error-handling. See GitHub issues for suggested projects i """ [features] -# Supports tracking channels with a non-bitcoin chain hashes. Currently enables all kinds of fun DoS attacks. -non_bitcoin_chain_hash_routing = [] fuzztarget = ["bitcoin/fuzztarget"] # Unlog messages superior at targeted level. max_level_off = [] diff --git a/lightning/src/ln/msgs.rs b/lightning/src/ln/msgs.rs index 43005ad1..30343172 100644 --- a/lightning/src/ln/msgs.rs +++ b/lightning/src/ln/msgs.rs @@ -1445,7 +1445,7 @@ mod tests { assert_eq!(encoded_value, hex::decode("040000000000000005000000000000000600000000000000070000000000000000083a840000034dd977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073acf9953cef4700860f5967838eba2bae89288ad188ebf8b20bf995c3ea53a26df1876d0a3a0e13172ba286a673140190c02ba9da60a2e43a745188c8a83c7f3ef").unwrap()); } - fn do_encoding_channel_announcement(unknown_features_bits: bool, non_bitcoin_chain_hash: bool, excess_data: bool) { + fn do_encoding_channel_announcement(unknown_features_bits: bool, excess_data: bool) { let secp_ctx = Secp256k1::new(); let (privkey_1, pubkey_1) = get_keys_from!("0101010101010101010101010101010101010101010101010101010101010101", secp_ctx); let (privkey_2, pubkey_2) = get_keys_from!("0202020202020202020202020202020202020202020202020202020202020202", secp_ctx); @@ -1461,7 +1461,7 @@ mod tests { } let unsigned_channel_announcement = msgs::UnsignedChannelAnnouncement { features, - chain_hash: if !non_bitcoin_chain_hash { BlockHash::from_hex("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000").unwrap() } else { BlockHash::from_hex("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943").unwrap() }, + chain_hash: BlockHash::from_hex("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000").unwrap(), short_channel_id: 2316138423780173, node_id_1: pubkey_1, node_id_2: pubkey_2, @@ -1483,11 +1483,7 @@ mod tests { } else { target_value.append(&mut hex::decode("0000").unwrap()); } - if non_bitcoin_chain_hash { - target_value.append(&mut hex::decode("43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000").unwrap()); - } else { - target_value.append(&mut hex::decode("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f").unwrap()); - } + target_value.append(&mut hex::decode("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f").unwrap()); target_value.append(&mut hex::decode("00083a840000034d031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d076602531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33703462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b").unwrap()); if excess_data { target_value.append(&mut hex::decode("0a00001400001e000028").unwrap()); @@ -1497,14 +1493,10 @@ mod tests { #[test] fn encoding_channel_announcement() { - do_encoding_channel_announcement(false, false, false); - do_encoding_channel_announcement(true, false, false); - do_encoding_channel_announcement(true, true, false); - do_encoding_channel_announcement(true, true, true); - do_encoding_channel_announcement(false, true, true); - do_encoding_channel_announcement(false, false, true); - do_encoding_channel_announcement(false, true, false); - do_encoding_channel_announcement(true, false, true); + do_encoding_channel_announcement(true, false); + do_encoding_channel_announcement(false, true); + do_encoding_channel_announcement(false, false); + do_encoding_channel_announcement(true, true); } fn do_encoding_node_announcement(unknown_features_bits: bool, ipv4: bool, ipv6: bool, onionv2: bool, onionv3: bool, excess_address_data: bool, excess_data: bool) { @@ -1606,12 +1598,12 @@ mod tests { do_encoding_node_announcement(false, false, true, false, true, false, false); } - fn do_encoding_channel_update(non_bitcoin_chain_hash: bool, direction: bool, disable: bool, htlc_maximum_msat: bool) { + fn do_encoding_channel_update(direction: bool, disable: bool, htlc_maximum_msat: bool) { let secp_ctx = Secp256k1::new(); let (privkey_1, _) = get_keys_from!("0101010101010101010101010101010101010101010101010101010101010101", secp_ctx); let sig_1 = get_sig_on!(privkey_1, secp_ctx, String::from("01010101010101010101010101010101")); let unsigned_channel_update = msgs::UnsignedChannelUpdate { - chain_hash: if !non_bitcoin_chain_hash { BlockHash::from_hex("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000").unwrap() } else { BlockHash::from_hex("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943").unwrap() }, + chain_hash: BlockHash::from_hex("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000").unwrap(), short_channel_id: 2316138423780173, timestamp: 20190119, flags: if direction { 1 } else { 0 } | if disable { 1 << 1 } else { 0 } | if htlc_maximum_msat { 1 << 8 } else { 0 }, @@ -1627,11 +1619,7 @@ mod tests { }; let encoded_value = channel_update.encode(); let mut target_value = hex::decode("d977cb9b53d93a6ff64bb5f1e158b4094b66e798fb12911168a3ccdf80a83096340a6a95da0ae8d9f776528eecdbb747eb6b545495a4319ed5378e35b21e073a").unwrap(); - if non_bitcoin_chain_hash { - target_value.append(&mut hex::decode("43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000").unwrap()); - } else { - target_value.append(&mut hex::decode("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f").unwrap()); - } + target_value.append(&mut hex::decode("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f").unwrap()); target_value.append(&mut hex::decode("00083a840000034d013413a7").unwrap()); if htlc_maximum_msat { target_value.append(&mut hex::decode("01").unwrap()); @@ -1656,15 +1644,14 @@ mod tests { #[test] fn encoding_channel_update() { - do_encoding_channel_update(false, false, false, false); - do_encoding_channel_update(true, false, false, false); - do_encoding_channel_update(false, true, false, false); - do_encoding_channel_update(false, false, true, false); - do_encoding_channel_update(false, false, false, true); - do_encoding_channel_update(true, true, true, true); + do_encoding_channel_update(false, false, false); + do_encoding_channel_update(true, false, false); + do_encoding_channel_update(false, true, false); + do_encoding_channel_update(false, false, true); + do_encoding_channel_update(true, true, true); } - fn do_encoding_open_channel(non_bitcoin_chain_hash: bool, random_bit: bool, shutdown: bool) { + fn do_encoding_open_channel(random_bit: bool, shutdown: bool) { let secp_ctx = Secp256k1::new(); let (_, pubkey_1) = get_keys_from!("0101010101010101010101010101010101010101010101010101010101010101", secp_ctx); let (_, pubkey_2) = get_keys_from!("0202020202020202020202020202020202020202020202020202020202020202", secp_ctx); @@ -1673,7 +1660,7 @@ mod tests { let (_, pubkey_5) = get_keys_from!("0505050505050505050505050505050505050505050505050505050505050505", secp_ctx); let (_, pubkey_6) = get_keys_from!("0606060606060606060606060606060606060606060606060606060606060606", secp_ctx); let open_channel = msgs::OpenChannel { - chain_hash: if !non_bitcoin_chain_hash { BlockHash::from_hex("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000").unwrap() } else { BlockHash::from_hex("000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943").unwrap() }, + chain_hash: BlockHash::from_hex("6fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000").unwrap(), temporary_channel_id: [2; 32], funding_satoshis: 1311768467284833366, push_msat: 2536655962884945560, @@ -1695,11 +1682,7 @@ mod tests { }; let encoded_value = open_channel.encode(); let mut target_value = Vec::new(); - if non_bitcoin_chain_hash { - target_value.append(&mut hex::decode("43497fd7f826957108f4a30fd9cec3aeba79972084e90ead01ea330900000000").unwrap()); - } else { - target_value.append(&mut hex::decode("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f").unwrap()); - } + target_value.append(&mut hex::decode("000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f").unwrap()); target_value.append(&mut hex::decode("02020202020202020202020202020202020202020202020202020202020202021234567890123456233403289122369832144668701144767633030896203198784335490624111800083a840000034d000c89d4c0bcc0bc031b84c5567b126440995d3ed5aaba0565d71e1834604819ff9c17f5e9d5dd078f024d4b6cd1361032ca9bd2aeb9d900aa4d45d9ead80ac9423374c451a7254d076602531fe6068134503d2723133227c867ac8fa6c83c537e9a44c3c5bdbdcb1fe33703462779ad4aad39514614751a71085f2f10e1c7a593e4e030efb5b8721ce55b0b0362c0a046dacce86ddd0343c6d3c7c79c2208ba0d9c9cf24a6d046d21d21f90f703f006a18d5653c4edf5391ff23a61f03ff83d237e880ee61187fa9f379a028e0a").unwrap()); if random_bit { target_value.append(&mut hex::decode("20").unwrap()); @@ -1714,11 +1697,10 @@ mod tests { #[test] fn encoding_open_channel() { - do_encoding_open_channel(false, false, false); - do_encoding_open_channel(true, false, false); - do_encoding_open_channel(false, true, false); - do_encoding_open_channel(false, false, true); - do_encoding_open_channel(true, true, true); + do_encoding_open_channel(false, false); + do_encoding_open_channel(true, false); + do_encoding_open_channel(false, true); + do_encoding_open_channel(true, true); } fn do_encoding_accept_channel(shutdown: bool) { diff --git a/lightning/src/routing/router.rs b/lightning/src/routing/router.rs index fef99fcc..07798509 100644 --- a/lightning/src/routing/router.rs +++ b/lightning/src/routing/router.rs @@ -9,7 +9,6 @@ use bitcoin::secp256k1; use bitcoin::hashes::sha256d::Hash as Sha256dHash; use bitcoin::hashes::Hash; -use bitcoin::hash_types::BlockHash; use bitcoin::blockdata::script::Builder; use bitcoin::blockdata::opcodes; @@ -171,9 +170,6 @@ impl_writeable!(ChannelInfo, 0, { #[derive(PartialEq)] struct NodeInfo { - #[cfg(feature = "non_bitcoin_chain_hash_routing")] - channels: Vec<(u64, Sha256dHash)>, - #[cfg(not(feature = "non_bitcoin_chain_hash_routing"))] channels: Vec, lowest_inbound_channel_fee_base_msat: u32, @@ -262,11 +258,7 @@ impl Readable for NodeInfo { #[derive(PartialEq)] struct NetworkMap { - #[cfg(feature = "non_bitcoin_chain_hash_routing")] - channels: BTreeMap<(u64, Sha256dHash), ChannelInfo>, - #[cfg(not(feature = "non_bitcoin_chain_hash_routing"))] channels: BTreeMap, - our_node_id: PublicKey, nodes: BTreeMap, } @@ -327,32 +319,6 @@ impl std::fmt::Display for NetworkMap { } } -impl NetworkMap { - #[cfg(feature = "non_bitcoin_chain_hash_routing")] - #[inline] - fn get_key(short_channel_id: u64, chain_hash: BlockHash) -> (u64, BlockHash) { - (short_channel_id, chain_hash) - } - - #[cfg(not(feature = "non_bitcoin_chain_hash_routing"))] - #[inline] - fn get_key(short_channel_id: u64, _: BlockHash) -> u64 { - short_channel_id - } - - #[cfg(feature = "non_bitcoin_chain_hash_routing")] - #[inline] - fn get_short_id(id: &(u64, BlockHash)) -> &u64 { - &id.0 - } - - #[cfg(not(feature = "non_bitcoin_chain_hash_routing"))] - #[inline] - fn get_short_id(id: &u64) -> &u64 { - id - } -} - /// A channel descriptor which provides a last-hop route to get_route pub struct RouteHint { /// The node_id of the non-target end of the route @@ -532,7 +498,7 @@ impl RoutingMessageHandler for Router { announcement_message: if should_relay { Some(msg.clone()) } else { None }, }; - match network.channels.entry(NetworkMap::get_key(msg.contents.short_channel_id, msg.contents.chain_hash)) { + match network.channels.entry(msg.contents.short_channel_id) { BtreeEntry::Occupied(mut entry) => { //TODO: because asking the blockchain if short_channel_id is valid is only optional //in the blockchain API, we need to handle it smartly here, though it's unclear @@ -561,11 +527,11 @@ impl RoutingMessageHandler for Router { ( $node_id: expr ) => { match network.nodes.entry($node_id) { BtreeEntry::Occupied(node_entry) => { - node_entry.into_mut().channels.push(NetworkMap::get_key(msg.contents.short_channel_id, msg.contents.chain_hash)); + node_entry.into_mut().channels.push(msg.contents.short_channel_id); }, BtreeEntry::Vacant(node_entry) => { node_entry.insert(NodeInfo { - channels: vec!(NetworkMap::get_key(msg.contents.short_channel_id, msg.contents.chain_hash)), + channels: vec!(msg.contents.short_channel_id), lowest_inbound_channel_fee_base_msat: u32::max_value(), lowest_inbound_channel_fee_proportional_millionths: u32::max_value(), features: NodeFeatures::empty(), @@ -621,7 +587,7 @@ impl RoutingMessageHandler for Router { let chan_enabled = msg.contents.flags & (1 << 1) != (1 << 1); let chan_was_enabled; - match network.channels.get_mut(&NetworkMap::get_key(msg.contents.short_channel_id, msg.contents.chain_hash)) { + match network.channels.get_mut(&msg.contents.short_channel_id) { None => return Err(LightningError{err: "Couldn't find channel for update", action: ErrorAction::IgnoreError}), Some(channel) => { macro_rules! maybe_update_channel_info { @@ -826,7 +792,7 @@ impl Router { ($node_id: expr) => { if let BtreeEntry::Occupied(mut entry) = nodes.entry($node_id) { entry.get_mut().channels.retain(|chan_id| { - short_channel_id != *NetworkMap::get_short_id(chan_id) + short_channel_id != *chan_id }); if entry.get().channels.is_empty() { entry.remove_entry(); @@ -1088,7 +1054,6 @@ mod tests { use bitcoin::hashes::sha256d::Hash as Sha256dHash; use bitcoin::hashes::Hash; - use bitcoin::hash_types::BlockHash; use bitcoin::network::constants::Network; use bitcoin::blockdata::constants::genesis_block; use bitcoin::blockdata::script::Builder; @@ -1183,8 +1148,6 @@ mod tests { let node7 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0808080808080808080808080808080808080808080808080808080808080808").unwrap()[..]).unwrap()); let node8 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0909090909090909090909090909090909090909090909090909090909090909").unwrap()[..]).unwrap()); - let zero_hash = BlockHash::hash(&[0; 32]); - macro_rules! id_to_feature_flags { // Set the feature flags to the id'th odd (ie non-required) feature bit so that we can // test for it later. @@ -1206,7 +1169,7 @@ mod tests { let mut network = router.network_map.write().unwrap(); network.nodes.insert(node1.clone(), NodeInfo { - channels: vec!(NetworkMap::get_key(1, zero_hash.clone()), NetworkMap::get_key(3, zero_hash.clone())), + channels: vec!(1, 3), lowest_inbound_channel_fee_base_msat: 100, lowest_inbound_channel_fee_proportional_millionths: 0, features: NodeFeatures::from_le_bytes(id_to_feature_flags!(1)), @@ -1216,7 +1179,7 @@ mod tests { addresses: Vec::new(), announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(1, zero_hash.clone()), ChannelInfo { + network.channels.insert(1, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(1)), one_to_two: DirectionalChannelInfo { src_node_id: our_id.clone(), @@ -1240,7 +1203,7 @@ mod tests { announcement_message: None, }); network.nodes.insert(node2.clone(), NodeInfo { - channels: vec!(NetworkMap::get_key(2, zero_hash.clone()), NetworkMap::get_key(4, zero_hash.clone())), + channels: vec!(2, 4), lowest_inbound_channel_fee_base_msat: 0, lowest_inbound_channel_fee_proportional_millionths: 0, features: NodeFeatures::from_le_bytes(id_to_feature_flags!(2)), @@ -1250,7 +1213,7 @@ mod tests { addresses: Vec::new(), announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(2, zero_hash.clone()), ChannelInfo { + network.channels.insert(2, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(2)), one_to_two: DirectionalChannelInfo { src_node_id: our_id.clone(), @@ -1274,7 +1237,7 @@ mod tests { announcement_message: None, }); network.nodes.insert(node8.clone(), NodeInfo { - channels: vec!(NetworkMap::get_key(12, zero_hash.clone()), NetworkMap::get_key(13, zero_hash.clone())), + channels: vec!(12, 13), lowest_inbound_channel_fee_base_msat: 0, lowest_inbound_channel_fee_proportional_millionths: 0, features: NodeFeatures::from_le_bytes(id_to_feature_flags!(8)), @@ -1284,7 +1247,7 @@ mod tests { addresses: Vec::new(), announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(12, zero_hash.clone()), ChannelInfo { + network.channels.insert(12, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(12)), one_to_two: DirectionalChannelInfo { src_node_id: our_id.clone(), @@ -1309,12 +1272,12 @@ mod tests { }); network.nodes.insert(node3.clone(), NodeInfo { channels: vec!( - NetworkMap::get_key(3, zero_hash.clone()), - NetworkMap::get_key(4, zero_hash.clone()), - NetworkMap::get_key(13, zero_hash.clone()), - NetworkMap::get_key(5, zero_hash.clone()), - NetworkMap::get_key(6, zero_hash.clone()), - NetworkMap::get_key(7, zero_hash.clone())), + 3, + 4, + 13, + 5, + 6, + 7), lowest_inbound_channel_fee_base_msat: 0, lowest_inbound_channel_fee_proportional_millionths: 0, features: NodeFeatures::from_le_bytes(id_to_feature_flags!(3)), @@ -1324,7 +1287,7 @@ mod tests { addresses: Vec::new(), announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(3, zero_hash.clone()), ChannelInfo { + network.channels.insert(3, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(3)), one_to_two: DirectionalChannelInfo { src_node_id: node1.clone(), @@ -1347,7 +1310,7 @@ mod tests { }, announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(4, zero_hash.clone()), ChannelInfo { + network.channels.insert(4, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(4)), one_to_two: DirectionalChannelInfo { src_node_id: node2.clone(), @@ -1370,7 +1333,7 @@ mod tests { }, announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(13, zero_hash.clone()), ChannelInfo { + network.channels.insert(13, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(13)), one_to_two: DirectionalChannelInfo { src_node_id: node8.clone(), @@ -1394,7 +1357,7 @@ mod tests { announcement_message: None, }); network.nodes.insert(node4.clone(), NodeInfo { - channels: vec!(NetworkMap::get_key(5, zero_hash.clone()), NetworkMap::get_key(11, zero_hash.clone())), + channels: vec!(5, 11), lowest_inbound_channel_fee_base_msat: 0, lowest_inbound_channel_fee_proportional_millionths: 0, features: NodeFeatures::from_le_bytes(id_to_feature_flags!(4)), @@ -1404,7 +1367,7 @@ mod tests { addresses: Vec::new(), announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(5, zero_hash.clone()), ChannelInfo { + network.channels.insert(5, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(5)), one_to_two: DirectionalChannelInfo { src_node_id: node3.clone(), @@ -1428,7 +1391,7 @@ mod tests { announcement_message: None, }); network.nodes.insert(node5.clone(), NodeInfo { - channels: vec!(NetworkMap::get_key(6, zero_hash.clone()), NetworkMap::get_key(11, zero_hash.clone())), + channels: vec!(6, 11), lowest_inbound_channel_fee_base_msat: 0, lowest_inbound_channel_fee_proportional_millionths: 0, features: NodeFeatures::from_le_bytes(id_to_feature_flags!(5)), @@ -1438,7 +1401,7 @@ mod tests { addresses: Vec::new(), announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(6, zero_hash.clone()), ChannelInfo { + network.channels.insert(6, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(6)), one_to_two: DirectionalChannelInfo { src_node_id: node3.clone(), @@ -1461,7 +1424,7 @@ mod tests { }, announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(11, zero_hash.clone()), ChannelInfo { + network.channels.insert(11, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(11)), one_to_two: DirectionalChannelInfo { src_node_id: node5.clone(), @@ -1485,7 +1448,7 @@ mod tests { announcement_message: None, }); network.nodes.insert(node6.clone(), NodeInfo { - channels: vec!(NetworkMap::get_key(7, zero_hash.clone())), + channels: vec!(7), lowest_inbound_channel_fee_base_msat: 0, lowest_inbound_channel_fee_proportional_millionths: 0, features: NodeFeatures::from_le_bytes(id_to_feature_flags!(6)), @@ -1495,7 +1458,7 @@ mod tests { addresses: Vec::new(), announcement_message: None, }); - network.channels.insert(NetworkMap::get_key(7, zero_hash.clone()), ChannelInfo { + network.channels.insert(7, ChannelInfo { features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(7)), one_to_two: DirectionalChannelInfo { src_node_id: node3.clone(), @@ -1541,8 +1504,8 @@ mod tests { { // Disable channels 4 and 12 by requiring unknown feature bits let mut network = router.network_map.write().unwrap(); - network.channels.get_mut(&NetworkMap::get_key(4, zero_hash.clone())).unwrap().features.set_required_unknown_bits(); - network.channels.get_mut(&NetworkMap::get_key(12, zero_hash.clone())).unwrap().features.set_required_unknown_bits(); + network.channels.get_mut(&4).unwrap().features.set_required_unknown_bits(); + network.channels.get_mut(&12).unwrap().features.set_required_unknown_bits(); } { // If all the channels require some features we don't understand, route should fail @@ -1583,8 +1546,8 @@ mod tests { { // Re-enable channels 4 and 12 by wiping the unknown feature bits let mut network = router.network_map.write().unwrap(); - network.channels.get_mut(&NetworkMap::get_key(4, zero_hash.clone())).unwrap().features.clear_unknown_bits(); - network.channels.get_mut(&NetworkMap::get_key(12, zero_hash.clone())).unwrap().features.clear_unknown_bits(); + network.channels.get_mut(&4).unwrap().features.clear_unknown_bits(); + network.channels.get_mut(&12).unwrap().features.clear_unknown_bits(); } { // Disable nodes 1, 2, and 8 by requiring unknown feature bits @@ -2032,8 +1995,7 @@ mod tests { excess_data: Vec::new(), }; - let channel_key = NetworkMap::get_key(unsigned_announcement.short_channel_id, - unsigned_announcement.chain_hash); + let channel_key = unsigned_announcement.short_channel_id; let mut msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]); let valid_announcement = ChannelAnnouncement { @@ -2089,8 +2051,7 @@ mod tests { // Now test if the transaction is found in the UTXO set and the script is correct. unsigned_announcement.short_channel_id += 1; *chain_monitor.utxo_ret.lock().unwrap() = Ok((good_script.clone(), 0)); - let channel_key = NetworkMap::get_key(unsigned_announcement.short_channel_id, - unsigned_announcement.chain_hash); + let channel_key = unsigned_announcement.short_channel_id; msghash = hash_to_message!(&Sha256dHash::hash(&unsigned_announcement.encode()[..])[..]); let valid_announcement = ChannelAnnouncement { @@ -2202,7 +2163,7 @@ mod tests { let zero_hash = Sha256dHash::hash(&[0; 32]); let short_channel_id = 0; let chain_hash = genesis_block(Network::Testnet).header.bitcoin_hash(); - let channel_key = NetworkMap::get_key(short_channel_id, chain_hash); + let channel_key = short_channel_id; { @@ -2333,7 +2294,7 @@ mod tests { let short_channel_id = 0; let chain_hash = genesis_block(Network::Testnet).header.bitcoin_hash(); - let channel_key = NetworkMap::get_key(short_channel_id, chain_hash); + let channel_key = short_channel_id; { // There is only local node in the table at the beginning. @@ -2421,7 +2382,7 @@ mod tests { let short_channel_id = 1; let chain_hash = genesis_block(Network::Testnet).header.bitcoin_hash(); - let channel_key = NetworkMap::get_key(short_channel_id, chain_hash); + let channel_key = short_channel_id; // Channels were not announced yet. let channels_with_announcements = router.get_next_channel_announcements(0, 1);