+ commitment_seed: [u8; 32],
+ /// Local public keys and basepoints
+ pub(crate) local_channel_pubkeys: ChannelPublicKeys,
+ /// Remote public keys and base points
+ pub(crate) remote_channel_pubkeys: Option<ChannelPublicKeys>,
+ /// The total value of this channel
+ channel_value_satoshis: u64,
+}
+
+impl InMemoryChannelKeys {
+ /// Create a new InMemoryChannelKeys
+ pub fn new<C: Signing>(
+ secp_ctx: &Secp256k1<C>,
+ funding_key: SecretKey,
+ revocation_base_key: SecretKey,
+ payment_base_key: SecretKey,
+ delayed_payment_base_key: SecretKey,
+ htlc_base_key: SecretKey,
+ commitment_seed: [u8; 32],
+ channel_value_satoshis: u64) -> InMemoryChannelKeys {
+ let local_channel_pubkeys =
+ InMemoryChannelKeys::make_local_keys(secp_ctx, &funding_key, &revocation_base_key,
+ &payment_base_key, &delayed_payment_base_key,
+ &htlc_base_key);
+ InMemoryChannelKeys {
+ funding_key,
+ revocation_base_key,
+ payment_base_key,
+ delayed_payment_base_key,
+ htlc_base_key,
+ commitment_seed,
+ channel_value_satoshis,
+ local_channel_pubkeys,
+ remote_channel_pubkeys: None,
+ }
+ }
+
+ fn make_local_keys<C: Signing>(secp_ctx: &Secp256k1<C>,
+ funding_key: &SecretKey,
+ revocation_base_key: &SecretKey,
+ payment_base_key: &SecretKey,
+ delayed_payment_base_key: &SecretKey,
+ htlc_base_key: &SecretKey) -> ChannelPublicKeys {
+ let from_secret = |s: &SecretKey| PublicKey::from_secret_key(secp_ctx, s);
+ ChannelPublicKeys {
+ funding_pubkey: from_secret(&funding_key),
+ revocation_basepoint: from_secret(&revocation_base_key),
+ payment_basepoint: from_secret(&payment_base_key),
+ delayed_payment_basepoint: from_secret(&delayed_payment_base_key),
+ htlc_basepoint: from_secret(&htlc_base_key),
+ }
+ }