Skip to content

Commit e64ebfc

Browse files
committed
Delete EcdsaChannelSigner::sign_justice_revoked_output
1 parent 17893e2 commit e64ebfc

File tree

3 files changed

+17
-86
lines changed

3 files changed

+17
-86
lines changed

lightning/src/sign/ecdsa.rs

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -54,32 +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 an HTLC transaction output
58-
/// or a commitment transaction `to_local` 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 value of the output spent by this input, committed to in the BIP 143 signature.
66-
///
67-
/// `per_commitment_key` is revocation secret which was provided by our counterparty when they
68-
/// revoked the state which they eventually broadcast. It's not a _holder_ secret key and does
69-
/// not allow the spending of any funds by itself (you need our holder `revocation_secret` to do
70-
/// so).
71-
///
72-
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
73-
/// signature and should be retried later. Once the signer is ready to provide a signature after
74-
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
75-
/// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors.
76-
///
77-
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
78-
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
79-
fn sign_justice_revoked_output(
80-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
81-
secp_ctx: &Secp256k1<secp256k1::All>,
82-
) -> Result<Signature, ()>;
8357
/// Create a signature for the given input in a transaction spending a commitment transaction
8458
/// HTLC output when our counterparty broadcasts an old state.
8559
///

lightning/src/sign/mod.rs

Lines changed: 17 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,14 +1661,23 @@ impl ChannelSigner for InMemorySigner {
16611661
contest_delay,
16621662
&keys.broadcaster_delayed_payment_key,
16631663
);
1664-
let sig = EcdsaChannelSigner::sign_justice_revoked_output(
1665-
self,
1666-
justice_tx,
1667-
input,
1668-
amount,
1669-
per_commitment_key,
1670-
secp_ctx,
1671-
)?;
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);
16721681
let ecdsa_sig = EcdsaSignature::sighash_all(sig);
16731682
Ok(Witness::from(
16741683
&[ecdsa_sig.serialize().as_ref(), &[1][..], witness_script.as_bytes()][..],
@@ -1887,50 +1896,6 @@ impl EcdsaChannelSigner for InMemorySigner {
18871896
Ok((commitment_sig, htlc_sigs))
18881897
}
18891898

1890-
fn sign_justice_revoked_output(
1891-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
1892-
secp_ctx: &Secp256k1<secp256k1::All>,
1893-
) -> Result<Signature, ()> {
1894-
let revocation_key = chan_utils::derive_private_revocation_key(
1895-
&secp_ctx,
1896-
&per_commitment_key,
1897-
&self.revocation_base_key,
1898-
);
1899-
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
1900-
let revocation_pubkey = RevocationKey::from_basepoint(
1901-
&secp_ctx,
1902-
&self.pubkeys().revocation_basepoint,
1903-
&per_commitment_point,
1904-
);
1905-
let witness_script = {
1906-
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1907-
let holder_selected_contest_delay =
1908-
self.holder_selected_contest_delay().expect(MISSING_PARAMS_ERR);
1909-
let counterparty_delayedpubkey = DelayedPaymentKey::from_basepoint(
1910-
&secp_ctx,
1911-
&counterparty_keys.delayed_payment_basepoint,
1912-
&per_commitment_point,
1913-
);
1914-
chan_utils::get_revokeable_redeemscript(
1915-
&revocation_pubkey,
1916-
holder_selected_contest_delay,
1917-
&counterparty_delayedpubkey,
1918-
)
1919-
};
1920-
let mut sighash_parts = sighash::SighashCache::new(justice_tx);
1921-
let sighash = hash_to_message!(
1922-
&sighash_parts
1923-
.p2wsh_signature_hash(
1924-
input,
1925-
&witness_script,
1926-
Amount::from_sat(amount),
1927-
EcdsaSighashType::All
1928-
)
1929-
.unwrap()[..]
1930-
);
1931-
return Ok(sign_with_aux_rand(secp_ctx, &sighash, &revocation_key, &self));
1932-
}
1933-
19341899
fn sign_justice_revoked_htlc(
19351900
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
19361901
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_output(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()> {
355-
#[cfg(test)]
356-
if !self.is_signer_available(SignerOp::SignJusticeRevokedOutput) {
357-
return Err(());
358-
}
359-
Ok(EcdsaChannelSigner::sign_justice_revoked_output(&self.inner, justice_tx, input, amount, per_commitment_key, secp_ctx).unwrap())
360-
}
361-
362354
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, ()> {
363355
#[cfg(test)]
364356
if !self.is_signer_available(SignerOp::SignJusticeRevokedHtlc) {

0 commit comments

Comments
 (0)