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.
This commit is contained in:
Jeffrey Czyz 2025-02-20 15:56:27 -06:00
parent 3e9ab723c3
commit a3420d0e05
No known key found for this signature in database
GPG key ID: 3A4E08275D5E96D2
4 changed files with 16 additions and 12 deletions

View file

@ -620,7 +620,7 @@ impl PackageSolvingData {
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);
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);
//TODO: should we panic on signer failure ?
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) {
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) {
let mut ser_sig = sig.serialize_der().to_vec();
ser_sig.push(EcdsaSighashType::All as u8);
bumped_tx.input[i].witness.push(ser_sig);

View file

@ -143,8 +143,9 @@ pub trait EcdsaChannelSigner: ChannelSigner {
/// [`ChannelMonitor::signer_unblocked`]: crate::chain::channelmonitor::ChannelMonitor::signer_unblocked
/// [`ChainMonitor::signer_unblocked`]: crate::chain::chainmonitor::ChainMonitor::signer_unblocked
fn sign_justice_revoked_htlc(
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> Result<Signature, ()>;
/// Computes the signature for a commitment transaction's HTLC output used as an input within
/// `htlc_tx`, which spends the commitment transaction at index `input`. The signature returned

View file

@ -1537,8 +1537,9 @@ impl EcdsaChannelSigner for InMemorySigner {
}
fn sign_justice_revoked_htlc(
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> Result<Signature, ()> {
let revocation_key = chan_utils::derive_private_revocation_key(
&secp_ctx,
@ -1548,11 +1549,12 @@ impl EcdsaChannelSigner for InMemorySigner {
let per_commitment_point = PublicKey::from_secret_key(secp_ctx, &per_commitment_key);
let revocation_pubkey = RevocationKey::from_basepoint(
&secp_ctx,
&self.pubkeys().revocation_basepoint,
&channel_parameters.holder_pubkeys.revocation_basepoint,
&per_commitment_point,
);
let witness_script = {
let counterparty_keys = self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
let counterparty_keys =
channel_parameters.counterparty_pubkeys().expect(MISSING_PARAMS_ERR);
let counterparty_htlcpubkey = HtlcKey::from_basepoint(
&secp_ctx,
&counterparty_keys.htlc_basepoint,
@ -1560,13 +1562,12 @@ impl EcdsaChannelSigner for InMemorySigner {
);
let holder_htlcpubkey = HtlcKey::from_basepoint(
&secp_ctx,
&self.pubkeys().htlc_basepoint,
&channel_parameters.holder_pubkeys.htlc_basepoint,
&per_commitment_point,
);
let chan_type = self.channel_type_features().expect(MISSING_PARAMS_ERR);
chan_utils::get_htlc_redeemscript_with_explicit_keys(
&htlc,
chan_type,
&channel_parameters.channel_type_features,
&counterparty_htlcpubkey,
&holder_htlcpubkey,
&revocation_pubkey,

View file

@ -332,8 +332,9 @@ impl EcdsaChannelSigner for TestChannelSigner {
}
fn sign_justice_revoked_htlc(
&self, justice_tx: &Transaction, input: usize, amount: u64, per_commitment_key: &SecretKey,
htlc: &HTLCOutputInCommitment, secp_ctx: &Secp256k1<secp256k1::All>,
&self, channel_parameters: &ChannelTransactionParameters, justice_tx: &Transaction,
input: usize, amount: u64, per_commitment_key: &SecretKey, htlc: &HTLCOutputInCommitment,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> Result<Signature, ()> {
#[cfg(test)]
if !self.is_signer_available(SignerOp::SignJusticeRevokedHtlc) {
@ -341,6 +342,7 @@ impl EcdsaChannelSigner for TestChannelSigner {
}
Ok(EcdsaChannelSigner::sign_justice_revoked_htlc(
&self.inner,
channel_parameters,
justice_tx,
input,
amount,