Skip to content

Commit a70df34

Browse files
committed
Pass channel params to sign_justice_revoked_htlc
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 722a65c commit a70df34

File tree

4 files changed

+16
-12
lines changed

4 files changed

+16
-12
lines changed

lightning/src/chain/package.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ impl PackageSolvingData {
620620
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);
621621
let witness_script = chan_utils::get_htlc_redeemscript_with_explicit_keys(&outp.htlc, &onchain_handler.channel_type_features(), &chan_keys.broadcaster_htlc_key, &chan_keys.countersignatory_htlc_key, &chan_keys.revocation_key);
622622
//TODO: should we panic on signer failure ?
623-
if let Ok(sig) = onchain_handler.signer.sign_justice_revoked_htlc(&bumped_tx, i, outp.amount, &outp.per_commitment_key, &outp.htlc, &onchain_handler.secp_ctx) {
623+
if let Ok(sig) = onchain_handler.signer.sign_justice_revoked_htlc(channel_parameters, &bumped_tx, i, outp.amount, &outp.per_commitment_key, &outp.htlc, &onchain_handler.secp_ctx) {
624624
let mut ser_sig = sig.serialize_der().to_vec();
625625
ser_sig.push(EcdsaSighashType::All as u8);
626626
bumped_tx.input[i].witness.push(ser_sig);

lightning/src/sign/ecdsa.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
143143
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
144144
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
145145
fn sign_justice_revoked_htlc(
146-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
147-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
146+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
147+
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
148+
secp_ctx: &Secp256k1<secp256k1::All>,
148149
) -> Result<Signature, ()>;
149150
/// Computes the signature for a commitment transaction's HTLC output used as an input within
150151
/// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned

lightning/src/sign/mod.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1554,8 +1554,9 @@ impl EcdsaChannelSigner for InMemorySigner {
15541554
}
15551555

15561556
fn sign_justice_revoked_htlc(
1557-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
1558-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
1557+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
1558+
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
1559+
secp_ctx: &Secp256k1<secp256k1::All>,
15591560
) -> Result<Signature, ()> {
15601561
let revocation_key = chan_utils::derive_private_revocation_key(
15611562
&secp_ctx,
@@ -1565,25 +1566,25 @@ impl EcdsaChannelSigner for InMemorySigner {
15651566
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
15661567
let revocation_pubkey = RevocationKey::from_basepoint(
15671568
&secp_ctx,
1568-
&self.pubkeys().revocation_basepoint,
1569+
&channel_parameters.holder_pubkeys.revocation_basepoint,
15691570
&per_commitment_point,
15701571
);
15711572
let witness_script = {
1572-
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1573+
let counterparty_keys =
1574+
channel_parameters.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
15731575
let counterparty_htlcpubkey = HtlcKey::from_basepoint(
15741576
&secp_ctx,
15751577
&counterparty_keys.htlc_basepoint,
15761578
&per_commitment_point,
15771579
);
15781580
let holder_htlcpubkey = HtlcKey::from_basepoint(
15791581
&secp_ctx,
1580-
&self.pubkeys().htlc_basepoint,
1582+
&channel_parameters.holder_pubkeys.htlc_basepoint,
15811583
&per_commitment_point,
15821584
);
1583-
let chan_type = self.channel_type_features().expect(MISSING_PARAMS_ERR);
15841585
chan_utils::get_htlc_redeemscript_with_explicit_keys(
15851586
&htlc,
1586-
chan_type,
1587+
&channel_parameters.channel_type_features,
15871588
&counterparty_htlcpubkey,
15881589
&holder_htlcpubkey,
15891590
&revocation_pubkey,

lightning/src/util/test_channel_signer.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,17 @@ impl EcdsaChannelSigner for TestChannelSigner {
334334
}
335335

336336
fn sign_justice_revoked_htlc(
337-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
338-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
337+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
338+
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
339+
secp_ctx: &Secp256k1<secp256k1::All>,
339340
) -> Result<Signature, ()> {
340341
#[cfg(test)]
341342
if !self.is_signer_available(SignerOp::SignJusticeRevokedHtlc) {
342343
return Err(());
343344
}
344345
Ok(EcdsaChannelSigner::sign_justice_revoked_htlc(
345346
&self.inner,
347+
channel_parameters,
346348
justice_tx,
347349
input,
348350
amount,

0 commit comments

Comments
 (0)