Skip to content

feat: implement single-funded DLC transactions#16

Merged
matthewjablack merged 2 commits into
developfrom
feat/single-funded-dlcs
Jul 8, 2025
Merged

feat: implement single-funded DLC transactions#16
matthewjablack merged 2 commits into
developfrom
feat/single-funded-dlcs

Conversation

@matthewjablack

Copy link
Copy Markdown

Summary

Implements full support for single-funded DLC transactions where one party provides all inputs while the other party contributes zero inputs but still participates in the contract.

Changes Made

Single-Funded DLC Support

  • Added dust output filtering in CreateFundTransaction and CreateBatchFundTransaction
  • Fixed fee computation for single-funded DLCs where funding party pays all fees
  • Updated change calculation to properly handle zero-input parties
  • Corrected serial ID handling to only include non-dust outputs in vout calculations

Fee Distribution Logic

  • Funding party pays all fees including the non-funding party's CET fees
  • Zero-input party returns zero fees in GetChangeOutputAndFees functions
  • Proper change recalculation accounting for both parties' collateral and all fees

Transaction Structure Improvements

  • Dust filtering removes zero-value change outputs from funding transactions
  • Supports no-change transactions for enhanced privacy
  • Maintains correct output ordering with serial ID sorting

Comprehensive Testing

  • CreateSingleFundedDlcTransactions - Basic single-funded DLC test
  • CreateBatchSingleFundedDlcTransactions - Batch single-funded DLC test
  • CreateSingleFundedDlcTransactionsNoChange - No-change single-funded DLC test
  • Fixed existing test bug in CreateCetTransactionNotEnoughInputTest

Benefits

  • Enables asymmetric DLC funding for real-world use cases
  • Reduces on-chain footprint by filtering dust outputs
  • Supports privacy-focused transactions with no change outputs
  • Maintains backward compatibility with existing dual-funded DLCs

Use Cases

  • Asymmetric funding scenarios where one party provides all capital
  • Privacy-enhanced DLCs with minimal on-chain footprint
  • Simplified DLC workflows for certain business models

All tests pass and the implementation maintains full compatibility with existing DLC functionality.

- add support for single-funded DLCs where one party has zero inputs
- filter out dust change outputs from funding transactions
- fix fee computation for single-funded DLCs with proper distribution
- add comprehensive tests for single and batch single-funded DLCs
- support no-change single-funded DLCs for privacy benefits
- clarify fee distribution between funding/non-funding parties
- document zero input handling in fee calculation fns
@matthewjablack matthewjablack force-pushed the feat/single-funded-dlcs branch from aec3e7b to abae687 Compare July 8, 2025 02:52
@matthewjablack matthewjablack merged commit 6c18665 into develop Jul 8, 2025
8 checks passed
@matthewjablack matthewjablack deleted the feat/single-funded-dlcs branch July 8, 2025 03:05
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.

1 participant