From: Matt Corallo Date: Thu, 12 Dec 2019 19:56:28 +0000 (-0500) Subject: Set basic channel info in chanmon all at once, add a bit more info X-Git-Tag: v0.0.12~163^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=200e8983ad45bded3a70138c1ead5c2d02468694;p=rust-lightning Set basic channel info in chanmon all at once, add a bit more info --- diff --git a/lightning/src/ln/channel.rs b/lightning/src/ln/channel.rs index 889fec05c..0fb7012cb 100644 --- a/lightning/src/ln/channel.rs +++ b/lightning/src/ln/channel.rs @@ -644,11 +644,9 @@ impl Channel { } let secp_ctx = Secp256k1::new(); - let mut channel_monitor = ChannelMonitor::new(chan_keys.revocation_base_key(), chan_keys.delayed_payment_base_key(), - chan_keys.htlc_base_key(), chan_keys.payment_base_key(), &keys_provider.get_shutdown_pubkey(), config.own_channel_config.our_to_self_delay, - keys_provider.get_destination_script(), logger.clone()); - channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint); - channel_monitor.set_their_to_self_delay(msg.to_self_delay); + let channel_monitor = ChannelMonitor::new(chan_keys.revocation_base_key(), chan_keys.delayed_payment_base_key(), + chan_keys.htlc_base_key(), chan_keys.payment_base_key(), &keys_provider.get_shutdown_pubkey(), config.own_channel_config.our_to_self_delay, + keys_provider.get_destination_script(), logger.clone()); let their_shutdown_scriptpubkey = if their_local_features.supports_upfront_shutdown_script() { match &msg.shutdown_scriptpubkey { @@ -748,7 +746,8 @@ impl Channel { }; let obscure_factor = chan.get_commitment_transaction_number_obscure_factor(); - chan.channel_monitor.set_commitment_obscure_factor(obscure_factor); + let funding_redeemscript = chan.get_funding_redeemscript(); + chan.channel_monitor.set_basic_channel_info(&msg.htlc_basepoint, &msg.delayed_payment_basepoint, msg.to_self_delay, funding_redeemscript, msg.funding_satoshis, obscure_factor); Ok(chan) } @@ -1469,8 +1468,6 @@ impl Channel { } } else { None }; - self.channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint); - self.their_dust_limit_satoshis = msg.dust_limit_satoshis; self.their_max_htlc_value_in_flight_msat = cmp::min(msg.max_htlc_value_in_flight_msat, self.channel_value_satoshis * 1000); self.their_channel_reserve_satoshis = msg.channel_reserve_satoshis; @@ -1487,8 +1484,8 @@ impl Channel { self.their_shutdown_scriptpubkey = their_shutdown_scriptpubkey; let obscure_factor = self.get_commitment_transaction_number_obscure_factor(); - self.channel_monitor.set_commitment_obscure_factor(obscure_factor); - self.channel_monitor.set_their_to_self_delay(msg.to_self_delay); + let funding_redeemscript = self.get_funding_redeemscript(); + self.channel_monitor.set_basic_channel_info(&msg.htlc_basepoint, &msg.delayed_payment_basepoint, msg.to_self_delay, funding_redeemscript, self.channel_value_satoshis, obscure_factor); self.channel_state = ChannelState::OurInitSent as u32 | ChannelState::TheirInitSent as u32; diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index bde08bc51..fef352ce4 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -571,6 +571,8 @@ pub struct ChannelMonitor { key_storage: Storage, their_htlc_base_key: Option, their_delayed_payment_base_key: Option, + funding_redeemscript: Option