X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fln%2Fchannelmonitor.rs;h=55e534c826969d3b1af39c11fe32b3ff860987f2;hb=f48fe4bd8c3f775f487de81ef807c309d1b4e1f3;hp=f037c673079b2b0071697c012bbbac3d4d4d850d;hpb=27d5a3a94f9bac6d88f4ea364142d98a8ff2dc20;p=rust-lightning diff --git a/src/ln/channelmonitor.rs b/src/ln/channelmonitor.rs index f037c673..55e534c8 100644 --- a/src/ln/channelmonitor.rs +++ b/src/ln/channelmonitor.rs @@ -1222,7 +1222,7 @@ impl ChannelMonitor { }; } - let secret = self.get_secret(commitment_number).unwrap(); + let secret = ignore_error!(self.get_secret(commitment_number)); let per_commitment_key = ignore_error!(SecretKey::from_slice(&self.secp_ctx, &secret)); let per_commitment_point = PublicKey::from_secret_key(&self.secp_ctx, &per_commitment_key); let revocation_pubkey = match self.key_storage { @@ -1269,7 +1269,6 @@ impl ChannelMonitor { output: outputs, }; - let sighash_parts = bip143::SighashComponents::new(&spend_tx); let sig = match self.key_storage { @@ -1352,9 +1351,14 @@ impl ChannelMonitor { fn block_connected(&self, txn_matched: &[&Transaction], height: u32, broadcaster: &BroadcasterInterface)-> Vec<(Sha256dHash, Vec)> { let mut watch_outputs = Vec::new(); for tx in txn_matched { - let mut txn: Vec = Vec::new(); - for txin in tx.input.iter() { - if self.funding_txo.is_none() || (txin.previous_output.txid == self.funding_txo.as_ref().unwrap().0.txid && txin.previous_output.vout == self.funding_txo.as_ref().unwrap().0.index as u32) { + if tx.input.len() == 1 { + // Assuming our keys were not leaked (in which case we're screwed no matter what), + // commitment transactions and HTLC transactions will all only ever have one input, + // which is an easy way to filter out any potential non-matching txn for lazy + // filters. + let prevout = &tx.input[0].previous_output; + let mut txn: Vec = Vec::new(); + if self.funding_txo.is_none() || (prevout.txid == self.funding_txo.as_ref().unwrap().0.txid && prevout.vout == self.funding_txo.as_ref().unwrap().0.index as u32) { let (remote_txn, new_outputs) = self.check_spend_remote_transaction(tx, height); txn = remote_txn; if !new_outputs.1.is_empty() {