Merge pull request #223 from TheBlueMatt/2018-10-chanmanager-serialize
[rust-lightning] / src / chain / keysinterface.rs
index 3e4ff0e36991320fb67f4be28f4fa460f05408c1..18b069369b70e72455cee7cc80893a76bacb5195 100644 (file)
@@ -62,6 +62,7 @@ pub trait KeysInterface: Send + Sync {
 }
 
 /// Set of lightning keys needed to operate a channel as described in BOLT 3
+#[derive(Clone)]
 pub struct ChannelKeys {
        /// Private key of anchor tx
        pub funding_key: SecretKey,
@@ -73,14 +74,19 @@ pub struct ChannelKeys {
        pub delayed_payment_base_key: SecretKey,
        /// Local htlc secret key used in commitment tx htlc outputs
        pub htlc_base_key: SecretKey,
-       /// Local secret key used for closing tx
-       pub channel_close_key: SecretKey,
-       /// Local secret key used in justice tx, claim tx and preimage tx outputs
-       pub channel_monitor_claim_key: SecretKey,
        /// Commitment seed
        pub commitment_seed: [u8; 32],
 }
 
+impl_writeable!(ChannelKeys, 0, {
+       funding_key,
+       revocation_base_key,
+       payment_base_key,
+       delayed_payment_base_key,
+       htlc_base_key,
+       commitment_seed
+});
+
 impl ChannelKeys {
        /// Generate a set of lightning keys needed to operate a channel by HKDF-expanding a given
        /// random 32-byte seed
@@ -105,12 +111,6 @@ impl ChannelKeys {
                hkdf_expand(Sha256::new(), &prk, b"rust-lightning htlc base key info", &mut okm);
                let htlc_base_key = SecretKey::from_slice(&secp_ctx, &okm).expect("Sha256 is broken");
 
-               hkdf_expand(Sha256::new(), &prk, b"rust-lightning channel close key info", &mut okm);
-               let channel_close_key = SecretKey::from_slice(&secp_ctx, &okm).expect("Sha256 is broken");
-
-               hkdf_expand(Sha256::new(), &prk, b"rust-lightning channel monitor claim key info", &mut okm);
-               let channel_monitor_claim_key = SecretKey::from_slice(&secp_ctx, &okm).expect("Sha256 is broken");
-
                hkdf_expand(Sha256::new(), &prk, b"rust-lightning local commitment seed info", &mut okm);
 
                ChannelKeys {
@@ -119,8 +119,6 @@ impl ChannelKeys {
                        payment_base_key: payment_base_key,
                        delayed_payment_base_key: delayed_payment_base_key,
                        htlc_base_key: htlc_base_key,
-                       channel_close_key: channel_close_key,
-                       channel_monitor_claim_key: channel_monitor_claim_key,
                        commitment_seed: okm
                }
        }