Skip to content

Commit c9050a5

Browse files
committed
Delete EcdsaChannelSigner::sign_holder_anchor_input
1 parent fc2a45e commit c9050a5

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
@@ -1033,7 +1033,16 @@ pub trait ChannelSigner {
10331033
}
10341034
}
10351035

1036-
/// Spend the holder anchor output
1036+
/// Computes the signature for a commitment transaction's anchor output used as an
1037+
/// input within `anchor_tx`, which spends the commitment transaction, at index `input`.
1038+
///
1039+
/// An `Err` can be returned to signal that the signer is unavailable/cannot produce a valid
1040+
/// signature and should be retried later. Once the signer is ready to provide a signature after
1041+
/// previously returning an `Err`, [`ChannelMonitor::signer_unblocked`] must be called on its
1042+
/// monitor or [`ChainMonitor::signer_unblocked`] called to attempt unblocking all monitors.
1043+
///
1044+
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
1045+
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
10371046
fn spend_holder_anchor_output(
10381047
&self, anchor_tx: &Transaction, input_idx: usize, secp_ctx: &Secp256k1<secp256k1::All>,
10391048
) -> Result<Witness, ()>;
@@ -1829,10 +1838,19 @@ impl ChannelSigner for InMemorySigner {
18291838
fn spend_holder_anchor_output(
18301839
&self, anchor_tx: &Transaction, input_idx: usize, secp_ctx: &Secp256k1<secp256k1::All>,
18311840
) -> Result<Witness, ()> {
1832-
let anchor_sig =
1833-
EcdsaChannelSigner::sign_holder_anchor_input(self, anchor_tx, input_idx, secp_ctx)?;
1834-
let funding_pubkey = self.pubkeys().funding_pubkey;
1835-
Ok(chan_utils::build_anchor_input_witness(&funding_pubkey, &anchor_sig))
1841+
let funding_pubkey = &self.pubkeys().funding_pubkey;
1842+
let witness_script = chan_utils::get_anchor_redeemscript(funding_pubkey);
1843+
let sighash = sighash::SighashCache::new(anchor_tx)
1844+
.p2wsh_signature_hash(
1845+
input_idx,
1846+
&witness_script,
1847+
Amount::from_sat(ANCHOR_OUTPUT_VALUE_SATOSHI),
1848+
EcdsaSighashType::All,
1849+
)
1850+
.unwrap();
1851+
let sig =
1852+
sign_with_aux_rand(secp_ctx, &hash_to_message!(&sighash[..]), &self.funding_key, &self);
1853+
Ok(chan_utils::build_anchor_input_witness(funding_pubkey, &sig))
18361854
}
18371855
}
18381856

@@ -1922,22 +1940,6 @@ impl EcdsaChannelSigner for InMemorySigner {
19221940
))
19231941
}
19241942

1925-
fn sign_holder_anchor_input(
1926-
&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
1927-
) -> Result<Signature, ()> {
1928-
let witness_script =
1929-
chan_utils::get_anchor_redeemscript(&self.holder_channel_pubkeys.funding_pubkey);
1930-
let sighash = sighash::SighashCache::new(&*anchor_tx)
1931-
.p2wsh_signature_hash(
1932-
input,
1933-
&witness_script,
1934-
Amount::from_sat(ANCHOR_OUTPUT_VALUE_SATOSHI),
1935-
EcdsaSighashType::All,
1936-
)
1937-
.unwrap();
1938-
Ok(sign_with_aux_rand(secp_ctx, &hash_to_message!(&sighash[..]), &self.funding_key, &self))
1939-
}
1940-
19411943
fn sign_channel_announcement_with_funding_key(
19421944
&self, msg: &UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<secp256k1::All>,
19431945
) -> 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::{self, HTLCOutputInCommitment, ChannelPublicKeys, HolderCommitmentTransaction, CommitmentTransaction, ChannelTransactionParameters, TrustedCommitmentTransaction, ClosingTransaction, TxCreationKeys};
1211
use crate::ln::channel_keys::{HtlcKey};
1312
use crate::ln::msgs;
@@ -368,20 +367,6 @@ impl EcdsaChannelSigner for TestChannelSigner {
368367
Ok(self.inner.sign_closing_transaction(closing_tx, secp_ctx).unwrap())
369368
}
370369

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

0 commit comments

Comments
 (0)