Skip to content

[Splicing] Signing utility for splicing #3312

Closed
@optout21

Description

@optout21

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions