Skip to content

Commit fbc1b5c

Browse files
committed
Delete EcdsaChannelSigner::sign_justice_revoked_output
1 parent 03d6a40 commit fbc1b5c

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
@@ -1624,14 +1624,23 @@ impl ChannelSigner for InMemorySigner {
16241624
contest_delay,
16251625
&keys.broadcaster_delayed_payment_key,
16261626
);
1627-
let sig = EcdsaChannelSigner::sign_justice_revoked_output(
1628-
self,
1629-
justice_tx,
1630-
input,
1631-
amount,
1632-
per_commitment_key,
1633-
secp_ctx,
1634-
)?;
1627+
let revocation_key = chan_utils::derive_private_revocation_key(
1628+
&secp_ctx,
1629+
&per_commitment_key,
1630+
&self.revocation_base_key,
1631+
);
1632+
let mut sighash_parts = sighash::SighashCache::new(justice_tx);
1633+
let sighash = hash_to_message!(
1634+
&sighash_parts
1635+
.p2wsh_signature_hash(
1636+
input,
1637+
&witness_script,
1638+
Amount::from_sat(amount),
1639+
EcdsaSighashType::All
1640+
)
1641+
.unwrap()[..]
1642+
);
1643+
let sig = sign_with_aux_rand(secp_ctx, &sighash, &revocation_key, &self);
16351644
let ecdsa_sig = EcdsaSignature::sighash_all(sig);
16361645
Ok(Witness::from(
16371646
&[ecdsa_sig.serialize().as_ref(), &[1][..], witness_script.as_bytes()][..],
@@ -1861,50 +1870,6 @@ impl EcdsaChannelSigner for InMemorySigner {
18611870
Ok((commitment_sig, htlc_sigs))
18621871
}
18631872

1864-
fn sign_justice_revoked_output(
1865-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
1866-
secp_ctx: &Secp256k1<secp256k1::All>,
1867-
) -> Result<Signature, ()> {
1868-
let revocation_key = chan_utils::derive_private_revocation_key(
1869-
&secp_ctx,
1870-
&per_commitment_key,
1871-
&self.revocation_base_key,
1872-
);
1873-
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
1874-
let revocation_pubkey = RevocationKey::from_basepoint(
1875-
&secp_ctx,
1876-
&self.pubkeys().revocation_basepoint,
1877-
&per_commitment_point,
1878-
);
1879-
let witness_script = {
1880-
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1881-
let holder_selected_contest_delay =
1882-
self.holder_selected_contest_delay().expect(MISSING_PARAMS_ERR);
1883-
let counterparty_delayedpubkey = DelayedPaymentKey::from_basepoint(
1884-
&secp_ctx,
1885-
&counterparty_keys.delayed_payment_basepoint,
1886-
&per_commitment_point,
1887-
);
1888-
chan_utils::get_revokeable_redeemscript(
1889-
&revocation_pubkey,
1890-
holder_selected_contest_delay,
1891-
&counterparty_delayedpubkey,
1892-
)
1893-
};
1894-
let mut sighash_parts = sighash::SighashCache::new(justice_tx);
1895-
let sighash = hash_to_message!(
1896-
&sighash_parts
1897-
.p2wsh_signature_hash(
1898-
input,
1899-
&witness_script,
1900-
Amount::from_sat(amount),
1901-
EcdsaSighashType::All
1902-
)
1903-
.unwrap()[..]
1904-
);
1905-
return Ok(sign_with_aux_rand(secp_ctx, &sighash, &revocation_key, &self));
1906-
}
1907-
19081873
fn sign_justice_revoked_htlc(
19091874
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
19101875
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_output(&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()> {
362-
#[cfg(test)]
363-
if !self.is_signer_available(SignerOp::SignJusticeRevokedOutput) {
364-
return Err(());
365-
}
366-
Ok(EcdsaChannelSigner::sign_justice_revoked_output(&self.inner, justice_tx, input, amount, per_commitment_key, secp_ctx).unwrap())
367-
}
368-
369361
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, ()> {
370362
#[cfg(test)]
371363
if !self.is_signer_available(SignerOp::SignJusticeRevokedHtlc) {

0 commit comments

Comments
 (0)