X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fchannelmonitor.rs;h=f32d2fbdb9d2b38cf225adfb313e9b4eb1a3ab5b;hb=a166eca0155a507cfcf1387a70be34c0a15184cb;hp=70f11405d0cb8399beb1c540acbe84ff20955982;hpb=f263b3793f4ee593e3358b68c8822524faecb9f1;p=rust-lightning diff --git a/lightning/src/ln/channelmonitor.rs b/lightning/src/ln/channelmonitor.rs index 70f11405d..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 { .. } => { } }