- let node1 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0202020202020202020202020202020202020202020202020202020202020202").unwrap()[..]).unwrap());
- let node2 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0303030303030303030303030303030303030303030303030303030303030303").unwrap()[..]).unwrap());
- let node3 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0404040404040404040404040404040404040404040404040404040404040404").unwrap()[..]).unwrap());
- let node4 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0505050505050505050505050505050505050505050505050505050505050505").unwrap()[..]).unwrap());
- let node5 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0606060606060606060606060606060606060606060606060606060606060606").unwrap()[..]).unwrap());
- let node6 = PublicKey::from_secret_key(&secp_ctx, &SecretKey::from_slice(&hex::decode("0707070707070707070707070707070707070707070707070707070707070707").unwrap()[..]).unwrap());
- 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.
- ($id: expr) => { {
- let idx = ($id - 1) * 2 + 1;
- if idx > 8*3 {
- vec![1 << (idx - 8*3), 0, 0, 0]
- } else if idx > 8*2 {
- vec![1 << (idx - 8*2), 0, 0]
- } else if idx > 8*1 {
- vec![1 << (idx - 8*1), 0]
- } else {
- vec![1 << idx]
- }
- } }
- }
-
- {
- 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())),
- lowest_inbound_channel_fee_base_msat: 100,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(1)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(1, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(1)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: our_id.clone(),
- last_update: 0,
- enabled: false,
- cltv_expiry_delta: u16::max_value(), // This value should be ignored
- htlc_minimum_msat: 0,
- fee_base_msat: u32::max_value(), // This value should be ignored
- fee_proportional_millionths: u32::max_value(), // This value should be ignored
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node1.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: 0,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- 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())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(2)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(2, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(2)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: our_id.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: u16::max_value(), // This value should be ignored
- htlc_minimum_msat: 0,
- fee_base_msat: u32::max_value(), // This value should be ignored
- fee_proportional_millionths: u32::max_value(), // This value should be ignored
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node2.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: 0,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- 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())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(8)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(12, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(12)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: our_id.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: u16::max_value(), // This value should be ignored
- htlc_minimum_msat: 0,
- fee_base_msat: u32::max_value(), // This value should be ignored
- fee_proportional_millionths: u32::max_value(), // This value should be ignored
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node8.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: 0,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- 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())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(3)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(3, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(3)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node1.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (3 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (3 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 100,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(4, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(4)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node2.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (4 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 1000000,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (4 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(13, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(13)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node8.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (13 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 2000000,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (13 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- 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())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(4)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(5, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(5)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (5 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 100,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node4.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (5 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- 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())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(5)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(6, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(6)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (6 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node5.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (6 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(11, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(11)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node5.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (11 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node4.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (11 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- network.nodes.insert(node6.clone(), NodeInfo {
- channels: vec!(NetworkMap::get_key(7, zero_hash.clone())),
- lowest_inbound_channel_fee_base_msat: 0,
- lowest_inbound_channel_fee_proportional_millionths: 0,
- features: NodeFeatures::from_le_bytes(id_to_feature_flags!(6)),
- last_update: Some(1),
- rgb: [0; 3],
- alias: [0; 32],
- addresses: Vec::new(),
- announcement_message: None,
- });
- network.channels.insert(NetworkMap::get_key(7, zero_hash.clone()), ChannelInfo {
- features: ChannelFeatures::from_le_bytes(id_to_feature_flags!(7)),
- one_to_two: DirectionalChannelInfo {
- src_node_id: node3.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (7 << 8) | 1,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 1000000,
- last_update_message: None,
- }, two_to_one: DirectionalChannelInfo {
- src_node_id: node6.clone(),
- last_update: 0,
- enabled: true,
- cltv_expiry_delta: (7 << 8) | 2,
- htlc_minimum_msat: 0,
- fee_base_msat: 0,
- fee_proportional_millionths: 0,
- last_update_message: None,
- },
- announcement_message: None,
- });
- }