Skip to content

Commit e0a8eee

Browse files
committed
Remove custom derive_channel_signer methods
The custom derive_channel_signer methods on AnchorDescriptor and HTLCDescriptor simply delegate to the passed SignerProvider now that providing ChannelTransactionParameters is no longer needed. Drop these methods and replace them with the method bodies at the call sites.
1 parent 9cde57e commit e0a8eee

File tree

3 files changed

+8
-24
lines changed

3 files changed

+8
-24
lines changed

lightning/src/events/bump_transaction.rs

+6-13
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,6 @@ impl AnchorDescriptor {
9191
let channel_params = self.channel_derivation_parameters.transaction_parameters.as_holder_broadcastable();
9292
chan_utils::build_anchor_input_witness(&channel_params.broadcaster_pubkeys().funding_pubkey, signature)
9393
}
94-
95-
/// Derives the channel signer required to sign the anchor input.
96-
pub fn derive_channel_signer<S: EcdsaChannelSigner, SP: Deref>(&self, signer_provider: &SP) -> S
97-
where
98-
SP::Target: SignerProvider<EcdsaSigner= S>
99-
{
100-
signer_provider.derive_channel_signer(self.channel_derivation_parameters.keys_id)
101-
}
10294
}
10395

10496
/// Represents the different types of transactions, originating from LDK, to be bumped.
@@ -118,7 +110,7 @@ pub enum BumpTransactionEvent {
118110
///
119111
/// The consumer should be able to sign for any of the additional inputs included within the
120112
/// child anchor transaction. To sign its anchor input, an [`EcdsaChannelSigner`] should be
121-
/// re-derived through [`AnchorDescriptor::derive_channel_signer`]. The anchor input signature
113+
/// re-derived through [`SignerProvider::derive_channel_signer`]. The anchor input signature
122114
/// can be computed with [`EcdsaChannelSigner::sign_holder_anchor_input`], which can then be
123115
/// provided to [`build_anchor_input_witness`] along with the `funding_pubkey` to obtain the
124116
/// full witness required to spend.
@@ -183,7 +175,7 @@ pub enum BumpTransactionEvent {
183175
///
184176
/// The consumer should be able to sign for any of the non-HTLC inputs added to the resulting
185177
/// HTLC transaction. To sign HTLC inputs, an [`EcdsaChannelSigner`] should be re-derived
186-
/// through [`HTLCDescriptor::derive_channel_signer`]. Each HTLC input's signature can be
178+
/// through [`SignerProvider::derive_channel_signer`]. Each HTLC input's signature can be
187179
/// computed with [`EcdsaChannelSigner::sign_holder_htlc_transaction`], which can then be
188180
/// provided to [`HTLCDescriptor::tx_input_witness`] to obtain the fully signed witness required
189181
/// to spend.
@@ -684,7 +676,7 @@ where
684676
log_debug!(self.logger, "Signing anchor transaction {}", anchor_txid);
685677
anchor_tx = self.utxo_source.sign_psbt(anchor_psbt)?;
686678

687-
let signer = anchor_descriptor.derive_channel_signer(&self.signer_provider);
679+
let signer = self.signer_provider.derive_channel_signer(anchor_descriptor.channel_derivation_parameters.keys_id);
688680
let channel_parameters = &anchor_descriptor.channel_derivation_parameters.transaction_parameters;
689681
let anchor_sig = signer.sign_holder_anchor_input(channel_parameters, &anchor_tx, 0, &self.secp)?;
690682
anchor_tx.input[0].witness = anchor_descriptor.tx_input_witness(&anchor_sig);
@@ -787,8 +779,9 @@ where
787779

788780
let mut signers = BTreeMap::new();
789781
for (idx, htlc_descriptor) in htlc_descriptors.iter().enumerate() {
790-
let signer = signers.entry(htlc_descriptor.channel_derivation_parameters.keys_id)
791-
.or_insert_with(|| htlc_descriptor.derive_channel_signer(&self.signer_provider));
782+
let keys_id = htlc_descriptor.channel_derivation_parameters.keys_id;
783+
let signer = signers.entry(keys_id)
784+
.or_insert_with(|| self.signer_provider.derive_channel_signer(keys_id));
792785
let htlc_sig = signer.sign_holder_htlc_transaction(&htlc_tx, idx, htlc_descriptor, &self.secp)?;
793786
let witness_script = htlc_descriptor.witness_script(&self.secp);
794787
htlc_tx.input[idx].witness = htlc_descriptor.tx_input_witness(&htlc_sig, &witness_script);

lightning/src/ln/monitor_tests.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
//! Further functional tests which test blockchain reorganizations.
1111
12-
use crate::sign::{ecdsa::EcdsaChannelSigner, OutputSpender, SpendableOutputDescriptor};
12+
use crate::sign::{ecdsa::EcdsaChannelSigner, OutputSpender, SignerProvider, SpendableOutputDescriptor};
1313
use crate::chain::channelmonitor::{ANTI_REORG_DELAY, ARCHIVAL_DELAY_BLOCKS,LATENCY_GRACE_PERIOD_BLOCKS, COUNTERPARTY_CLAIMABLE_WITHIN_BLOCKS_PINNABLE, Balance, BalanceSource, ChannelMonitorUpdateStep};
1414
use crate::chain::transaction::OutPoint;
1515
use crate::chain::chaininterface::{ConfirmationTarget, LowerBoundedFeeEstimator, compute_feerate_sat_per_1000_weight};
@@ -2921,7 +2921,7 @@ fn test_anchors_aggregated_revoked_htlc_tx() {
29212921
}
29222922
for (idx, htlc_descriptor) in descriptors.into_iter().enumerate() {
29232923
let htlc_input_idx = idx + 1;
2924-
let signer = htlc_descriptor.derive_channel_signer(&nodes[1].keys_manager);
2924+
let signer = nodes[1].keys_manager.derive_channel_signer(htlc_descriptor.channel_derivation_parameters.keys_id);
29252925
let our_sig = signer.sign_holder_htlc_transaction(&htlc_tx, htlc_input_idx, &htlc_descriptor, &secp).unwrap();
29262926
let witness_script = htlc_descriptor.witness_script(&secp);
29272927
htlc_tx.input[htlc_input_idx].witness = htlc_descriptor.tx_input_witness(&our_sig, &witness_script);

lightning/src/sign/mod.rs

-9
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ use crate::sign::ecdsa::EcdsaChannelSigner;
6868
use crate::sign::taproot::TaprootChannelSigner;
6969
use crate::util::atomic_counter::AtomicCounter;
7070
use core::convert::TryInto;
71-
use core::ops::Deref;
7271
use core::sync::atomic::{AtomicUsize, Ordering};
7372
#[cfg(taproot)]
7473
use musig2::types::{PartialSignature, PublicNonce};
@@ -703,14 +702,6 @@ impl HTLCDescriptor {
703702
&self.channel_derivation_parameters.transaction_parameters.channel_type_features,
704703
)
705704
}
706-
707-
/// Derives the channel signer required to sign the HTLC input.
708-
pub fn derive_channel_signer<S: EcdsaChannelSigner, SP: Deref>(&self, signer_provider: &SP) -> S
709-
where
710-
SP::Target: SignerProvider<EcdsaSigner = S>,
711-
{
712-
signer_provider.derive_channel_signer(self.channel_derivation_parameters.keys_id)
713-
}
714705
}
715706

716707
/// A trait to handle Lightning channel key material without concretizing the channel type or

0 commit comments

Comments
 (0)