Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Splicing] Signing utility for splicing #3312

Open
optout21 opened this issue Sep 12, 2024 · 0 comments · May be fixed by #3316
Open

[Splicing] Signing utility for splicing #3312

optout21 opened this issue Sep 12, 2024 · 0 comments · May be fixed by #3316

Comments

@optout21
Copy link
Contributor

This is in preparation for Splicing (#1621 )

In splicing the channel has to sign the previous funding as an input to the new funding transactions. For this, the EcdsaChannelSigner trait has to be extended.

The proposed solution is visible in #3274, the EcdsaChannelSigner trait has been extended with this method:

	/// Create a signature for a splicing funding transaction, for the input which is the previous funding tx.
	fn sign_splicing_funding_input(
		&self, splicing_tx: &Transaction, splice_prev_funding_input_index: u16, splice_prev_funding_input_value: u64, redeem_script: &Script, secp_ctx: &Secp256k1<secp256k1::All>
	) -> Result<Signature, ()>;

with the implementation:

	fn sign_splicing_funding_input(&self, splicing_tx: &Transaction, splice_prev_funding_input_index: u16, splice_prev_funding_input_value: u64, redeem_script: &Script, secp_ctx: &Secp256k1<secp256k1::All>) -> Result<Signature, ()> {
		let sighash = &sighash::SighashCache::new(splicing_tx).segwit_signature_hash(splice_prev_funding_input_index as usize, &redeem_script, splice_prev_funding_input_value, EcdsaSighashType::All).unwrap()[..];
		let msg = hash_to_message!(sighash);
		let sig = sign(secp_ctx, &msg, &self.funding_key);
		Ok(sig)
	}

(files src/sign/mod.rs src/sign/ecdsa.rs src/ln/channel.rs)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant