Skip to content

fix(core): charge sole funder full base weights in single-funded DLCs - #241

Open
matthewjablack wants to merge 2 commits into
masterfrom
matt/eng-1807-single-funder-fees
Open

matthewjablack wants to merge 2 commits into
masterfrom
matt/eng-1807-single-funder-fees

Conversation

@matthewjablack

Copy link
Copy Markdown
Contributor

Summary

DualFundingTxFinalizer always split the fund tx and CET base weights in half per party, so in a single-funded DLC (counterparty has no inputs) nobody paid the other half. This matches ddk-dlc, which bills the sole funder the full base weights, and fixes coin selection undershooting the funds ddk requires (a 5000 sat contract at 10 sat/vB was accepting 7950 sats of inputs when 8000 were needed).

Changes

  • TxFinalizer.ts: when the counterparty has zero inputs, the funding party pays the full fund tx base weight and the full 500-weight CET base instead of half. Dual-funded fees are unchanged (107 / 249 per party).
  • CoinSelect.ts: dualFees and dualFundingCoinSelect take an optional trailing singleFunded flag (default false) that drops the synthetic accept input so the threshold is sized correctly.
  • Tests pin the single-funder numbers (1530 fund + 1470 CET = 3000 at 10 sat/vB with one P2WPKH input), the symmetric accepter case, unchanged dual-funded fees, and the 7950 + 3000 coin selection case.
  • BatchDlcTxBuilder.calculateMaxCollateral already passes empty accept inputs, so it picks up the fix with no changes.

Note: upstream rust-dlc always splits the base weight in half. ddk-dlc is the one that deviates, but it is the counterparty in practice and the transaction underpays otherwise.

Match ddk-dlc: when the counterparty has no inputs, the funding party
pays the full fund tx and CET base weights instead of half
Add singleFunded option to dualFees and dualFundingCoinSelect
Only an explicit empty array marks the counterparty as non-funding;
bitcoin-abstraction-layer passes null at offer time and must keep the
half split instead of throwing
Delegate dualFees to getFinalizerByCount and pin exact single-funded
fee, threshold and funding tx values in tests
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