Drop unused Network argument to KeysManager::new().
authorMatt Corallo <git@bluematt.me>
Wed, 3 Feb 2021 04:23:25 +0000 (23:23 -0500)
committerMatt Corallo <git@bluematt.me>
Tue, 16 Feb 2021 20:58:02 +0000 (15:58 -0500)
KeyManager::new() took a bitcoin::Network parameter which needs to
be passed to the BIP 32 Extended Key constructor, but because we
never write out the BIP 32 serialization, it isn't used. Instead,
we just pass a dummy value into `ExtendedPrivKey`, dropping the
unused argument to KeysManager::new().

lightning/src/chain/keysinterface.rs
lightning/src/util/test_utils.rs

index eaf6e5497f3141d9fea5ace617d23ec3554b5793..68c6137c89051ea7fcf442959364dd9eb865007b 100644 (file)
@@ -723,9 +723,10 @@ impl KeysManager {
        /// Note that until the 0.1 release there is no guarantee of backward compatibility between
        /// versions. Once the library is more fully supported, the docs will be updated to include a
        /// detailed description of the guarantee.
-       pub fn new(seed: &[u8; 32], network: Network, starting_time_secs: u64, starting_time_nanos: u32) -> Self {
+       pub fn new(seed: &[u8; 32], starting_time_secs: u64, starting_time_nanos: u32) -> Self {
                let secp_ctx = Secp256k1::signing_only();
-               match ExtendedPrivKey::new_master(network.clone(), seed) {
+               // Note that when we aren't serializing the key, network doesn't matter
+               match ExtendedPrivKey::new_master(Network::Testnet, seed) {
                        Ok(master_key) => {
                                let node_secret = master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(0).unwrap()).expect("Your RNG is busted").private_key.key;
                                let destination_script = match master_key.ckd_priv(&secp_ctx, ChildNumber::from_hardened_idx(1).unwrap()) {
index b758f5c65af5a15e168f27a3eaf0c9cc8196b16e..98565bdf60fcff4e9a1fff1392b4e9e39a352f64 100644 (file)
@@ -475,7 +475,7 @@ impl TestKeysInterface {
        pub fn new(seed: &[u8; 32], network: Network) -> Self {
                let now = Duration::from_secs(genesis_block(network).header.time as u64);
                Self {
-                       backing: keysinterface::KeysManager::new(seed, network, now.as_secs(), now.subsec_nanos()),
+                       backing: keysinterface::KeysManager::new(seed, now.as_secs(), now.subsec_nanos()),
                        override_session_priv: Mutex::new(None),
                        override_channel_id_priv: Mutex::new(None),
                        disable_revocation_policy_check: false,