+ }
+ }
+
+ if let Some(ref current_local_signed_commitment_tx) = self.current_local_signed_commitment_tx {
+ if input.previous_output.txid == current_local_signed_commitment_tx.txid {
+ scan_commitment!(current_local_signed_commitment_tx.htlc_outputs.iter().map(|&(ref a, _, _)| a),
+ current_local_signed_commitment_tx.htlc_sources,
+ "our latest local commitment tx");
+ }
+ }
+ if let Some(ref prev_local_signed_commitment_tx) = self.prev_local_signed_commitment_tx {
+ if input.previous_output.txid == prev_local_signed_commitment_tx.txid {
+ scan_commitment!(prev_local_signed_commitment_tx.htlc_outputs.iter().map(|&(ref a, _, _)| a),
+ prev_local_signed_commitment_tx.htlc_sources,
+ "our latest local commitment tx");
+ }
+ }
+ if let Some(&(ref htlc_outputs, ref htlc_sources)) = self.remote_claimable_outpoints.get(&input.previous_output.txid) {
+ scan_commitment!(htlc_outputs, htlc_sources, "remote commitment tx");
+ }
+
+ // If tx isn't solving htlc output from local/remote commitment tx and htlc isn't outbound we don't need
+ // to broadcast solving backward
+ if let Some((source, payment_hash)) = payment_data {
+ let mut payment_preimage = PaymentPreimage([0; 32]);
+ if (input.witness.len() == 3 && input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT && input.witness[1].len() == 33)
+ || (input.witness.len() == 3 && input.witness[2].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT && input.witness[1].len() == 33) {
+ log_error!(self, "Remote used revocation sig to take a {} HTLC output at index {} from commitment_tx {}", if input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT { "offered" } else { "accepted" }, input.previous_output.vout, input.previous_output.txid);
+ } else if input.witness.len() == 5 && input.witness[4].len() == ACCEPTED_HTLC_SCRIPT_WEIGHT {
+ payment_preimage.0.copy_from_slice(&tx.input[0].witness[3]);
+ htlc_updated.push((source, Some(payment_preimage), payment_hash));
+ } else if input.witness.len() == 3 && input.witness[2].len() == OFFERED_HTLC_SCRIPT_WEIGHT {
+ payment_preimage.0.copy_from_slice(&tx.input[0].witness[1]);
+ htlc_updated.push((source, Some(payment_preimage), payment_hash));
+ } else {
+ htlc_updated.push((source, None, payment_hash));