Skip to content

feat: spliced dlc#4

Open
bennyhodl wants to merge 2 commits into
single-funded-dlcfrom
spliced-contract
Open

feat: spliced dlc#4
bennyhodl wants to merge 2 commits into
single-funded-dlcfrom
spliced-contract

Conversation

@bennyhodl
Copy link
Copy Markdown
Owner

@bennyhodl bennyhodl commented Jul 13, 2025

Add DLC Splicing Support

This pull request implements DLC splicing functionality, allowing existing confirmed DLC contracts to be used as inputs for new DLC contracts. This enables users to efficiently chain DLCs together without needing to close and settle previous contracts on-chain.

How it works

The implementation extends the existing DLC messaging protocol by adding an optional DlcInput subtype to FundingInput messages. When present, this subtype contains the funding public keys from both parties and the contract ID of an existing confirmed DLC that will be consumed as input.

The splicing flow follows the standard DLC negotiation process (offer → accept → sign) with enhanced funding input handling:

  1. Offer Phase: When creating a splice offer, the system identifies confirmed DLC contracts that can serve as inputs and includes their details in the DlcInput optional fields of the funding inputs.

  2. Accept Phase: The accepting party processes splice offers the same way as regular offers, but the system recognizes DLC inputs and handles them appropriately during transaction construction.

  3. Signing Phase: During contract verification and signing, the system automatically:

    • Retrieves the original contract signer using the stored keys ID from the referenced DLC
    • Creates funding input signatures for DLC inputs using the appropriate private keys
    • Combines signatures from both parties to satisfy the 2-of-2 multisig spending conditions of the input DLC

The funding transaction construction seamlessly integrates DLC inputs alongside regular UTXOs, with proper weight and fee calculations. The spending conditions for DLC inputs are satisfied through the standard 2-of-2 multisig script, where both parties contribute their signatures to unlock the funds from the previous contract.

This implementation maintains backward compatibility with existing DLC contracts while enabling efficient contract chaining. The PR includes comprehensive test cases covering both "splice-in" scenarios (adding collateral from external sources plus existing DLCs) and "splice-out" scenarios (reducing total collateral by consuming DLC inputs).

@bennyhodl bennyhodl force-pushed the single-funded-dlc branch from e389637 to d215bc7 Compare July 14, 2025 13:52
@bennyhodl bennyhodl force-pushed the spliced-contract branch 2 times, most recently from 04a93fb to d7c796b Compare July 25, 2025 20:40
Comment thread dlc/src/dlc_input.rs Outdated
@bennyhodl bennyhodl force-pushed the spliced-contract branch 2 times, most recently from 1d4e474 to e0399a8 Compare July 25, 2025 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants