Skip to content

Commit a3420d0

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 3e9ab72 commit a3420d0

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
@@ -1537,8 +1537,9 @@ impl EcdsaChannelSigner for InMemorySigner {
15371537
}
15381538

15391539
fn sign_justice_revoked_htlc(
1540-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
1541-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
1540+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
1541+
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
1542+
secp_ctx: &Secp256k1<secp256k1::All>,
15421543
) -> Result<Signature, ()> {
15431544
let revocation_key = chan_utils::derive_private_revocation_key(
15441545
&secp_ctx,
@@ -1548,25 +1549,25 @@ impl EcdsaChannelSigner for InMemorySigner {
15481549
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
15491550
let revocation_pubkey = RevocationKey::from_basepoint(
15501551
&secp_ctx,
1551-
&self.pubkeys().revocation_basepoint,
1552+
&channel_parameters.holder_pubkeys.revocation_basepoint,
15521553
&per_commitment_point,
15531554
);
15541555
let witness_script = {
1555-
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
1556+
let counterparty_keys =
1557+
channel_parameters.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
15561558
let counterparty_htlcpubkey = HtlcKey::from_basepoint(
15571559
&secp_ctx,
15581560
&counterparty_keys.htlc_basepoint,
15591561
&per_commitment_point,
15601562
);
15611563
let holder_htlcpubkey = HtlcKey::from_basepoint(
15621564
&secp_ctx,
1563-
&self.pubkeys().htlc_basepoint,
1565+
&channel_parameters.holder_pubkeys.htlc_basepoint,
15641566
&per_commitment_point,
15651567
);
1566-
let chan_type = self.channel_type_features().expect(MISSING_PARAMS_ERR);
15671568
chan_utils::get_htlc_redeemscript_with_explicit_keys(
15681569
&htlc,
1569-
chan_type,
1570+
&channel_parameters.channel_type_features,
15701571
&counterparty_htlcpubkey,
15711572
&holder_htlcpubkey,
15721573
&revocation_pubkey,

lightning/src/util/test_channel_signer.rs

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

334334
fn sign_justice_revoked_htlc(
335-
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
336-
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
335+
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
336+
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
337+
secp_ctx: &Secp256k1<secp256k1::All>,
337338
) -> Result<Signature, ()> {
338339
#[cfg(test)]
339340
if !self.is_signer_available(SignerOp::SignJusticeRevokedHtlc) {
340341
return Err(());
341342
}
342343
Ok(EcdsaChannelSigner::sign_justice_revoked_htlc(
343344
&self.inner,
345+
channel_parameters,
344346
justice_tx,
345347
input,
346348
amount,

0 commit comments

Comments
 (0)