- for &(ref htlc, ref sigs, _) in local_tx.htlc_outputs.iter() {
- if let Some(transaction_output_index) = htlc.transaction_output_index {
- if let &Some((ref their_sig, ref our_sig)) = sigs {
- if htlc.offered {
- log_trace!(self, "Broadcasting HTLC-Timeout transaction against local commitment transactions");
- let mut htlc_timeout_tx = chan_utils::build_htlc_transaction(&local_tx.txid, local_tx.feerate_per_kw, self.their_to_self_delay.unwrap(), htlc, &local_tx.delayed_payment_key, &local_tx.revocation_key);
-
- htlc_timeout_tx.input[0].witness.push(Vec::new()); // First is the multisig dummy
-
- htlc_timeout_tx.input[0].witness.push(their_sig.serialize_der().to_vec());
- htlc_timeout_tx.input[0].witness[1].push(SigHashType::All as u8);
- htlc_timeout_tx.input[0].witness.push(our_sig.serialize_der().to_vec());
- htlc_timeout_tx.input[0].witness[2].push(SigHashType::All as u8);
-
- htlc_timeout_tx.input[0].witness.push(Vec::new());
- let htlc_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(htlc, &local_tx.a_htlc_key, &local_tx.b_htlc_key, &local_tx.revocation_key);
- htlc_timeout_tx.input[0].witness.push(htlc_script.clone().into_bytes());
-
- add_dynamic_output!(htlc_timeout_tx, 0);
- let height_timer = Self::get_height_timer(height, htlc.cltv_expiry);
- let mut per_input_material = HashMap::with_capacity(1);
- per_input_material.insert(htlc_timeout_tx.input[0].previous_output, InputMaterial::LocalHTLC { script: htlc_script, sigs: (*their_sig, *our_sig), preimage: None, amount: htlc.amount_msat / 1000});
- log_trace!(self, "Outpoint {}:{} is being being claimed, if it doesn't succeed, a bumped claiming txn is going to be broadcast at height {}", htlc_timeout_tx.input[0].previous_output.vout, htlc_timeout_tx.input[0].previous_output.txid, height_timer);
- pending_claims.push((htlc_timeout_tx.txid(), ClaimTxBumpMaterial { height_timer, feerate_previous: 0, soonest_timelock: htlc.cltv_expiry, per_input_material }));
- res.push(htlc_timeout_tx);
- } else {
- if let Some(payment_preimage) = self.payment_preimages.get(&htlc.payment_hash) {
- log_trace!(self, "Broadcasting HTLC-Success transaction against local commitment transactions");
- let mut htlc_success_tx = chan_utils::build_htlc_transaction(&local_tx.txid, local_tx.feerate_per_kw, self.their_to_self_delay.unwrap(), htlc, &local_tx.delayed_payment_key, &local_tx.revocation_key);
-
- htlc_success_tx.input[0].witness.push(Vec::new()); // First is the multisig dummy
-
- htlc_success_tx.input[0].witness.push(their_sig.serialize_der().to_vec());
- htlc_success_tx.input[0].witness[1].push(SigHashType::All as u8);
- htlc_success_tx.input[0].witness.push(our_sig.serialize_der().to_vec());
- htlc_success_tx.input[0].witness[2].push(SigHashType::All as u8);
-
- htlc_success_tx.input[0].witness.push(payment_preimage.0.to_vec());
- let htlc_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(htlc, &local_tx.a_htlc_key, &local_tx.b_htlc_key, &local_tx.revocation_key);
- htlc_success_tx.input[0].witness.push(htlc_script.clone().into_bytes());
+ if let &Storage::Local { ref htlc_base_key, .. } = &self.key_storage {
+ for &(ref htlc, ref sigs, _) in local_tx.htlc_outputs.iter() {
+ if let Some(transaction_output_index) = htlc.transaction_output_index {
+ if let &Some(ref their_sig) = sigs {
+ if htlc.offered {
+ log_trace!(self, "Broadcasting HTLC-Timeout transaction against local commitment transactions");
+ let mut htlc_timeout_tx = chan_utils::build_htlc_transaction(&local_tx.txid, local_tx.feerate_per_kw, self.their_to_self_delay.unwrap(), htlc, &local_tx.delayed_payment_key, &local_tx.revocation_key);
+ let (our_sig, htlc_script) = match
+ chan_utils::sign_htlc_transaction(&mut htlc_timeout_tx, their_sig, &None, htlc, &local_tx.a_htlc_key, &local_tx.b_htlc_key, &local_tx.revocation_key, &local_tx.per_commitment_point, htlc_base_key, &self.secp_ctx) {
+ Ok(res) => res,
+ Err(_) => continue,
+ };