<oembed><type>rich</type><version>1.0</version><title>Lloyd Fournier [ARCHIVE] wrote</title><author_name>Lloyd Fournier [ARCHIVE] (npub1kh…y05yp)</author_name><author_url>https://yabu.me/npub1khlhcuz0jrjwa0ayznq2q9agg4zvxfvx5x7jljrvwnpfzngrcf0q7y05yp</author_url><provider_name>njump</provider_name><provider_url>https://yabu.me</provider_url><html>📅 Original date posted:2019-01-02&#xA;📝 Original message:&#xA;Happy new year lightning-dev!&#xA;&#xA;This topic is my main area of research at moment so I&#39;m really happy to see&#xA;a thread about it. In general I agree with ZmnSCPxj&#39;s analysis and&#xA;conclusions. I&#39;d like to add a couple of ideas to this discussion and would&#xA;greatly appreciate some early peer review on them :)&#xA;&#xA;HTLCs as American call options&#xA;=========================&#xA;&#xA;I think the &#34;option problem&#34; is actually caused by protocols using HTLCs in&#xA;a naive way rather than the use of HTLCs themselves. Consider the atomic&#xA;swap protocol described in the OP:&#xA;&#xA;&gt;1.  You provide me a hash of some secret preimage that only you know.&#xA;&gt;2.  You make an HTLC on the Bitcoin blockchain.&#xA;&gt;The value of this HTLC is `P`, the hash is the hash you gave above, and&#xA;the timelock is `E` + 1 day.&#xA;&gt;3.  I make an HTLC on the WJT blockchain.&#xA;&gt;The value of this HTLC is 1, the hash is the hash you gave, and the&#xA;timelock is `E`.&#xA;&#xA;If we take this protocol and draw out its abstract functionality we get:&#xA;&#xA;1. *Up for sale* Alice puts Asset `A` up for sale to Bob for some time&#xA;period `Eb` + `Ea`&#xA;2. *Make expiring offer* Bob makes an offer of asset `B` which expires at&#xA;time `Eb`&#xA;3. *Take offer* Alice may take the offer up until time `Eb`&#xA;&#xA;As has been pointed out, Alice has an &#34;option&#34; for the duration of `Eb`&#xA;(and she didn&#39;t pay a premium). This is because Bob made her an offer he&#xA;cannot cancel (an offer you can&#39;t cancel but has an expiration is basically&#xA;the definition of being short an option contract).&#xA;In order to remedy this, the party that makes the offer must be able to&#xA;cancel their offer at any point after they have made it (before the&#xA;counterparty has taken it). This should be intuitive because it&#39;s how&#xA;centralised exchanges work.&#xA;&#xA;Therefore, the ideal abstract functionality we want is:&#xA;&#xA;1. *Make Offer* Alice makes an offer to Bob to trade `A` for `B`&#xA;2. *Take Offer* Bob can take the offer (if Alice hasn&#39;t already cancelled&#xA;it) and get `A` in exchange for `B`.&#xA;3. *Cancel Offer* If Bob hasn&#39;t taken the offer, Alice may get back `A` by&#xA;cancelling the offer&#xA;&#xA;I developed the protocol below which comes pretty close to realising this.&#xA;Let&#xA;- α and β and be two bitcoin-like blockchains&#xA;- Alice own asset `A` on the α blockchain and `C` on the β blockchain&#xA;- Bob own asset `B` on the β blockchain&#xA;&#xA;1. Alice puts the HTLC for `A` on α and waits for it to confirm (as per&#xA;usual)&#xA;2. Alice creates a partial β blockchain transaction by signing one input&#xA;and one output (using SIGHASH_SINGLE for example):&#xA;   - The input is the asset `C`&#xA;   - The output is a HTLC which gives `B` and `C` to herself with the&#xA;secret or gives them both to Bob on timeout&#xA;  She sends this partial transaction to Bob. (This gives us the &#34;Make&#xA;Offer&#34; functionality)&#xA;3. If Bob wants to accept the offer, he adds asset `B` to another input of&#xA;the transaction and posts it to β. (This gives us &#34;Take Offer&#34;&#xA;functionality)&#xA;4. If Alice wishes to cancel the trade before Bob has confirmed this&#xA;transaction she double spends the `C` output and then reclaims `A` on α&#xA;after the timeout. (This gives us the &#34;Cancel Offer&#34; functionality)&#xA;5. If the &#34;Take Offer&#34; transaction is confirmed on β, Alice must unlock the&#xA;HTLC before the timeout or Bob will gain `C` AND get back `B`.&#xA;6. Once she reveals the secret, she both gets back `C` and gains `B` on β.&#xA;7. Bob can now take `A` on α in the usual manner now that he has learned&#xA;the secret.&#xA;&#xA;Bob is not guaranteed to get `A` after he &#34;takes&#34; the offer but he is&#xA;guaranteed to get `A` (in exchange for `B`) or `C` (for free). Obviously,&#xA;`C` is Alice&#39;s collateral for the trade. Bob should only take the offer if&#xA;he wants `A` more than `B` and if he is sure that the value of gaining `C`&#xA;will be greater than any loss he could experience from `B` depreciating&#xA;relative to `A` during the execution of the protocol.&#xA;&#xA;I believe this shows that HTLCs do not in cause options but rather&#xA;uncancelable offers + uncollateralized HTLCs cause the option problem.&#xA;&#xA;I think this protocol works in payment channels in the case that Alice and&#xA;Bob have direct channels to each other. The issue is that if Alice decides&#xA;she wants to cancel at the same time Bob decides he wants to take it you&#xA;have to go to the blockchain to resolve the issue (which will be rather&#xA;arbitrary). CJP&#39;s idea of having a 3rd party who is trusted simply to&#xA;compute the outcome of a offer (cancelled or taken) in layer 2 networks&#xA;seems like a promising direction because this would avoid on-chain&#xA;resolution in this case.&#xA;&#xA;Cross Asset Payments Don&#39;t Make Sense&#xA;====================================&#xA;&#xA;As ZmnSCPxj demonstrated, the idea of sending a payment in asset `A` and&#xA;the other party receiving it as asset `B` with some exchange node in the&#xA;middle doing a conversion is unsound given what we are able to construct in&#xA;Lightning.&#xA;&#xA;But this doesn&#39;t necessarily mean that Lightning has to be single asset.&#xA;Theoretically, a single two-party channel could record multiple asset types&#xA;with a state transaction that has distinct outputs for different&#xA;asset-type/party combinations. This would allow you to buy an amount of the&#xA;desired asset in one of your channels by simply doing a state update where&#xA;you lose `A` in exchange for `B` with your direct peer (no HTLCs needed).&#xA;You can then just send `B` normally to the receiver. This is not quite as&#xA;good as a cross asset payment but it could still be useful*.&#xA;&#xA;Quite simply, if you want to send someone asset `A` but they want to&#xA;receive asset `B` then just buy asset `B` with asset `A` and then send `B`&#xA;to them!&#xA;&#xA;*I don&#39;t know much about non-native assets on Bitcoin and their suggested&#xA;integration with LN so I&#39;m just guessing here.&#xA;&#xA;All the best for 2019,&#xA;Lloyd&#xA;\n&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20190102/5adacabb/attachment-0001.html&gt;</html></oembed>