Skip to content

Commit 8cfd5d9

Browse files
committed
Rename; remove redeem_script, signer can derive it
1 parent 2c2f9f1 commit 8cfd5d9

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

lightning/src/sign/ecdsa.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Defines ECDSA-specific signer types.
22
3-
use bitcoin::{Script, Transaction};
3+
use bitcoin::transaction::Transaction;
44

55
use bitcoin::secp256k1;
66
use bitcoin::secp256k1::ecdsa::Signature;
@@ -213,8 +213,8 @@ pub trait EcdsaChannelSigner: ChannelSigner {
213213
/// Used for splicing, when signing the previous funding transaction.
214214
/// The previous funding transaction becomes an input to the new funding transaction,
215215
/// and it is a multisig, which we also need to sign.
216-
fn sign_transaction_input(
217-
&self, tx: &Transaction, input_index: u16, input_value: u64, input_redeem_script: &Script,
216+
fn sign_splicing_funding_input(
217+
&self, tx: &Transaction, input_index: u16, input_value: u64,
218218
secp_ctx: &Secp256k1<secp256k1::All>,
219219
) -> Result<Signature, ()>;
220220
}

lightning/src/sign/mod.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1696,14 +1696,19 @@ impl EcdsaChannelSigner for InMemorySigner {
16961696
Ok(secp_ctx.sign_ecdsa(&msghash, &self.funding_key))
16971697
}
16981698

1699-
fn sign_transaction_input(
1700-
&self, tx: &Transaction, input_index: u16, input_value: u64, input_redeem_script: &Script,
1699+
fn sign_splicing_funding_input(
1700+
&self, tx: &Transaction, input_index: u16, input_value: u64,
17011701
secp_ctx: &Secp256k1<secp256k1::All>,
17021702
) -> Result<Signature, ()> {
1703+
let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
1704+
let counterparty_funding_key =
1705+
&self.counterparty_pubkeys().expect(MISSING_PARAMS_ERR).funding_pubkey;
1706+
let funding_redeemscript =
1707+
make_funding_redeemscript(&funding_pubkey, counterparty_funding_key);
17031708
let sighash = &sighash::SighashCache::new(tx)
17041709
.p2wsh_signature_hash(
17051710
input_index as usize,
1706-
&input_redeem_script,
1711+
&funding_redeemscript,
17071712
Amount::from_sat(input_value),
17081713
EcdsaSighashType::All,
17091714
)

lightning/src/util/test_channel_signer.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use core::cmp;
2222
use crate::sync::{Mutex, Arc};
2323
#[cfg(test)] use crate::sync::MutexGuard;
2424

25-
use bitcoin::{Script, Transaction};
25+
use bitcoin::transaction::Transaction;
2626
use bitcoin::hashes::Hash;
2727
use bitcoin::sighash;
2828
use bitcoin::sighash::EcdsaSighashType;
@@ -354,16 +354,11 @@ impl EcdsaChannelSigner for TestChannelSigner {
354354
self.inner.sign_channel_announcement_with_funding_key(msg, secp_ctx)
355355
}
356356

357-
fn sign_transaction_input(
358-
&self, tx: &Transaction, input_index: u16, input_value: u64, input_redeem_script: &Script, secp_ctx: &Secp256k1<secp256k1::All>
357+
fn sign_splicing_funding_input(
358+
&self, tx: &Transaction, input_index: u16, input_value: u64,
359+
secp_ctx: &Secp256k1<secp256k1::All>,
359360
) -> Result<Signature, ()> {
360-
self.inner.sign_transaction_input(
361-
tx,
362-
input_index,
363-
input_value,
364-
input_redeem_script,
365-
secp_ctx,
366-
)
361+
self.inner.sign_splicing_funding_input(tx, input_index, input_value, secp_ctx)
367362
}
368363
}
369364

0 commit comments

Comments
 (0)