X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=lightning%2Fsrc%2Fln%2Fonchaintx.rs;h=f0d7072256aa0ef24d81e26e9363eee717b29a05;hb=9a23130db94246df059cd6fa2b69a40796a52e1e;hp=01294bba751cc369405181159e40a0c349da3107;hpb=4395b92cc8bfe0cc803e70bba11f4db58d5d0dbf;p=rust-lightning diff --git a/lightning/src/ln/onchaintx.rs b/lightning/src/ln/onchaintx.rs index 01294bba..f0d70722 100644 --- a/lightning/src/ln/onchaintx.rs +++ b/lightning/src/ln/onchaintx.rs @@ -583,12 +583,12 @@ impl OnchainTxHandler { for (i, (outp, per_outp_material)) in cached_claim_datas.per_input_material.iter().enumerate() { match per_outp_material { &InputMaterial::Revoked { ref per_commitment_point, ref remote_delayed_payment_base_key, ref remote_htlc_base_key, ref per_commitment_key, ref input_descriptor, ref amount, ref htlc, ref on_remote_tx_csv } => { - if let Ok(chan_keys) = TxCreationKeys::new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) { + if let Ok(chan_keys) = TxCreationKeys::derive_new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) { let witness_script = if let Some(ref htlc) = *htlc { - chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &chan_keys.a_htlc_key, &chan_keys.b_htlc_key, &chan_keys.revocation_key) + chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &chan_keys.broadcaster_htlc_key, &chan_keys.countersignatory_htlc_key, &chan_keys.revocation_key) } else { - chan_utils::get_revokeable_redeemscript(&chan_keys.revocation_key, *on_remote_tx_csv, &chan_keys.a_delayed_payment_key) + chan_utils::get_revokeable_redeemscript(&chan_keys.revocation_key, *on_remote_tx_csv, &chan_keys.broadcaster_delayed_payment_key) }; if let Ok(sig) = self.key_storage.sign_justice_transaction(&bumped_tx, i, *amount, &per_commitment_key, htlc, &self.secp_ctx) { @@ -607,11 +607,11 @@ impl OnchainTxHandler { } }, &InputMaterial::RemoteHTLC { ref per_commitment_point, ref remote_delayed_payment_base_key, ref remote_htlc_base_key, ref preimage, ref htlc } => { - if let Ok(chan_keys) = TxCreationKeys::new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) { - let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &chan_keys.a_htlc_key, &chan_keys.b_htlc_key, &chan_keys.revocation_key); + if let Ok(chan_keys) = TxCreationKeys::derive_new(&self.secp_ctx, &per_commitment_point, remote_delayed_payment_base_key, remote_htlc_base_key, &self.key_storage.pubkeys().revocation_basepoint, &self.key_storage.pubkeys().htlc_basepoint) { + let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&htlc, &chan_keys.broadcaster_htlc_key, &chan_keys.countersignatory_htlc_key, &chan_keys.revocation_key); if !preimage.is_some() { bumped_tx.lock_time = htlc.cltv_expiry }; // Right now we don't aggregate time-locked transaction, if we do we should set lock_time before to avoid breaking hash computation - if let Ok(sig) = self.key_storage.sign_remote_htlc_transaction(&bumped_tx, i, &htlc.amount_msat / 1000, &per_commitment_point, htlc, &self.secp_ctx) { + if let Ok(sig) = self.key_storage.sign_counterparty_htlc_transaction(&bumped_tx, i, &htlc.amount_msat / 1000, &per_commitment_point, htlc, &self.secp_ctx) { bumped_tx.input[i].witness.push(sig.serialize_der().to_vec()); bumped_tx.input[i].witness[0].push(SigHashType::All as u8); if let &Some(preimage) = preimage { @@ -893,7 +893,7 @@ impl OnchainTxHandler { fn sign_latest_local_htlcs(&mut self) { if let Some(ref local_commitment) = self.local_commitment { - if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, &self.secp_ctx) { + if let Ok(sigs) = self.key_storage.sign_holder_commitment_htlc_transactions(local_commitment, &self.secp_ctx) { self.local_htlc_sigs = Some(Vec::new()); let ret = self.local_htlc_sigs.as_mut().unwrap(); for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() { @@ -909,7 +909,7 @@ impl OnchainTxHandler { } fn sign_prev_local_htlcs(&mut self) { if let Some(ref local_commitment) = self.prev_local_commitment { - if let Ok(sigs) = self.key_storage.sign_local_commitment_htlc_transactions(local_commitment, &self.secp_ctx) { + if let Ok(sigs) = self.key_storage.sign_holder_commitment_htlc_transactions(local_commitment, &self.secp_ctx) { self.prev_local_htlc_sigs = Some(Vec::new()); let ret = self.prev_local_htlc_sigs.as_mut().unwrap(); for (htlc_idx, (local_sig, &(ref htlc, _))) in sigs.iter().zip(local_commitment.per_htlc.iter()).enumerate() { @@ -930,7 +930,7 @@ impl OnchainTxHandler { // to monitor before. pub(super) fn get_fully_signed_local_tx(&mut self, funding_redeemscript: &Script) -> Option { if let Some(ref mut local_commitment) = self.local_commitment { - match self.key_storage.sign_local_commitment(local_commitment, &self.secp_ctx) { + match self.key_storage.sign_holder_commitment(local_commitment, &self.secp_ctx) { Ok(sig) => Some(local_commitment.add_local_sig(funding_redeemscript, sig)), Err(_) => return None, } @@ -939,11 +939,11 @@ impl OnchainTxHandler { } } - #[cfg(test)] + #[cfg(any(test, feature="unsafe_revoked_tx_signing"))] pub(super) fn get_fully_signed_copy_local_tx(&mut self, funding_redeemscript: &Script) -> Option { if let Some(ref mut local_commitment) = self.local_commitment { let local_commitment = local_commitment.clone(); - match self.key_storage.sign_local_commitment(&local_commitment, &self.secp_ctx) { + match self.key_storage.sign_holder_commitment(&local_commitment, &self.secp_ctx) { Ok(sig) => Some(local_commitment.add_local_sig(funding_redeemscript, sig)), Err(_) => return None, } @@ -979,7 +979,7 @@ impl OnchainTxHandler { htlc_tx } - #[cfg(test)] + #[cfg(any(test,feature = "unsafe_revoked_tx_signing"))] pub(super) fn unsafe_get_fully_signed_htlc_tx(&mut self, outp: &::bitcoin::OutPoint, preimage: &Option) -> Option { let latest_had_sigs = self.local_htlc_sigs.is_some(); let prev_had_sigs = self.prev_local_htlc_sigs.is_some();