X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannelmonitor.rs;h=f32d2fbdb9d2b38cf225adfb313e9b4eb1a3ab5b;hb=e325598e674022af82ef5f976e9b11f430fb71bf;hp=94d13a8117ae4ac91aa532c3e1b1fb80e1ed4bad;hpb=fbc7885a97ce3807e390ee5427908d7ac069042a;p=rust-lightning diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 94d13a811..f32d2fbdb 100644 --- a/lightning/src/ln/channelmonitor.rs +++ b/lightning/src/ln/channelmonitor.rs @@ -152,7 +152,6 @@ pub struct SimpleManyChannelMonitor { } impl<'a, Key : Send + cmp::Eq + hash::Hash> ChainListener for SimpleManyChannelMonitor { - fn block_connected(&self, header: &BlockHeader, height: u32, txn_matched: &[&Transaction], _indexes_of_txn_matched: &[u32]) { let block_hash = header.bitcoin_hash(); let mut new_events: Vec = Vec::with_capacity(0); @@ -219,8 +218,8 @@ impl<'a, Key : Send + cmp::Eq + hash::Hash> ChainListener for SimpleManyChannelM impl SimpleManyChannelMonitor { /// Creates a new object which can be used to monitor several channels given the chain /// interface with which to register to receive notifications. - pub fn new(chain_monitor: Arc, broadcaster: Arc, logger: Arc, feeest: Arc) -> Arc> { - let res = Arc::new(SimpleManyChannelMonitor { + pub fn new(chain_monitor: Arc, broadcaster: Arc, logger: Arc, feeest: Arc) -> SimpleManyChannelMonitor { + let res = SimpleManyChannelMonitor { monitors: Mutex::new(HashMap::new()), chain_monitor, broadcaster, @@ -228,7 +227,7 @@ impl SimpleManyChannelMonitor pending_htlc_updated: Mutex::new(HashMap::new()), logger, fee_estimator: feeest, - }); + }; res } @@ -2058,7 +2057,7 @@ impl ChannelMonitor { assert!(predicted_weight >= spend_tx.get_weight()); let outpoint = BitcoinOutPoint { txid: spend_tx.txid(), vout: 0 }; let output = spend_tx.output[0].clone(); - let height_timer = Self::get_height_timer(height, self.their_to_self_delay.unwrap() as u32); // We can safely unwrap given we are past channel opening + let height_timer = Self::get_height_timer(height, height + self.our_to_self_delay as u32); log_trace!(self, "Outpoint {}:{} is being being claimed, if it doesn't succeed, a bumped claiming txn is going to be broadcast at height {}", spend_tx.input[0].previous_output.txid, spend_tx.input[0].previous_output.vout, height_timer); let mut per_input_material = HashMap::with_capacity(1); per_input_material.insert(spend_tx.input[0].previous_output, InputMaterial::Revoked { script: redeemscript, pubkey: None, key: revocation_key, is_htlc: false, amount: tx.output[0].value }); @@ -2219,7 +2218,8 @@ impl ChannelMonitor { assert!(local_tx.tx.has_local_sig()); match self.key_storage { Storage::Local { ref delayed_payment_base_key, .. } => { - append_onchain_update!(self.broadcast_by_local_state(local_tx, delayed_payment_base_key, height)); + let mut res = self.broadcast_by_local_state(local_tx, delayed_payment_base_key, height); + append_onchain_update!(res); }, Storage::Watchtower { .. } => { } } @@ -2242,7 +2242,8 @@ impl ChannelMonitor { assert!(local_tx.tx.has_local_sig()); match self.key_storage { Storage::Local { ref delayed_payment_base_key, .. } => { - append_onchain_update!(self.broadcast_by_local_state(local_tx, delayed_payment_base_key, height)); + let mut res = self.broadcast_by_local_state(local_tx, delayed_payment_base_key, height); + append_onchain_update!(res); }, Storage::Watchtower { .. } => { } } @@ -2555,6 +2556,7 @@ impl ChannelMonitor { } fn block_disconnected(&mut self, height: u32, block_hash: &Sha256dHash, broadcaster: &BroadcasterInterface, fee_estimator: &FeeEstimator) { + log_trace!(self, "Block {} at height {} disconnected", block_hash, height); let mut bump_candidates = HashMap::new(); if let Some(events) = self.onchain_events_waiting_threshold_conf.remove(&(height + ANTI_REORG_DELAY - 1)) { //We may discard: