From: Antoine Riard Date: Wed, 18 Mar 2020 04:29:26 +0000 (-0400) Subject: Add ChanSigner in OnchainTxHandler X-Git-Tag: v0.0.12~93^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=16fba9fd664522ac8d24111547b41dd4ff94812b;p=rust-lightning Add ChanSigner in OnchainTxHandler Rename ChannelMonitor::Storage to OnchainDetection, holder of channel state (base_key+per_commitment_point) to detect onchain transactions accordingly. Going further between splitting detection and transaction generation, we endow OnchainTxHandler with keys access. That way, in latter commits, we may remove secret keys entirely from ChannelMonitor. --- diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 8b73f0f75..868a5d4f7 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -290,7 +290,7 @@ impl return Err(MonitorUpdateError("Channel monitor for given key is already present")), hash_map::Entry::Vacant(e) => e, }; - match monitor.key_storage.funding_info { + match monitor.onchain_detection.funding_info { None => { return Err(MonitorUpdateError("Try to update a useless monitor without funding_txo !")); }, @@ -314,7 +314,7 @@ impl { - log_trace!(self, "Updating Channel Monitor for channel {}", log_funding_info!(orig_monitor.key_storage)); + log_trace!(self, "Updating Channel Monitor for channel {}", log_funding_info!(orig_monitor.onchain_detection)); orig_monitor.update_monitor(update, &self.broadcaster) }, None => Err(MonitorUpdateError("No such monitor registered")) @@ -391,7 +391,7 @@ pub(crate) const LATENCY_GRACE_PERIOD_BLOCKS: u32 = 3; /// keeping bumping another claim tx to solve the outpoint. pub(crate) const ANTI_REORG_DELAY: u32 = 6; -struct Storage { +struct OnchainDetection { keys: ChanSigner, funding_key: SecretKey, revocation_base_key: SecretKey, @@ -404,7 +404,7 @@ struct Storage { } #[cfg(any(test, feature = "fuzztarget"))] -impl PartialEq for Storage { +impl PartialEq for OnchainDetection { fn eq(&self, other: &Self) -> bool { self.keys.pubkeys() == other.keys.pubkeys() } @@ -737,7 +737,7 @@ pub struct ChannelMonitor { broadcasted_remote_payment_script: Option<(Script, SecretKey)>, shutdown_script: Script, - key_storage: Storage, + onchain_detection: OnchainDetection, their_htlc_base_key: Option, their_delayed_payment_base_key: Option, funding_redeemscript: Option