Skip to content

feat: Add single funded DLC support to messaging#224

Merged
matthewjablack merged 1 commit into
masterfrom
feat/single-funded-dlc-support
Jul 16, 2025
Merged

feat: Add single funded DLC support to messaging#224
matthewjablack merged 1 commit into
masterfrom
feat/single-funded-dlc-support

Conversation

@matthewjablack
Copy link
Copy Markdown
Contributor

@matthewjablack matthewjablack commented Jul 14, 2025

What

This PR adds comprehensive support for single funded DLCs to the messaging layer, allowing for DLC contracts where only one party provides collateral.

Changes Made

Core Changes

  • DlcOffer: Added singleFunded flag and related methods (markAsSingleFunded(), isSingleFunded())
  • DlcAccept: Added singleFunded flag and related methods for acceptor side
  • Auto-detection: Implemented logic to automatically detect single funded DLCs during deserialization
  • Validation: Updated validation rules to handle single funded DLC scenarios appropriately

Single Funded DLC Characteristics

  • DlcOffer: totalCollateral equals offerCollateral (offerer funds the entire contract)
  • DlcAccept: acceptCollateral is typically 0 or minimal (acceptor provides little/no collateral)
  • Funding validation: Different rules apply for funding amount validation

Test Coverage

  • Added comprehensive test suites for both DlcOffer and DlcAccept single funded functionality
  • Tests cover validation, auto-detection, serialization/deserialization, and error cases
  • All existing tests continue to pass

Backward Compatibility

  • Changes are fully backward compatible
  • Existing DLC messages continue to work unchanged
  • New functionality is opt-in via explicit marking or auto-detection

Usage Example

// Creating a single funded DLC offer
const offer = new DlcOffer();
offer.contractInfo.totalCollateral = BigInt(1e8);
offer.offerCollateral = BigInt(1e8);
offer.markAsSingleFunded();

// Auto-detection works too
const isUserFunded = offer.isSingleFunded(); // true

// Acceptor side for single funded DLC
const accept = new DlcAccept();
accept.acceptCollateral = BigInt(0);
accept.markAsSingleFunded();

This implementation enables more flexible DLC contract arrangements where one party can fund the entire contract

@matthewjablack matthewjablack force-pushed the feat/single-funded-dlc-support branch from 0238737 to 8c6156f Compare July 14, 2025 22:59
- add singleFunded flag and methods to DlcOffer and DlcAccept
- implement auto-detection logic for single funded DLCs
- update validation rules for single funded DLC scenarios
- add comprehensive test coverage for new functionality

In single funded DLCs:
- DlcOffer: totalCollateral equals offerCollateral
- DlcAccept: acceptCollateral is typically 0 or minimal
@matthewjablack matthewjablack force-pushed the feat/single-funded-dlc-support branch from 8c6156f to abe0728 Compare July 15, 2025 00:13
@matthewjablack matthewjablack merged commit 3ca3f80 into master Jul 16, 2025
2 checks passed
@matthewjablack matthewjablack deleted the feat/single-funded-dlc-support branch July 16, 2025 02:57
matthewjablack added a commit that referenced this pull request Jul 16, 2025
- feat: add single funded DLC support to messaging (#224)
- fix: handle number inputs in computeRoundingModulus (#225)
- chore: upgrade ESLint tooling & improve code quality (#226)
- update: bump all package versions to 1.0.1
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