let nodes = create_network(2, &node_cfgs, &node_chanmgrs);
//Force duplicate channel ids
for node in nodes.iter() {
- *node.keys_manager.override_channel_id_priv.lock().unwrap() = Some([0; 32]);
+ *node.keys_manager.override_random_bytes.lock().unwrap() = Some([0; 32]);
}
// BOLT #2 spec: Sending node must ensure temporary_channel_id is unique from any other channel ID with the same peer.
let node_chanmgrs = create_node_chanmgrs(3, &node_cfgs, &[Some(config), Some(config), Some(node_2_cfg)]);
let mut nodes = create_network(3, &node_cfgs, &node_chanmgrs);
for node in nodes.iter() {
- *node.keys_manager.override_session_priv.lock().unwrap() = Some([3; 32]);
+ *node.keys_manager.override_random_bytes.lock().unwrap() = Some([3; 32]);
}
let channels = [create_announced_chan_between_nodes(&nodes, 0, 1, InitFeatures::known(), InitFeatures::known()), create_announced_chan_between_nodes(&nodes, 1, 2, InitFeatures::known(), InitFeatures::known())];
let (route, payment_hash, _, payment_secret) = get_route_and_payment_hash!(nodes[0], nodes[2], 40000);
// We'll use the session priv later when constructing an invalid onion packet.
let session_priv = [3; 32];
- *nodes[0].keys_manager.override_session_priv.lock().unwrap() = Some(session_priv);
+ *nodes[0].keys_manager.override_random_bytes.lock().unwrap() = Some(session_priv);
nodes[0].node.send_payment(&route, payment_hash.clone(), &Some(payment_secret)).unwrap();
check_added_monitors!(nodes[0], 1);
let update_0 = get_htlc_update_msgs!(nodes[0], nodes[1].node.get_our_node_id());
pub struct TestKeysInterface {
pub backing: keysinterface::PhantomKeysManager,
- pub override_session_priv: Mutex<Option<[u8; 32]>>,
- pub override_channel_id_priv: Mutex<Option<[u8; 32]>>,
+ pub override_random_bytes: Mutex<Option<[u8; 32]>>,
pub disable_revocation_policy_check: bool,
enforcement_states: Mutex<HashMap<[u8;32], Arc<Mutex<EnforcementState>>>>,
expectations: Mutex<Option<VecDeque<OnGetShutdownScriptpubkey>>>,
}
fn get_secure_random_bytes(&self) -> [u8; 32] {
- let override_channel_id = self.override_channel_id_priv.lock().unwrap();
- let override_session_key = self.override_session_priv.lock().unwrap();
- if override_channel_id.is_some() && override_session_key.is_some() {
- panic!("We don't know which override key to use!");
- }
- if let Some(key) = &*override_channel_id {
- return *key;
- }
- if let Some(key) = &*override_session_key {
- return *key;
+ let override_random_bytes = self.override_random_bytes.lock().unwrap();
+ if let Some(bytes) = &*override_random_bytes {
+ return *bytes;
}
self.backing.get_secure_random_bytes()
}
let now = Duration::from_secs(genesis_block(network).header.time as u64);
Self {
backing: keysinterface::PhantomKeysManager::new(seed, now.as_secs(), now.subsec_nanos(), seed),
- override_session_priv: Mutex::new(None),
- override_channel_id_priv: Mutex::new(None),
+ override_random_bytes: Mutex::new(None),
disable_revocation_policy_check: false,
enforcement_states: Mutex::new(HashMap::new()),
expectations: Mutex::new(None),