<oembed><type>rich</type><version>1.0</version><author_name>npub1zgyy2j829vn4zuvhkgza7qe37knzdls4kuwt2k8cehwpjxn9duwqv5j4mf</author_name><author_url>https://nostr.ae/npub1zgyy2j829vn4zuvhkgza7qe37knzdls4kuwt2k8cehwpjxn9duwqv5j4mf</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2023-05-09&#xA;🗒️ Summary of this message: A proposed solution to protect against liquidity griefing attacks in Lightning Network&#39;s dual funded transactions is to never lock UTXOs used in the transactions. Instead, if a remote node goes silent, the UTXOs will be automatically re-used in another instance of the protocol. However, this solution is not safe when multiple contributors are involved. The proposed solution is to lock UTXOs after tx_complete exchange if the channel has only one contributor and to differentiate 0-conf channels prior to UTXO selection to avoid reusing soft-locked UTXOs.&#xA;📝 Original message:&#xA;Hi Bastien,&#xA;&#xA;In general, 0-conf is only safe when WE are the only contributor to&#xA;the channel, otherwise the peer could double spend us.&#xA;&#xA;The problem you seem to be describing is that we might double-spend&#xA;ourselves if we don&#39;t lock our 0-conf UTXOs at some point.  I propose&#xA;that we DO lock our UTXOs after tx_completes have been exchanged IF we&#xA;are the only contributor.  We don&#39;t have to worry about liquidity&#xA;griefing in this case, since the peer has no tx_signatures to withhold&#xA;from us.  Of course, the opportunistic upgrade of a regular channel to&#xA;0-conf won&#39;t work -- we need a way to differentiate 0-conf channels&#xA;prior to UTXO selection, so that we don&#39;t reuse soft-locked UTXOs.&#xA;&#xA;All together, what I propose is:&#xA;&#xA;1) If the channel type has option_zeroconf, select UTXOs that are not&#xA;soft locked.&#xA;2) If the peer adds any inputs to the funding transaction, abort&#xA;(0-conf is unsafe for us in this case).&#xA;3) After tx_complete exchange, TryLock() our UTXO inputs and abort if&#xA;already locked.&#xA;4) Broadcast funding transaction and begin using the 0-conf channel.&#xA;&#xA;I think this at least enables the common use case for 0-conf: LSPs can&#xA;use their own funds to open 0-conf channels for clients.&#xA;&#xA;- Matt&#xA;&#xA;&#xA;&#xA;&#xA;On Sat, May 6, 2023 at 3:16 AM Bastien TEINTURIER &lt;bastien at acinq.fr&gt; wrote:&#xA;&gt;&#xA;&gt; Good morning list,&#xA;&gt;&#xA;&gt; One of the challenges created by the introduction of dual funded&#xA;&gt; transactions [1] in lightning is how to protect against liquidity&#xA;&gt; griefing attacks from malicious peers [2].&#xA;&gt;&#xA;&gt; Let&#39;s start by reviewing this liquidity griefing issue. The dual funding&#xA;&gt; protocol starts by exchanging data about the utxos each peer adds to the&#xA;&gt; shared transaction, then exchange signatures and broadcast the resulting&#xA;&gt; transaction. If peers lock their utxos as soon as they&#39;ve decided to add&#xA;&gt; them to the shared transaction, the remote node may go silent. If that&#xA;&gt; happens, the honest node has some liquidity that is locked and unusable.&#xA;&gt;&#xA;&gt; This cannot easily be fixed by simply unlocking utxos *after* detecting&#xA;&gt; that the remote node is fishy, because the remote node would still have&#xA;&gt; succeeded at locking your liquidity for a (small) duration, and could&#xA;&gt; start other instances of that attack with different node_ids.&#xA;&gt;&#xA;&gt; An elegant solution to this issue is to never lock utxos used in dual&#xA;&gt; funded transactions. If a remote node goes silent in the middle of an&#xA;&gt; instance of the protocol, your utxos will automatically be re-used in&#xA;&gt; another instance of the protocol. The only drawback with that approach&#xA;&gt; is that when you have multiple concurrent instances of dual funding with&#xA;&gt; honest peers, some of them may fail because they are double-spent by one&#xA;&gt; of the concurrent instances. This is acceptable, since the protocol&#xA;&gt; should complete fairly quickly when peers are honest, and at worst, it&#xA;&gt; can simply be restarted when failure is detected.&#xA;&gt;&#xA;&gt; But that solution falls short when using 0-conf, because accidentally&#xA;&gt; double-spending a 0-conf channel (because of concurrent instances) can&#xA;&gt; result in loss of funds for one of the peers (if payments were made on&#xA;&gt; that channel before detecting the double-spend). It seems like using&#xA;&gt; 0-conf forces us to lock utxos to avoid this issue, which means that&#xA;&gt; nodes offering 0-conf services expose themselves to liquidity griefing.&#xA;&gt;&#xA;&gt; Another related issue is that nodes that want to offer 0-conf channels&#xA;&gt; must ensure that the utxos they use for 0-conf are isolated from the&#xA;&gt; utxos they use for non 0-conf, otherwise it is not possible to properly&#xA;&gt; lock utxos, because of the following race scenario:&#xA;&gt;&#xA;&gt; - utxoA is selected for a non 0-conf funding attempt and not locked&#xA;&gt;   (to protect against liquidity griefing)&#xA;&gt; - utxoA is also selected for a 0-conf funding attempt (because it is&#xA;&gt;   found unlocked in the wallet) and then locked&#xA;&gt; - the funding transaction for the 0-conf channel is successfully&#xA;&gt;   published first and that channel is instantly used for payments&#xA;&gt; - the funding transaction for the non 0-conf channel is then published&#xA;&gt;   and confirms, accidentally double-spending the 0-conf channel&#xA;&gt;&#xA;&gt; This can be fixed by using a &#34;soft lock&#34; when selecting utxos for a non&#xA;&gt; 0-conf funding attempt. 0-conf funding attempts must ignore soft locked&#xA;&gt; utxos while non 0-conf funding attempts can (should) reuse soft locked&#xA;&gt; utxos.&#xA;&gt;&#xA;&gt; In eclair, we are currently doing &#34;opportunistic&#34; 0-conf:&#xA;&gt;&#xA;&gt; - if we receive `channel_ready` immediately (which means that our peer&#xA;&gt;   trusts us to use 0-conf)&#xA;&gt; - and we&#39;re the only contributor to the funding transaction (our peer&#xA;&gt;   doesn&#39;t have any input that they could use to double-spend)&#xA;&gt; - and the transaction hasn&#39;t been RBF-ed yet&#xA;&gt;&#xA;&gt; Then we immediately send `channel_ready` as well and start using that&#xA;&gt; channel (because we know we won&#39;t double spend ourselves). This is nice&#xA;&gt; because it lets us use 0-conf in a way where only one side of the&#xA;&gt; channel needs to trust the other side (instead of both sides trusting&#xA;&gt; each other).&#xA;&gt;&#xA;&gt; Unfortunately, we cannot do that anymore when mixing 0-conf and non&#xA;&gt; 0-conf funding attempts, because the utxos may be soft locked,&#xA;&gt; preventing us from &#34;upgrading&#34; to 0-conf.&#xA;&gt;&#xA;&gt; You have successfully reached the end of this quite technical post,&#xA;&gt; congrats! My goal with this post is to gather ideas on how we could&#xA;&gt; improve that situation and offer good enough protections against&#xA;&gt; liquidity griefing for nodes offering 0-conf services. Please share&#xA;&gt; your ideas! And yes, I know, 0-conf is a massive implementation pain&#xA;&gt; point that we would all like to remove from our codebases, but hey,&#xA;&gt; users like it ¯\_(ツ)_/¯&#xA;&gt;&#xA;&gt; Cheers,&#xA;&gt; Bastien&#xA;&gt;&#xA;&gt; [1] https://github.com/lightning/bolts/pull/851&#xA;&gt; [2] https://github.com/lightning/bolts/pull/851#discussion_r997537630&#xA;&gt; _______________________________________________&#xA;&gt; Lightning-dev mailing list&#xA;&gt; Lightning-dev at lists.linuxfoundation.org&#xA;&gt; https://lists.linuxfoundation.org/mailman/listinfo/lightning-dev</html></oembed>