From 2c8ed47311ec04b8d42640e8a62ea1f0b234212c Mon Sep 17 00:00:00 2001 From: Nadav Kohen Date: Tue, 17 Dec 2019 15:45:20 -0600 Subject: [PATCH 1/2] Add up-front fees to funding tx and make funding fees proportional --- Transactions.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Transactions.md b/Transactions.md index 0b03ec6..9b330e1 100644 --- a/Transactions.md +++ b/Transactions.md @@ -33,12 +33,12 @@ Where * Remote Change ScriptPubKey Where - - `P2WSH(DLC Funding Output)`'s value is `Total Local Collateral + Total Remote Collateral` + - `P2WSH(DLC Funding Output)`'s value is `Total Local Collateral + Total Remote Collateral + Computed CET Fee` - `DLC Funding Output`'s script is OP_2 OP_2 OP_CHECKMULTISIG - - Each `Change ScriptPubKey`'s value is at most that of its respective `Sum(Funding Inputs) - Total Collateral - Computed Fees` with `Computed Fees` being equal for both parties + - Each `Change ScriptPubKey`'s value is at most that of its respective `Sum(Funding Inputs) - Total Collateral - Computed Fees - (Computed CET Fee/2)` with `Computed Fees` being proportional to each party's total input weight and `Computed CET Fee` being the estimated fee for a [Contract Execution Transaction](#contract-execution-transaction) ## Contract Execution Transaction ### Known Values @@ -68,9 +68,8 @@ Where * ToRemoteOutput Where - - `P2WSH(ToLocalOutput).value = Local Payout - Local Fee` - - `ToRemoteOutput.value = Remote Payout - Remote Fee` - - `Local Fee = Remote Fee` + - `P2WSH(ToLocalOutput).value = Local Payout` + - `ToRemoteOutput.value = Remote Payout` - `ToLocalOutput`'s script is: OP_IF @@ -97,6 +96,7 @@ Where * Fee Rate: `FeeUnit` Where + - Unlike any other transaction in a DLC, there is only one Refund Transaction that both parties share - Both `Refund Public Key`s are 33-byte compressed public keys - `Total Local Collateral + Total Remote Collateral = (DLC Funding Output).value` - `DLC Funding Output` is of the form [specified above](#FundingOutputs) @@ -109,9 +109,9 @@ Where * ToRemoteOutput Where - - `ToLocalOutput`'s value is `Total Local Collateral - Local Fee` - - `ToRemoteOutput`'s value is `Total Remote Collateral - Remote Fee` - - `Local Fee / Total Local Collateral = Remote Fee / Total Remote Collateral` + - `ToLocalOutput`'s value is `Total Local Collateral + RefundFeeDelta/2` + - `ToRemoteOutput`'s value is `Total Remote Collateral + RefundFeeDelta/2` + - `RefundFeeDelta = Computed CET Fee - Computed Refund Tx Fee` (note that the Refund Transaction is smaller than any CET) - `ToLocalOutput`'s script is: OP_0 From a53b58c93c5efc2047d2521391fadb6aa69d2b11 Mon Sep 17 00:00:00 2001 From: nkohen Date: Fri, 27 Dec 2019 14:14:47 -0600 Subject: [PATCH 2/2] Responded to review --- Transactions.md | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Transactions.md b/Transactions.md index 9b330e1..8111c14 100644 --- a/Transactions.md +++ b/Transactions.md @@ -33,12 +33,12 @@ Where * Remote Change ScriptPubKey Where - - `P2WSH(DLC Funding Output)`'s value is `Total Local Collateral + Total Remote Collateral + Computed CET Fee` + - `P2WSH(DLC Funding Output)`'s value is `Total Local Collateral + Total Remote Collateral + Computed CET Fee + Computed ToLocal Closing Fee` - `DLC Funding Output`'s script is OP_2 OP_2 OP_CHECKMULTISIG - - Each `Change ScriptPubKey`'s value is at most that of its respective `Sum(Funding Inputs) - Total Collateral - Computed Fees - (Computed CET Fee/2)` with `Computed Fees` being proportional to each party's total input weight and `Computed CET Fee` being the estimated fee for a [Contract Execution Transaction](#contract-execution-transaction) + - Each `Change ScriptPubKey`'s value is at most that of its respective `Sum(Funding Inputs) - Total Collateral - Computed Fees - (Computed CET Fee + Computed ToLocal Closing Fee)/2` with `Computed Fees` being proportional to each party's total input weight and `Computed CET Fee` being the estimated fee for a [Contract Execution Transaction](#contract-execution-transaction) and `Computed ToLocal Closing Fee` being the estimated fee for a [Unilateral Closing Transaction](#ClosingUnilateral) ## Contract Execution Transaction ### Known Values @@ -68,7 +68,7 @@ Where * ToRemoteOutput Where - - `P2WSH(ToLocalOutput).value = Local Payout` + - `P2WSH(ToLocalOutput).value = Local Payout + Computed ToLocal Closing Fee` - `ToRemoteOutput.value = Remote Payout` - `ToLocalOutput`'s script is: @@ -96,7 +96,7 @@ Where * Fee Rate: `FeeUnit` Where - - Unlike any other transaction in a DLC, there is only one Refund Transaction that both parties share + - Unlike CETs in a DLC, there is only one Refund Transaction that both parties share, similar to how there is only one [Funding Transaction](#funding-transaction) - Both `Refund Public Key`s are 33-byte compressed public keys - `Total Local Collateral + Total Remote Collateral = (DLC Funding Output).value` - `DLC Funding Output` is of the form [specified above](#FundingOutputs) @@ -111,7 +111,7 @@ Where Where - `ToLocalOutput`'s value is `Total Local Collateral + RefundFeeDelta/2` - `ToRemoteOutput`'s value is `Total Remote Collateral + RefundFeeDelta/2` - - `RefundFeeDelta = Computed CET Fee - Computed Refund Tx Fee` (note that the Refund Transaction is smaller than any CET) + - `RefundFeeDelta = Computed CET Fee + Computed ToLocal Closing Fee - Computed Refund Tx Fee` (note that the Refund Transaction is smaller than any CET) - `ToLocalOutput`'s script is: OP_0 @@ -124,10 +124,11 @@ Where Which is `P2WPKH(Remote Refund Public Key)` -## Closing Transaction (Unilateral) +## Closing Transaction (Unilateral) ### Known Values * Local Unilateral Public Key: `ECPublicKey` * nLockTime: `UInt32` + * Local Payout: `CurrencyUnit` * ToLocalOutput: `ScriptPubKey` * Fee Rate: `FeeUnit` @@ -143,7 +144,7 @@ Where * P2WPKH(Local Unilateral Public Key) Where - - `P2WPKH(Local Unilateral Public Key)`'s value is `P2WSH(ToLocalOutput).value - fee` + - `P2WPKH(Local Unilateral Public Key)`'s value is `Local Payout` ## Closing Transaction (Justice) ### Known Values