-
Notifications
You must be signed in to change notification settings - Fork 3
Combine DLCs and Lightning Channels #8
Comments
blocked by #10 |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
@luckysori : what do you think of going for option 3: make LN speak DLCs. There was an attempt in the past which never made it into the library. The PR is completely outdated but it doesn't look to complex. We could then build a LN wallet from LDK with this additional feature. |
My intuition tells me that option 3 is the hardest because we would have to integrate it into an existing codebase which we (I) don't understand. Potentially it is also the one that would reap the most benefits. I think I have a rough idea of how each option would be implemented, but I do not fully understand how they compare in terms of functionality. Could you expand that information in the original post? As an example of my confusion: I seem to remember that option 1 included making the fund transaction "look like" a Lightning funding transaction. But then the disadvantages talk about incompatibility with pre-existing Lightning nodes. What would be the point of that solution then if we cannot use it with other Lightning nodes in any way? |
@luckysori : I've added a few more words to the initial description.
I think we should give it a try. I had a look at their source code and it looks a bit scary to be honest 😬 The thing I'm most afraid of is keeping our fork up2date. I think this is though the best solution longterm.
I've updated the description: we are able to receive payments from any LN node but we can only open channels to nodes with our implementation because of the custom transaction structure. |
Perhaps we shouldn't try to build something that we will need to maintain longterm. Maybe it's sufficient if we treat the protocol as a PoC, aiming to replace it with a more sustainable integration down the line. @bonomat: I understand that for DLCs on Lightning to work we also need to implement dual-funded channels. Would it make sense to start with that? This is not yet implemented in |
Meeting minutes of the discussion about Lightning DLC protocolAttendants: @bonomat and @luckysori. 1. Choosing a protocolDecisionWe have settled on Option 3 aka ReasoningIt is the only protocol out of the 3 outlined which would allow other Lightning Nodes not written by us to connect to our nodes and do all regular Lightning things. We thought it was insufficient to just be able to receive Lightning payments. This approach is also the one that best aligns with our vision: extending the Lightning Network to support DLCs. We are not alone in this vision, as this is a topic that is frequently discussed among people involved in 2. ApproachExtending the Rust LDKWe intend to extend the Rust LDK library to support DLC protocols including:
In the context of CFD trading, we purposefully leave out the rollover protocol for the time being because:
It is important to highlight that we do not expect to write code that will be maintainable. We intend to fork the repository and relatively quickly extend the codebase to support DLCs. We think this is acceptable because we understand that it would be okay to rewrite most of the code that we produce for the The Rust LDK is a complex project and it is challenging to upstream new features. There have been previous efforts to add DLC support to it and very likely in the medium term we could help with that (after the Rough plan
A note on dependenciesWe think we need to be careful with using external dependencies because:
|
I've generated a couple of transaction diagrams to illustrate what we are building: Add a DLC to a Lightning channelCollaboratively settle a Lightning DLC into the channelNotesNo need to draw anything for non-collaborative settlement, because it just entails unilaterally publishing the transactions displayed in the first diagram, closing the overall Lightning channel in the process. |
Punishing the publication of revoked commitment transactionsWe are familiar with this concept because we had to deal with a similar problem in Since our approach is to effectively add new features to a full-fledged Lightning node, it appears to be necessary to conform to the ways in which Lightning deals with revoked state. In Lightning, when the state of the channel is updated the two parties also exchange revocation secret keys. The corresponding revocation public keys enable punish spend paths on particular outputs on the transaction ("all outputs that return funds to the owner of the commitment transaction"). For example, in the following diagram taken from the previous comment the output that pays to Bob is called RSMC B, because it uses a Revocable Sequence Maturity Contract. This contract allows Bob to spend it after a timeout, if Alice doesn't use the revocation path first to punish Bob. Similarly, HTLC outputs that pay to the owner of the commit transaction are also protected by a revocation key, although this is done in a "second-stage HTLC transaction". This is all to say that our newly introduced DLC output will also need to be spendable by the counterparty of the owner of the commit transaction, if they provide the necessary revocation secret key. This just means we will have to design the DLC script to include that path. This is similar to what we already do in The nice thing is that, once we introduce the new CFD rollover protocol, we will already be covered for punisment since a rollover will just be replacing the DLC output on the commitment transaction with a new one, revoking the previous commitment transaction by sharing the revocation key (like any other Lightning channel update). A note on terminologyLightning calls punishment transactions penalty transactions. We should adopt this terminology when working with Lightning. |
The output of this ticket should go into #14. |
Seen this from the dual-funding issue. We're still thinking to support DLC in LDK and we had recent discussions about this subject at our last developer meetings, with a floating timeline of 2023. To be honest, in light of our historical progresses on complex features and current engineering resources, I don't think we'll get on it before second part of 2023, and realistically it might take 18 months to complete a "beta" support. Further, I think we'll go for long-term maintainability/high robustness and we aim to offer a generic API/custom scripts, not only to have DLC but also think like PeerSwap, for any type of L3 off-chain contracts. All that said, I still believe LDK is an awesome choice, especially if you're looking for high-grade mobile support, it just mean you'll have to maintain a fork for a while. Ideally, valuable piece of codes could be backported in both directions. The DLC code could live in its own repository/crate, still under the "lightningdevkit" or "rust-bitcoin" orgs as they have been efforts already. There is also the long-term fact if you would like to benefit from advanced, low-level features we're currently working on with LDK, such as VLS, FROST, time-sensitive fee-bumping, high availability architecture. IIRC, we have a "dlc" chan on our Discord. Feel free to poke for more feedbacks on if LDK could match your applications requirements :) |
Hi @ariard , thanks for your input. We indeed think that rust-lightning is the best choice to go for. Mostly because it's written in rust :D I like the idea of having a more generic API. In fact, our first attempt will be to only add another output to the commit transaction and potentially leave the DLC management on application layer, so I think this goes pretty much into this direction. We have started with our efforts in our fork here: https://github.com/itchysats/rust-lightning/tree/dlcs. Our first approach is going to be more of a PoC style and will then go for a feedback round to see how to do it properly with the intention to contribute it upstream to rust-lightning. p.s. we are aware of https://github.com/p2pderivatives/rust-dlc and have our own implementation of custom dlc-channels here https://github.com/comit-network/maia/. They have been in production for almost 1 year now with https://github.com/itchysats/itchysats/. Give it a try if you have the chance ;) |
Note: we've enabled issues on our fork here https://github.com/itchysats/rust-lightning/issues/. I'll close this ticket in favor of the other repository. |
Goal
We want to build a wallet which speaks lightning and is able to do DLCs.
Possible approaches
Virtual channels
Probably the most complex solution is to have 2 virtual channels. One speaking lightning, the other one speaking DLCs.
E.g. something like this:
Diagram
Advantages:
Disadvantage:
Maia speak LN
We could implement the needed bolts into https://github.com/comit-network/maia/
Advantage:
Disadvantage:
LN speak DLC
We could add the DLC feature to a lightning implementation (e.g. use LDK and extend it). The it's ok to be odd would allow us to add features to our client without breaking compatibility with other LN implementations.
Advantage:
Disadvantage:
The text was updated successfully, but these errors were encountered: