discreetlogcontracts / dlcspecs

Specification for Discreet Log Contracts
Creative Commons Attribution 4.0 International
238 stars 36 forks source link

DLC Mutual Close #170

Open matthewjablack opened 3 years ago

matthewjablack commented 3 years ago

This PR adds new close_dlc as per the discussion regarding https://github.com/discreetlogcontracts/dlcspecs/issues/161 which enables a way to request to close a DLC before cet_locktime with mutual consent

benthecarman commented 3 years ago

imo this would be better if it was more generalized. It would be great if this could be used to inside of any transaction. That way we could close our DLC inside of a regular transaction or in a batch with many other people, or even inside of a coinjoin.

matthewjablack commented 3 years ago

I realized funding_signatures for funding_inputs was missing, which are required sigs to broadcast and finalize close dlc. This has been added to close_dlc specification in Protocol.md

matthewjablack commented 3 years ago

Based on feedback from @ariard I've added nullifying_point and rationale to Non-Interactive-Protocol.md to explain why funding-inputs are necessary, and introduce a point where the initiator should nullify the close signature by spending funding-inputs as the outcome of the close transaction become increasingly unfavorable.

matthewjablack commented 2 years ago

It might be nice to consider defining a feature flag for this as well.

I agree that a contract flag could make sense to ensure one party does not waste sats sending a DlcClose message to a peer that is not going to accept it. Perhaps adding contract flag definition would make sense in a subsequent PR.

I think what should be changed is the funding_inputs naming. It conflict with the inputs of the funding transactions and is IMHO quite confusing. What about something like extra_inputs or cancellable_inputs?

I changed funding_inputs => extra_inputs and funding_signatures => extra_signatures to reduce confusion. I considered cancellable_inputs and cancellable_signatures however the concept of cancellable_signatures seemed very strange and confusing at face value.

matthewjablack commented 2 years ago

I also added close_locktime to help prevent fee sniping. It should be set to less than or equal to current timestamp/block.

matthewjablack commented 2 years ago

I checked on how this will be affected by #163, and it seems the only things to do is change the field num_extra_inputs from u16 to bigsize.

Fantastic 👌

TODO: