Skip to content

Commit 5f27ad7

Browse files
committed
Delete EcdsaChannelSigner::sign_justice_revoked_htlc
1 parent fbc1b5c commit 5f27ad7

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
@@ -1661,15 +1661,23 @@ impl ChannelSigner for InMemorySigner {
16611661
);
16621662
let witness_script =
16631663
chan_utils::get_htlc_redeemscript(htlc, params.channel_type_features(), &keys);
1664-
let sig = EcdsaChannelSigner::sign_justice_revoked_htlc(
1665-
self,
1666-
justice_tx,
1667-
input,
1668-
amount,
1669-
per_commitment_key,
1670-
htlc,
1671-
secp_ctx,
1672-
)?;
1664+
let revocation_key = chan_utils::derive_private_revocation_key(
1665+
&secp_ctx,
1666+
&per_commitment_key,
1667+
&self.revocation_base_key,
1668+
);
1669+
let mut sighash_parts = sighash::SighashCache::new(justice_tx);
1670+
let sighash = hash_to_message!(
1671+
&sighash_parts
1672+
.p2wsh_signature_hash(
1673+
input,
1674+
&witness_script,
1675+
Amount::from_sat(amount),
1676+
EcdsaSighashType::All
1677+
)
1678+
.unwrap()[..]
1679+
);
1680+
let sig = sign_with_aux_rand(secp_ctx, &sighash, &revocation_key, &self);
16731681
let ecdsa_sig = EcdsaSignature::sighash_all(sig);
16741682
Ok(Witness::from(
16751683
&[
@@ -1870,56 +1878,6 @@ impl EcdsaChannelSigner for InMemorySigner {
18701878
Ok((commitment_sig, htlc_sigs))
18711879
}
18721880

1873-
fn sign_justice_revoked_htlc(
1874-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
1875-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
1876-
) -> Result<Signature, ()> {
1877-
let revocation_key = chan_utils::derive_private_revocation_key(
1878-
&secp_ctx,
1879-
&per_commitment_key,
1880-
&self.revocation_base_key,
1881-
);
1882-
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
1883-
let revocation_pubkey = RevocationKey::from_basepoint(
1884-
&secp_ctx,
1885-
&self.pubkeys().revocation_basepoint,
1886-
&per_commitment_point,
1887-
);
1888-
let witness_script = {
1889-
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1890-
let counterparty_htlcpubkey = HtlcKey::from_basepoint(
1891-
&secp_ctx,
1892-
&counterparty_keys.htlc_basepoint,
1893-
&per_commitment_point,
1894-
);
1895-
let holder_htlcpubkey = HtlcKey::from_basepoint(
1896-
&secp_ctx,
1897-
&self.pubkeys().htlc_basepoint,
1898-
&per_commitment_point,
1899-
);
1900-
let chan_type = self.channel_type_features().expect(MISSING_PARAMS_ERR);
1901-
chan_utils::get_htlc_redeemscript_with_explicit_keys(
1902-
&htlc,
1903-
chan_type,
1904-
&counterparty_htlcpubkey,
1905-
&holder_htlcpubkey,
1906-
&revocation_pubkey,
1907-
)
1908-
};
1909-
let mut sighash_parts = sighash::SighashCache::new(justice_tx);
1910-
let sighash = hash_to_message!(
1911-
&sighash_parts
1912-
.p2wsh_signature_hash(
1913-
input,
1914-
&witness_script,
1915-
Amount::from_sat(amount),
1916-
EcdsaSighashType::All
1917-
)
1918-
.unwrap()[..]
1919-
);
1920-
return Ok(sign_with_aux_rand(secp_ctx, &sighash, &revocation_key, &self));
1921-
}
1922-
19231881
fn sign_counterparty_htlc_transaction(
19241882
&self, htlc_tx: &Transaction, input: usize, amount: u64, per_commitment_point: &PublicKey,
19251883
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
@@ -358,14 +358,6 @@ impl EcdsaChannelSigner for TestChannelSigner {
358358
Ok(self.inner.sign_counterparty_commitment(commitment_tx, inbound_htlc_preimages, outbound_htlc_preimages, secp_ctx).unwrap())
359359
}
360360

361-
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, ()> {
362-
#[cfg(test)]
363-
if !self.is_signer_available(SignerOp::SignJusticeRevokedHtlc) {
364-
return Err(());
365-
}
366-
Ok(EcdsaChannelSigner::sign_justice_revoked_htlc(&self.inner, justice_tx, input, amount, per_commitment_key, htlc, secp_ctx).unwrap())
367-
}
368-
369361
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, ()> {
370362
#[cfg(test)]
371363
if !self.is_signer_available(SignerOp::SignCounterpartyHtlcTransaction) {

0 commit comments

Comments
 (0)