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

Contract Execution Transaction Specification #56

Closed
wants to merge 1 commit into from

Conversation

nkohen
Copy link
Contributor

@nkohen nkohen commented Aug 11, 2020

Took my best shot at specifying the DLC Contract Execution Transaction as things stand right now.

The CET weight has been tested here: https://blockstream.info/testnet/tx/e2678c5646dc79ed0d7e0cc79ef5b0b3539d8ec9e32de1fbb3d854aaab1709f6

Related to #12
Related to #46

TODO:

  • CET Test Vectors

@nkohen nkohen added this to the v0.1 milestone Aug 11, 2020
@nkohen
Copy link
Contributor Author

nkohen commented Aug 11, 2020

I'm realizing that the Refund Transaction is exactly the same as a CET except it has a different locktime and output values are equal to the offerer and accepter's total collaterals from contract negotiation. As such, I am no starting to lean towards once again having just a single specification document for transactions which combines this PR and #51 into a single file and has a section on the Refund Transaction stating that it is specified as a special CET construction so that there isn't so much redundancy.

Comment on lines +32 to +36
The Offerer/Initiator's output comes first, the Accepter's output comes second.

Note that this will likely change in the future.

If either party receives less than the dust limit of `1000 satoshis` for this outcome, then their output is not produced.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should note that both of these are likely to change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I think this is another good case for where we could use bip-69 for input/output ordering for v0.1

Copy link
Contributor

@ariard ariard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should discuss if we add CET anchor outputs for v0.1. IMO, as predicting the feerate is even harder to be right for CET given your oracle signatures might be a month from now, network mempools will be far different. With the funding, the feerate negotiated is to be broadcast soon so less likely to be inaccurate.

- OP_2: 1 byte
- OP_CHECKMULTISIG: 1 byte

offer_output: 9 + offer_output_script length bytes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aren't output scripts normalized and thus we know their length ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is a final address field in both the offer and accept messages which will specify the SPK used, it does not even have to be segwit.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p2wpkh is OP_0 <20-byte-hash> vs p2wsh is OP_0 <32-byte-hash>

taproot will be OP_1 <32-byte-pub-key>


### Accepter Output

This output sends funds won by the accepter corresponding to this CET's outcome to the accepter's final address specified in the accept message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace address by scriptpubkey. Address are application-level data structs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addresses are what are currently specified in the offer and accept messages.


### Offerer Output

This output sends funds won by the offerer corresponding to this CET's outcome to the offerer's final address specified in the offer message.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Layout the witnessScript as they're not P2WPKH IIRC?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what you mean?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, they're freely picked up by offerer/accepter ?


# Fees

Fees for the CET are paid for in the Funding Transaction, the following only shows the weight calculation for the largest possible CET.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You mean the feerate is the same than the funding transaction ? Might be better like "The fee calculation for CETs is based on the negotiated feerate_per_kw and the expected weight of the transaction."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean that the outputs of the CETs are the exact outcome values negotiated and this is accomplished by including their fees in the funding output

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I.e. all fee computation is done when constructing the funding transaction, none is necessary for the CETs/Refund Tx

@nkohen
Copy link
Contributor Author

nkohen commented Aug 11, 2020

Replaced by #57

@nkohen nkohen closed this Aug 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants