mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-25 07:17:40 +01:00
Remove unnecessary sign_closing_transaction arg
This commit is contained in:
parent
d14ece4ac0
commit
db398438ab
3 changed files with 11 additions and 8 deletions
|
@ -148,7 +148,7 @@ pub trait ChannelKeys : Send {
|
|||
///
|
||||
/// Note that, due to rounding, there may be one "missing" satoshi, and either party may have
|
||||
/// chosen to forgo their output as dust.
|
||||
fn sign_closing_transaction<T: secp256k1::Signing>(&self, channel_funding_redeemscript: &Script, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
|
||||
fn sign_closing_transaction<T: secp256k1::Signing>(&self, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()>;
|
||||
|
||||
/// Signs a channel announcement message with our funding key, proving it comes from one
|
||||
/// of the channel participants.
|
||||
|
@ -223,11 +223,15 @@ impl ChannelKeys for InMemoryChannelKeys {
|
|||
Ok((commitment_sig, htlc_sigs))
|
||||
}
|
||||
|
||||
fn sign_closing_transaction<T: secp256k1::Signing>(&self, channel_funding_redeemscript: &Script, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
|
||||
fn sign_closing_transaction<T: secp256k1::Signing>(&self, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
|
||||
if closing_tx.input.len() != 1 { return Err(()); }
|
||||
if closing_tx.input[0].witness.len() != 0 { return Err(()); }
|
||||
if closing_tx.output.len() > 2 { return Err(()); }
|
||||
|
||||
let remote_channel_pubkeys = self.remote_channel_pubkeys.as_ref().expect("must set remote channel pubkeys before signing");
|
||||
let funding_pubkey = PublicKey::from_secret_key(secp_ctx, &self.funding_key);
|
||||
let channel_funding_redeemscript = make_funding_redeemscript(&funding_pubkey, &remote_channel_pubkeys.funding_pubkey);
|
||||
|
||||
let sighash = hash_to_message!(&bip143::SighashComponents::new(closing_tx)
|
||||
.sighash_all(&closing_tx.input[0], &channel_funding_redeemscript, self.channel_value_satoshis)[..]);
|
||||
Ok(secp_ctx.sign(&sighash, &self.funding_key))
|
||||
|
|
|
@ -2563,7 +2563,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
|
||||
let (closing_tx, total_fee_satoshis) = self.build_closing_transaction(proposed_total_fee_satoshis, false);
|
||||
let our_sig = self.local_keys
|
||||
.sign_closing_transaction(&self.get_funding_redeemscript(), &closing_tx, &self.secp_ctx)
|
||||
.sign_closing_transaction(&closing_tx, &self.secp_ctx)
|
||||
.ok();
|
||||
if our_sig.is_none() { return None; }
|
||||
|
||||
|
@ -2719,7 +2719,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
let closing_tx_max_weight = Self::get_closing_transaction_weight(&self.get_closing_scriptpubkey(), self.their_shutdown_scriptpubkey.as_ref().unwrap());
|
||||
let (closing_tx, used_total_fee) = self.build_closing_transaction($new_feerate * closing_tx_max_weight / 1000, false);
|
||||
let our_sig = self.local_keys
|
||||
.sign_closing_transaction(&funding_redeemscript, &closing_tx, &self.secp_ctx)
|
||||
.sign_closing_transaction(&closing_tx, &self.secp_ctx)
|
||||
.map_err(|_| ChannelError::Close("External signer refused to sign closing transaction"))?;
|
||||
self.last_sent_closing_fee = Some(($new_feerate, used_total_fee, our_sig.clone()));
|
||||
return Ok((Some(msgs::ClosingSigned {
|
||||
|
@ -2754,7 +2754,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
|
|||
}
|
||||
|
||||
let our_sig = self.local_keys
|
||||
.sign_closing_transaction(&funding_redeemscript, &closing_tx, &self.secp_ctx)
|
||||
.sign_closing_transaction(&closing_tx, &self.secp_ctx)
|
||||
.map_err(|_| ChannelError::Close("External signer refused to sign closing transaction"))?;
|
||||
self.build_signed_closing_transaction(&mut closing_tx, &msg.signature, &our_sig);
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ use std::cmp;
|
|||
use std::sync::Mutex;
|
||||
|
||||
use bitcoin::blockdata::transaction::Transaction;
|
||||
use bitcoin::blockdata::script::Script;
|
||||
|
||||
use secp256k1;
|
||||
use secp256k1::key::{SecretKey, PublicKey};
|
||||
|
@ -74,8 +73,8 @@ impl ChannelKeys for EnforcingChannelKeys {
|
|||
Ok(self.inner.sign_remote_commitment(feerate_per_kw, commitment_tx, keys, htlcs, to_self_delay, secp_ctx).unwrap())
|
||||
}
|
||||
|
||||
fn sign_closing_transaction<T: secp256k1::Signing>(&self, channel_funding_redeemscript: &Script, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
|
||||
Ok(self.inner.sign_closing_transaction(channel_funding_redeemscript, closing_tx, secp_ctx).unwrap())
|
||||
fn sign_closing_transaction<T: secp256k1::Signing>(&self, closing_tx: &Transaction, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
|
||||
Ok(self.inner.sign_closing_transaction(closing_tx, secp_ctx).unwrap())
|
||||
}
|
||||
|
||||
fn sign_channel_announcement<T: secp256k1::Signing>(&self, msg: &msgs::UnsignedChannelAnnouncement, secp_ctx: &Secp256k1<T>) -> Result<Signature, ()> {
|
||||
|
|
Loading…
Add table
Reference in a new issue