Skip to content

Commit 722a65c

Browse files
committed
Pass channel params to sign_justice_revoked_output
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 746ca89 commit 722a65c

File tree

5 files changed

+17
-9
lines changed

5 files changed

+17
-9
lines changed

lightning/src/chain/channelmonitor.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3511,8 +3511,11 @@ impl<Signer: EcdsaChannelSigner> ChannelMonitorImpl<Signer> {
35113511
let revokeable_redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey,
35123512
self.counterparty_commitment_params.on_counterparty_tx_csv, &delayed_key);
35133513

3514+
let channel_parameters = &self.onchain_tx_handler.channel_transaction_parameters;
35143515
let sig = self.onchain_tx_handler.signer.sign_justice_revoked_output(
3515-
&justice_tx, input_idx, value, &per_commitment_key, &self.onchain_tx_handler.secp_ctx)?;
3516+
&channel_parameters, &justice_tx, input_idx, value, &per_commitment_key,
3517+
&self.onchain_tx_handler.secp_ctx,
3518+
)?;
35163519
justice_tx.input[input_idx].witness.push_ecdsa_signature(&BitcoinSignature::sighash_all(sig));
35173520
justice_tx.input[input_idx].witness.push(&[1u8]);
35183521
justice_tx.input[input_idx].witness.push(revokeable_redeemscript.as_bytes());

lightning/src/chain/package.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,12 +602,13 @@ impl PackageSolvingData {
602602
}
603603
}
604604
fn finalize_input<Signer: EcdsaChannelSigner>(&self, bumped_tx: &mut Transaction, i: usize, onchain_handler: &mut OnchainTxHandler<Signer>) -> bool {
605+
let channel_parameters = &onchain_handler.channel_transaction_parameters;
605606
match self {
606607
PackageSolvingData::RevokedOutput(ref outp) => {
607608
let chan_keys = TxCreationKeys::derive_new(&onchain_handler.secp_ctx, &outp.per_commitment_point, &outp.counterparty_delayed_payment_base_key, &outp.counterparty_htlc_base_key, &onchain_handler.signer.pubkeys().revocation_basepoint, &onchain_handler.signer.pubkeys().htlc_basepoint);
608609
let witness_script = chan_utils::get_revokeable_redeemscript(&chan_keys.revocation_key, outp.on_counterparty_tx_csv, &chan_keys.broadcaster_delayed_payment_key);
609610
//TODO: should we panic on signer failure ?
610-
if let Ok(sig) = onchain_handler.signer.sign_justice_revoked_output(&bumped_tx, i, outp.amount.to_sat(), &outp.per_commitment_key, &onchain_handler.secp_ctx) {
611+
if let Ok(sig) = onchain_handler.signer.sign_justice_revoked_output(channel_parameters, &bumped_tx, i, outp.amount.to_sat(), &outp.per_commitment_key, &onchain_handler.secp_ctx) {
611612
let mut ser_sig = sig.serialize_der().to_vec();
612613
ser_sig.push(EcdsaSighashType::All as u8);
613614
bumped_tx.input[i].witness.push(ser_sig);

lightning/src/sign/ecdsa.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,8 @@ pub trait EcdsaChannelSigner: ChannelSigner {
112112
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
113113
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
114114
fn sign_justice_revoked_output(
115-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
115+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
116+
input: usize, amount: u64, per_commitment_key: &SecretKey,
116117
secp_ctx: &Secp256k1<secp256k1::All>,
117118
) -> Result<Signature, ()>;
118119
/// Create a signature for the given input in a transaction spending a commitment transaction

lightning/src/sign/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,8 @@ impl EcdsaChannelSigner for InMemorySigner {
15091509
}
15101510

15111511
fn sign_justice_revoked_output(
1512-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
1512+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
1513+
input: usize, amount: u64, per_commitment_key: &SecretKey,
15131514
secp_ctx: &Secp256k1<secp256k1::All>,
15141515
) -> Result<Signature, ()> {
15151516
let revocation_key = chan_utils::derive_private_revocation_key(
@@ -1520,13 +1521,13 @@ impl EcdsaChannelSigner for InMemorySigner {
15201521
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
15211522
let revocation_pubkey = RevocationKey::from_basepoint(
15221523
&secp_ctx,
1523-
&self.pubkeys().revocation_basepoint,
1524+
&channel_parameters.holder_pubkeys.revocation_basepoint,
15241525
&per_commitment_point,
15251526
);
15261527
let witness_script = {
1527-
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1528-
let holder_selected_contest_delay =
1529-
self.holder_selected_contest_delay().expect(MISSING_PARAMS_ERR);
1528+
let counterparty_keys =
1529+
channel_parameters.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1530+
let holder_selected_contest_delay = channel_parameters.holder_selected_contest_delay;
15301531
let counterparty_delayedpubkey = DelayedPaymentKey::from_basepoint(
15311532
&secp_ctx,
15321533
&counterparty_keys.delayed_payment_basepoint,

lightning/src/util/test_channel_signer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,8 @@ impl EcdsaChannelSigner for TestChannelSigner {
313313
}
314314

315315
fn sign_justice_revoked_output(
316-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
316+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
317+
input: usize, amount: u64, per_commitment_key: &SecretKey,
317318
secp_ctx: &Secp256k1<secp256k1::All>,
318319
) -> Result<Signature, ()> {
319320
#[cfg(test)]
@@ -322,6 +323,7 @@ impl EcdsaChannelSigner for TestChannelSigner {
322323
}
323324
Ok(EcdsaChannelSigner::sign_justice_revoked_output(
324325
&self.inner,
326+
channel_parameters,
325327
justice_tx,
326328
input,
327329
amount,

0 commit comments

Comments
 (0)