Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deterministic Fee Computation #12

Closed
nkohen opened this issue Feb 14, 2020 · 5 comments
Closed

Deterministic Fee Computation #12

nkohen opened this issue Feb 14, 2020 · 5 comments

Comments

@nkohen
Copy link
Contributor

nkohen commented Feb 14, 2020

In transaction construction, both parties must always agree on the fee of a given transaction.

This requires we define a deterministic function computeFee that takes in an transaction and the feerate at time of the DLC offer message, and returns the fee in satoshis.

I have opened this issue to allow there to be a place for the discussion of what this function should look like to happen.

Bitcoin-S currently uses the following static numbers to do CET and closing fee computations

  /** Experimental approx. vbytes for a CET */
  private val approxCETVBytes = 190

  /** Experimental approx. vbytes for a closing tx spending ToLocalOutput */
  private val approxToLocalClosingVBytes = 122

Note that I haven't checked that they are correct in quite a while (and changes have been made) and also we should have different numbers when outputs are removed due to the dust threshold.

@Tibo-lg
Copy link
Member

Tibo-lg commented Feb 18, 2020

we should have different numbers when outputs are removed due to the dust threshold.

Do you mean we might also discard outputs in CETs? I was personally thinking of only discarding change outputs in the fund transaction.

For CET and Closing, I think it makes sense to use constants, as I cannot really think of what could influence their size.

For the fund transaction input size estimation, we use this function: https://github.com/cryptogarageinc/cfd-core/blob/master/src/cfdcore_transaction.cpp#L72

At the moment we assume that all input are just P2WPKH, but if we update the protocol we could easily support P2WSH as well.

@nkohen
Copy link
Contributor Author

nkohen commented Mar 10, 2020

I'm quite confused as to why we wouldn't discard, for example, 0-amount outputs on CETs (in the case that one party wins all the funds). They are a pretty big privacy leak if we keep them. And if we are planning to remove them which I think we should this will affect the size of transactions and hence the fees.

@Tibo-lg
Copy link
Member

Tibo-lg commented Mar 10, 2020

Good point, you are right that we should also discard them. Then the question is, do we take into account that there might be only CETs with single output in which case the fee added to the collaterals in the fund transaction will change, or do we always put the same fee regardless and just give the leftover to the winning party? I guess the former is a bit nicer, but also a bit more complex.

@nkohen
Copy link
Contributor Author

nkohen commented Mar 12, 2020

During our meeting we decided not to change fees when outputs are removed due to them being dust. This is easier to implement as well as generally being a good idea when we move to multi-output CETs (when we have multi-party DLCs)

@nkohen
Copy link
Contributor Author

nkohen commented Sep 29, 2020

Closed by #81

@nkohen nkohen closed this as completed Sep 29, 2020
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

No branches or pull requests

2 participants