Skip to content

Commit 1547436

Browse files
committed
Delete EcdsaChannelSigner::sign_holder_anchor_input
1 parent 931d62d commit 1547436

File tree

4 files changed

+28
-57
lines changed

4 files changed

+28
-57
lines changed

lightning/src/events/bump_transaction.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,9 @@ pub enum BumpTransactionEvent {
119119
/// broadcast first, as the child anchor transaction depends on it.
120120
///
121121
/// The consumer should be able to sign for any of the additional inputs included within the
122-
/// child anchor transaction. To sign its anchor input, an [`EcdsaChannelSigner`] should be
123-
/// re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input signature
124-
/// can be computed with [`EcdsaChannelSigner::sign_holder_anchor_input`], which can then be
125-
/// provided to [`build_anchor_input_witness`] along with the `funding_pubkey` to obtain the
126-
/// full witness required to spend.
122+
/// child anchor transaction. To sign its anchor input, a [`ChannelSigner`] should be
123+
/// re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input witness
124+
/// can be computed with [`ChannelSigner::spend_holder_anchor_output`].
127125
///
128126
/// It is possible to receive more than one instance of this event if a valid child anchor
129127
/// transaction is never broadcast or is but not with a sufficient fee to be mined. Care should
@@ -142,9 +140,8 @@ pub enum BumpTransactionEvent {
142140
/// an empty `pending_htlcs`), confirmation of the commitment transaction can be considered to
143141
/// be not urgent.
144142
///
145-
/// [`EcdsaChannelSigner`]: crate::sign::ecdsa::EcdsaChannelSigner
146-
/// [`EcdsaChannelSigner::sign_holder_anchor_input`]: crate::sign::ecdsa::EcdsaChannelSigner::sign_holder_anchor_input
147-
/// [`build_anchor_input_witness`]: crate::ln::chan_utils::build_anchor_input_witness
143+
/// [`ChannelSigner`]: crate::sign::ChannelSigner
144+
/// [`ChannelSigner::spend_holder_anchor_output`]: crate::sign::ChannelSigner::spend_holder_anchor_output
148145
ChannelClose {
149146
/// The `channel_id` of the channel which has been closed.
150147
channel_id: ChannelId,

lightning/src/sign/ecdsa.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,6 @@ pub trait EcdsaChannelSigner: ChannelSigner {
6767
fn sign_closing_transaction(
6868
&self, closing_tx: &ClosingTransaction, secp_ctx: &Secp256k1<secp256k1::All>,
6969
) -> Result<Signature, ()>;
70-
/// Computes the signature for a commitment transaction's anchor output used as an
71-
/// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
72-
///
73-
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
74-
/// signature and should be retried later. Once the signer is ready to provide a signature after
75-
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
76-
/// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors.
77-
///
78-
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
79-
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
80-
fn sign_holder_anchor_input(
81-
&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
82-
) -> Result<Signature, ()>;
8370
/// Signs a channel announcement message with our funding key proving it comes from one of the
8471
/// channel participants.
8572
///

lightning/src/sign/mod.rs

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,7 +1070,16 @@ pub trait ChannelSigner {
10701070
}
10711071
}
10721072

1073-
/// Spend the holder anchor output
1073+
/// Computes the signature for a commitment transaction's anchor output used as an
1074+
/// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
1075+
///
1076+
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
1077+
/// signature and should be retried later. Once the signer is ready to provide a signature after
1078+
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
1079+
/// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors.
1080+
///
1081+
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
1082+
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
10741083
fn spend_holder_anchor_output(
10751084
&self, anchor_tx: &Transaction, input_idx: usize, secp_ctx: &Secp256k1<secp256k1::All>,
10761085
) -> Result<Witness, ()>;
@@ -1855,10 +1864,19 @@ impl ChannelSigner for InMemorySigner {
18551864
fn spend_holder_anchor_output(
18561865
&self, anchor_tx: &Transaction, input_idx: usize, secp_ctx: &Secp256k1<secp256k1::All>,
18571866
) -> Result<Witness, ()> {
1858-
let anchor_sig =
1859-
EcdsaChannelSigner::sign_holder_anchor_input(self, anchor_tx, input_idx, secp_ctx)?;
1860-
let funding_pubkey = self.pubkeys().funding_pubkey;
1861-
Ok(chan_utils::build_anchor_input_witness(&funding_pubkey, &anchor_sig))
1867+
let funding_pubkey = &self.pubkeys().funding_pubkey;
1868+
let witness_script = chan_utils::get_anchor_redeemscript(funding_pubkey);
1869+
let sighash = sighash::SighashCache::new(anchor_tx)
1870+
.p2wsh_signature_hash(
1871+
input_idx,
1872+
&witness_script,
1873+
Amount::from_sat(ANCHOR_OUTPUT_VALUE_SATOSHI),
1874+
EcdsaSighashType::All,
1875+
)
1876+
.unwrap();
1877+
let sig =
1878+
sign_with_aux_rand(secp_ctx, &hash_to_message!(&sighash[..]), &self.funding_key, &self);
1879+
Ok(chan_utils::build_anchor_input_witness(funding_pubkey, &sig))
18621880
}
18631881
}
18641882

@@ -1948,22 +1966,6 @@ impl EcdsaChannelSigner for InMemorySigner {
19481966
))
19491967
}
19501968

1951-
fn sign_holder_anchor_input(
1952-
&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
1953-
) -> Result<Signature, ()> {
1954-
let witness_script =
1955-
chan_utils::get_anchor_redeemscript(&self.holder_channel_pubkeys.funding_pubkey);
1956-
let sighash = sighash::SighashCache::new(&*anchor_tx)
1957-
.p2wsh_signature_hash(
1958-
input,
1959-
&witness_script,
1960-
Amount::from_sat(ANCHOR_OUTPUT_VALUE_SATOSHI),
1961-
EcdsaSighashType::All,
1962-
)
1963-
.unwrap();
1964-
Ok(sign_with_aux_rand(secp_ctx, &hash_to_message!(&sighash[..]), &self.funding_key, &self))
1965-
}
1966-
19671969
fn sign_channel_announcement_with_funding_key(
19681970
&self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
19691971
) -> Result<Signature, ()> {

lightning/src/util/test_channel_signer.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// You may not use this file except in accordance with one or both of these
88
// licenses.
99

10-
use crate::ln::channel::{ANCHOR_OUTPUT_VALUE_SATOSHI, MIN_CHAN_DUST_LIMIT_SATOSHIS};
1110
use crate::ln::chan_utils::{HTLCOutputInCommitment, ChannelPublicKeys, HolderCommitmentTransaction, CommitmentTransaction, ChannelTransactionParameters, TrustedCommitmentTransaction, ClosingTransaction};
1211
use crate::ln::channel_keys::{HtlcKey};
1312
use crate::ln::msgs;
@@ -361,20 +360,6 @@ impl EcdsaChannelSigner for TestChannelSigner {
361360
Ok(self.inner.sign_closing_transaction(closing_tx, secp_ctx).unwrap())
362361
}
363362

364-
fn sign_holder_anchor_input(
365-
&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
366-
) -> Result<Signature, ()> {
367-
debug_assert!(MIN_CHAN_DUST_LIMIT_SATOSHIS > ANCHOR_OUTPUT_VALUE_SATOSHI);
368-
// As long as our minimum dust limit is enforced and is greater than our anchor output
369-
// value, an anchor output can only have an index within [0, 1].
370-
assert!(anchor_tx.input[input].previous_output.vout == 0 || anchor_tx.input[input].previous_output.vout == 1);
371-
#[cfg(test)]
372-
if !self.is_signer_available(SignerOp::SignHolderAnchorInput) {
373-
return Err(());
374-
}
375-
EcdsaChannelSigner::sign_holder_anchor_input(&self.inner, anchor_tx, input, secp_ctx)
376-
}
377-
378363
fn sign_channel_announcement_with_funding_key(
379364
&self, msg: &msgs::UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>
380365
) -> Result<Signature, ()> {

0 commit comments

Comments
 (0)