Skip to content

Commit abd7d7f

Browse files
committed
Pass channel params to sign_holder_anchor_input
Now that channel_value_satoshis has been moved to ChannelTransactionParameters, pass the entire parameters when calling each method on EcdsaChannelSigner. This will remove the need for ChannelSigner::provide_channel_parameters. Instead, the parameters from the FundingScope will be passed in to each method. This simplifies the interaction with a ChannelSigner when needing to be called for more than one FundingScope, which will be the case for pending splices and RBF attempts.
1 parent 63611a5 commit abd7d7f

File tree

4 files changed

+16
-6
lines changed

4 files changed

+16
-6
lines changed

lightning/src/events/bump_transaction.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,7 +690,8 @@ where
690690
anchor_tx = self.utxo_source.sign_psbt(anchor_psbt)?;
691691

692692
let signer = anchor_descriptor.derive_channel_signer(&self.signer_provider);
693-
let anchor_sig = signer.sign_holder_anchor_input(&anchor_tx, 0, &self.secp)?;
693+
let channel_parameters = &anchor_descriptor.channel_derivation_parameters.transaction_parameters;
694+
let anchor_sig = signer.sign_holder_anchor_input(channel_parameters, &anchor_tx, 0, &self.secp)?;
694695
anchor_tx.input[0].witness = anchor_descriptor.tx_input_witness(&anchor_sig);
695696

696697
#[cfg(debug_assertions)] {

lightning/src/sign/ecdsa.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ pub trait EcdsaChannelSigner: ChannelSigner {
223223
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
224224
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
225225
fn sign_holder_anchor_input(
226-
&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
226+
&self, channel_parameters: &ChannelTransactionParameters, anchor_tx: &Transaction,
227+
input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
227228
) -> Result<Signature, ()>;
228229
/// Signs a channel announcement message with our funding key proving it comes from one of the
229230
/// channel participants.

lightning/src/sign/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1679,10 +1679,11 @@ impl EcdsaChannelSigner for InMemorySigner {
16791679
}
16801680

16811681
fn sign_holder_anchor_input(
1682-
&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
1682+
&self, channel_parameters: &ChannelTransactionParameters, anchor_tx: &Transaction,
1683+
input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
16831684
) -> Result<Signature, ()> {
16841685
let witness_script =
1685-
chan_utils::get_anchor_redeemscript(&self.holder_channel_pubkeys.funding_pubkey);
1686+
chan_utils::get_anchor_redeemscript(&channel_parameters.holder_pubkeys.funding_pubkey);
16861687
let sighash = sighash::SighashCache::new(&*anchor_tx)
16871688
.p2wsh_signature_hash(
16881689
input,

lightning/src/util/test_channel_signer.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ impl EcdsaChannelSigner for TestChannelSigner {
450450
}
451451

452452
fn sign_holder_anchor_input(
453-
&self, anchor_tx: &Transaction, input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
453+
&self, channel_parameters: &ChannelTransactionParameters, anchor_tx: &Transaction,
454+
input: usize, secp_ctx: &Secp256k1<secp256k1::All>,
454455
) -> Result<Signature, ()> {
455456
debug_assert!(MIN_CHAN_DUST_LIMIT_SATOSHIS > ANCHOR_OUTPUT_VALUE_SATOSHI);
456457
// As long as our minimum dust limit is enforced and is greater than our anchor output
@@ -463,7 +464,13 @@ impl EcdsaChannelSigner for TestChannelSigner {
463464
if !self.is_signer_available(SignerOp::SignHolderAnchorInput) {
464465
return Err(());
465466
}
466-
EcdsaChannelSigner::sign_holder_anchor_input(&self.inner, anchor_tx, input, secp_ctx)
467+
EcdsaChannelSigner::sign_holder_anchor_input(
468+
&self.inner,
469+
channel_parameters,
470+
anchor_tx,
471+
input,
472+
secp_ctx,
473+
)
467474
}
468475

469476
fn sign_channel_announcement_with_funding_key(

0 commit comments

Comments
 (0)