Skip to content

Commit 014449c

Browse files
committed
Delete EcdsaChannelSigner::sign_justice_revoked_htlc
1 parent d4e54eb commit 014449c

File tree

3 files changed

+18
-98
lines changed

3 files changed

+18
-98
lines changed

lightning/src/sign/ecdsa.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use bitcoin::transaction::Transaction;
44

55
use bitcoin::secp256k1;
66
use bitcoin::secp256k1::ecdsa::Signature;
7-
use bitcoin::secp256k1::{PublicKey, Secp256k1, SecretKey};
7+
use bitcoin::secp256k1::{PublicKey, Secp256k1};
88

99
use crate::ln::chan_utils::{ClosingTransaction, CommitmentTransaction, HTLCOutputInCommitment};
1010
use crate::ln::msgs::UnsignedChannelAnnouncement;
@@ -54,36 +54,6 @@ pub trait EcdsaChannelSigner: ChannelSigner {
5454
&self, commitment_tx: &CommitmentTransaction, inbound_htlc_preimages: Vec<PaymentPreimage>,
5555
outbound_htlc_preimages: Vec<PaymentPreimage>, secp_ctx: &Secp256k1<secp256k1::All>,
5656
) -> Result<(Signature, Vec<Signature>), ()>;
57-
/// Create a signature for the given input in a transaction spending a commitment transaction
58-
/// HTLC output when our counterparty broadcasts an old state.
59-
///
60-
/// A justice transaction may claim multiple outputs at the same time if timelocks are
61-
/// similar, but only a signature for the input at index `input` should be signed for here.
62-
/// It may be called multiple times for same output(s) if a fee-bump is needed with regards
63-
/// to an upcoming timelock expiration.
64-
///
65-
/// `amount` is the value of the output spent by this input, committed to in the BIP 143
66-
/// signature.
67-
///
68-
/// `per_commitment_key` is revocation secret which was provided by our counterparty when they
69-
/// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
70-
/// not allow the spending of any funds by itself (you need our holder revocation_secret to do
71-
/// so).
72-
///
73-
/// `htlc` holds HTLC elements (hash, timelock), thus changing the format of the witness script
74-
/// (which is committed to in the BIP 143 signatures).
75-
///
76-
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
77-
/// signature and should be retried later. Once the signer is ready to provide a signature after
78-
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
79-
/// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors.
80-
///
81-
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
82-
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
83-
fn sign_justice_revoked_htlc(
84-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
85-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
86-
) -> Result<Signature, ()>;
8757
/// Create a signature for a claiming transaction for a HTLC output on a counterparty's commitment
8858
/// transaction, either offered or received.
8959
///

lightning/src/sign/mod.rs

Lines changed: 17 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1698,15 +1698,23 @@ impl ChannelSigner for InMemorySigner {
16981698
);
16991699
let witness_script =
17001700
chan_utils::get_htlc_redeemscript(htlc, params.channel_type_features(), &keys);
1701-
let sig = EcdsaChannelSigner::sign_justice_revoked_htlc(
1702-
self,
1703-
justice_tx,
1704-
input,
1705-
amount,
1706-
per_commitment_key,
1707-
htlc,
1708-
secp_ctx,
1709-
)?;
1701+
let revocation_key = chan_utils::derive_private_revocation_key(
1702+
&secp_ctx,
1703+
&per_commitment_key,
1704+
&self.revocation_base_key,
1705+
);
1706+
let mut sighash_parts = sighash::SighashCache::new(justice_tx);
1707+
let sighash = hash_to_message!(
1708+
&sighash_parts
1709+
.p2wsh_signature_hash(
1710+
input,
1711+
&witness_script,
1712+
Amount::from_sat(amount),
1713+
EcdsaSighashType::All
1714+
)
1715+
.unwrap()[..]
1716+
);
1717+
let sig = sign_with_aux_rand(secp_ctx, &sighash, &revocation_key, &self);
17101718
let ecdsa_sig = EcdsaSignature::sighash_all(sig);
17111719
Ok(Witness::from(
17121720
&[
@@ -1896,56 +1904,6 @@ impl EcdsaChannelSigner for InMemorySigner {
18961904
Ok((commitment_sig, htlc_sigs))
18971905
}
18981906

1899-
fn sign_justice_revoked_htlc(
1900-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
1901-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
1902-
) -> Result<Signature, ()> {
1903-
let revocation_key = chan_utils::derive_private_revocation_key(
1904-
&secp_ctx,
1905-
&per_commitment_key,
1906-
&self.revocation_base_key,
1907-
);
1908-
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
1909-
let revocation_pubkey = RevocationKey::from_basepoint(
1910-
&secp_ctx,
1911-
&self.pubkeys().revocation_basepoint,
1912-
&per_commitment_point,
1913-
);
1914-
let witness_script = {
1915-
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1916-
let counterparty_htlcpubkey = HtlcKey::from_basepoint(
1917-
&secp_ctx,
1918-
&counterparty_keys.htlc_basepoint,
1919-
&per_commitment_point,
1920-
);
1921-
let holder_htlcpubkey = HtlcKey::from_basepoint(
1922-
&secp_ctx,
1923-
&self.pubkeys().htlc_basepoint,
1924-
&per_commitment_point,
1925-
);
1926-
let chan_type = self.channel_type_features().expect(MISSING_PARAMS_ERR);
1927-
chan_utils::get_htlc_redeemscript_with_explicit_keys(
1928-
&htlc,
1929-
chan_type,
1930-
&counterparty_htlcpubkey,
1931-
&holder_htlcpubkey,
1932-
&revocation_pubkey,
1933-
)
1934-
};
1935-
let mut sighash_parts = sighash::SighashCache::new(justice_tx);
1936-
let sighash = hash_to_message!(
1937-
&sighash_parts
1938-
.p2wsh_signature_hash(
1939-
input,
1940-
&witness_script,
1941-
Amount::from_sat(amount),
1942-
EcdsaSighashType::All
1943-
)
1944-
.unwrap()[..]
1945-
);
1946-
return Ok(sign_with_aux_rand(secp_ctx, &sighash, &revocation_key, &self));
1947-
}
1948-
19491907
fn sign_counterparty_htlc_transaction(
19501908
&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey,
19511909
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,

lightning/src/util/test_channel_signer.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -351,14 +351,6 @@ impl EcdsaChannelSigner for TestChannelSigner {
351351
Ok(self.inner.sign_counterparty_commitment(commitment_tx, inbound_htlc_preimages, outbound_htlc_preimages, secp_ctx).unwrap())
352352
}
353353

354-
fn sign_justice_revoked_htlc(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()> {
355-
#[cfg(test)]
356-
if !self.is_signer_available(SignerOp::SignJusticeRevokedHtlc) {
357-
return Err(());
358-
}
359-
Ok(EcdsaChannelSigner::sign_justice_revoked_htlc(&self.inner, justice_tx, input, amount, per_commitment_key, htlc, secp_ctx).unwrap())
360-
}
361-
362354
fn sign_counterparty_htlc_transaction(&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey, htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()> {
363355
#[cfg(test)]
364356
if !self.is_signer_available(SignerOp::SignCounterpartyHtlcTransaction) {

0 commit comments

Comments
 (0)