chain_monitor: Arc<chaininterface::ChainWatchInterfaceUtil>,
tx_broadcaster: Arc<test_utils::TestBroadcaster>,
chan_monitor: Arc<test_utils::TestChannelMonitor>,
+ keys_manager: Arc<test_utils::TestKeysInterface>,
node: Arc<ChannelManager>,
router: Router,
node_seed: [u8; 32],
let tx_broadcaster = Arc::new(test_utils::TestBroadcaster{txn_broadcasted: Mutex::new(Vec::new())});
let mut seed = [0; 32];
rng.fill_bytes(&mut seed);
- let keys_manager = Arc::new(keysinterface::KeysManager::new(&seed, Network::Testnet, Arc::clone(&logger)));
+ let keys_manager = Arc::new(test_utils::TestKeysInterface::new(&seed, Network::Testnet, Arc::clone(&logger)));
let chan_monitor = Arc::new(test_utils::TestChannelMonitor::new(chain_monitor.clone(), tx_broadcaster.clone(), logger.clone()));
let mut config = UserConfig::new();
config.channel_options.announced_channel = true;
config.channel_limits.force_announced_channel_preference = false;
let node = ChannelManager::new(Network::Testnet, feeest.clone(), chan_monitor.clone(), chain_monitor.clone(), tx_broadcaster.clone(), Arc::clone(&logger), keys_manager.clone(), config).unwrap();
let router = Router::new(PublicKey::from_secret_key(&secp_ctx, &keys_manager.get_node_secret()), chain_monitor.clone(), Arc::clone(&logger));
- nodes.push(Node { chain_monitor, tx_broadcaster, chan_monitor, node, router, node_seed: seed,
+ nodes.push(Node { chain_monitor, tx_broadcaster, chan_monitor, node, router, keys_manager, node_seed: seed,
network_payment_count: payment_count.clone(),
network_chan_count: chan_count.clone(),
});
use chain::chaininterface;
use chain::chaininterface::ConfirmationTarget;
use chain::transaction::OutPoint;
+use chain::keysinterface;
use ln::channelmonitor;
use ln::msgs;
use ln::msgs::{HandleError};
use util::ser::{ReadableArgs, Writer};
use bitcoin::blockdata::transaction::Transaction;
+use bitcoin::blockdata::script::Script;
use bitcoin::util::hash::Sha256dHash;
+use bitcoin::network::constants::Network;
-use secp256k1::PublicKey;
+use secp256k1::{SecretKey, PublicKey};
use std::sync::{Arc,Mutex};
use std::{mem};
}
}
}
+
+pub struct TestKeysInterface {
+ backing: keysinterface::KeysManager,
+ pub override_session_priv: Mutex<Option<SecretKey>>,
+}
+
+impl keysinterface::KeysInterface for TestKeysInterface {
+ fn get_node_secret(&self) -> SecretKey { self.backing.get_node_secret() }
+ fn get_destination_script(&self) -> Script { self.backing.get_destination_script() }
+ fn get_shutdown_pubkey(&self) -> PublicKey { self.backing.get_shutdown_pubkey() }
+ fn get_channel_keys(&self, inbound: bool) -> keysinterface::ChannelKeys { self.backing.get_channel_keys(inbound) }
+
+ fn get_session_key(&self) -> SecretKey {
+ match *self.override_session_priv.lock().unwrap() {
+ Some(key) => key.clone(),
+ None => self.backing.get_session_key()
+ }
+ }
+}
+
+impl TestKeysInterface {
+ pub fn new(seed: &[u8; 32], network: Network, logger: Arc<Logger>) -> Self {
+ Self {
+ backing: keysinterface::KeysManager::new(seed, network, logger),
+ override_session_priv: Mutex::new(None),
+ }
+ }
+}