Skip to content

Commit

Permalink
Rename; remove redeem_script, signer can derive it
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Sep 17, 2024
1 parent 2c2f9f1 commit 8cfd5d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions lightning/src/sign/ecdsa.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Defines ECDSA-specific signer types.

use bitcoin::{Script, Transaction};
use bitcoin::transaction::Transaction;

use bitcoin::secp256k1;
use bitcoin::secp256k1::ecdsa::Signature;
Expand Down Expand Up @@ -213,8 +213,8 @@ pub trait EcdsaChannelSigner: ChannelSigner {
/// Used for splicing, when signing the previous funding transaction.
/// The previous funding transaction becomes an input to the new funding transaction,
/// and it is a multisig, which we also need to sign.
fn sign_transaction_input(
&self, tx: &Transaction, input_index: u16, input_value: u64, input_redeem_script: &Script,
fn sign_splicing_funding_input(
&self, tx: &Transaction, input_index: u16, input_value: u64,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> Result<Signature, ()>;
}
11 changes: 8 additions & 3 deletions lightning/src/sign/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1696,14 +1696,19 @@ impl EcdsaChannelSigner for InMemorySigner {
Ok(secp_ctx.sign_ecdsa(&msghash, &self.funding_key))
}

fn sign_transaction_input(
&self, tx: &Transaction, input_index: u16, input_value: u64, input_redeem_script: &Script,
fn sign_splicing_funding_input(
&self, tx: &Transaction, input_index: u16, input_value: u64,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> Result<Signature, ()> {
let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
let counterparty_funding_key =
&self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR).funding_pubkey;
let funding_redeemscript =
make_funding_redeemscript(&funding_pubkey, counterparty_funding_key);
let sighash = &sighash::SighashCache::new(tx)
.p2wsh_signature_hash(
input_index as usize,
&input_redeem_script,
&funding_redeemscript,
Amount::from_sat(input_value),
EcdsaSighashType::All,
)
Expand Down
15 changes: 5 additions & 10 deletions lightning/src/util/test_channel_signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use core::cmp;
use crate::sync::{Mutex, Arc};
#[cfg(test)] use crate::sync::MutexGuard;

use bitcoin::{Script, Transaction};
use bitcoin::transaction::Transaction;
use bitcoin::hashes::Hash;
use bitcoin::sighash;
use bitcoin::sighash::EcdsaSighashType;
Expand Down Expand Up @@ -354,16 +354,11 @@ impl EcdsaChannelSigner for TestChannelSigner {
self.inner.sign_channel_announcement_with_funding_key(msg, secp_ctx)
}

fn sign_transaction_input(
&self, tx: &Transaction, input_index: u16, input_value: u64, input_redeem_script: &Script, secp_ctx: &Secp256k1<secp256k1::All>
fn sign_splicing_funding_input(
&self, tx: &Transaction, input_index: u16, input_value: u64,
secp_ctx: &Secp256k1<secp256k1::All>,
) -> Result<Signature, ()> {
self.inner.sign_transaction_input(
tx,
input_index,
input_value,
input_redeem_script,
secp_ctx,
)
self.inner.sign_splicing_funding_input(tx, input_index, input_value, secp_ctx)
}
}

Expand Down

0 comments on commit 8cfd5d9

Please sign in to comment.