Blockstream / green_qt

Blockstream Green App
GNU General Public License v3.0
203 stars 32 forks source link

Liquid Swaps #38

Open bstin opened 4 years ago

bstin commented 4 years ago

Not a bug. But a question / feature enhancement?

Is there support for swaps in Liquid?

Would be nice if you could load a proposal into client (paste / QR) and then approve.

SimpleAristocrats commented 4 years ago

I don't know if it fits your needs but there's a swap tool for liquid : https://docs.blockstream.com/liquid/swap_tool.html#using-liquid-swap-tool

bstin commented 4 years ago

Thank you for this, but my use case would involve mobile.

Imagine an arcade where you have been earning some TOKENS and now you want to leave the venue and exchange your remaining balance for L-USD.

  1. Go to Kiosk, which generates a proposal (ie 4 TOKENS = 1 USD) and displays it via QR Code on screen
  2. User scans proposal with Green Wallet on Phone. Taps Accept.
  3. Response is sent back to server which executes swap on network.

I realize its possible to do this manually - not using Liquid Swaps. But it would be much more secure and less development hassle to just utilize swaps, if they were available on mobile.

SimpleAristocrats commented 4 years ago

Interesting. So, the arcade would create tokens on liquid and customers could get and use them with the green app on mobile. The arcade could manage a website service like liquiditi dot io for those tokens. Perhaps the coinos github could serve as a starter to hack something together? : github.com/asoltys/coinos

bstin commented 4 years ago

This is precisely the theory. What I'm trying to achieve though is lessen the need for "arcade manages a liquiditi website", since that will become a headache for staff long-term.

I would like the arcade to just have a QR Code sticker that had a "proposal" on it (ie. 4 TOKENS = 1 L-USD). Then the user would just need to sign and accept. Hope my logic is coming thru....basically like a standing proposal....."out of this wallet we offer 1 L-USD for every 4 TOKENS you send us...." - without the need for a coinos like infrastructure

But relatedly, thank you for the coinos github. Thats an interesting project that I will consider.

SimpleAristocrats commented 4 years ago

Yeah, I see what you mean. I wouldn't know how to do that with the apps right now. Wouldn't the customer also need to show their own QR code to receive (to their receive address)? Or are you planning on sending it to the same address? (I wonder if we can send different assets on the same liquid address, haven't tried it yet).

Another option that comes to mind (wouldn't however be a simple as a QR code sticker proposal) would be to use BTCPayServer with their altcoin support (liquid) and their API or possibly their Transmuter : https://docs.btcpayserver.org/Altcoins/ https://docs.btcpayserver.org/API/Greenfield/v1/ https://docs.btcpayserver.org/Transmuter/#btctransmuter-docs BTCPayServer can be installed with just a few clicks on lunanode : https://docs.btcpayserver.org/LunaNodeWebDeployment/

BTCPayServer offers liquid out of the box (with liquid tether apparently : from the docs "Liquid Bitcoin (LBTC) (comes with Liquid Tether support USDt)" but I don't know if that includes other issued assets or how difficult it would be to add other liquid assets. It might not be too hard since the docs say https://docs.btcpayserver.org/Altcoins/#how-can-i-add-an-altcoin-to-btcpayserver : "Add support for your crypto to NBitcoin , NBxplorer , and BTCPayServer . (Use examples from other coins)". If my understanding of liquid is fit for purpose(!), it might be as simple as changing a few strings.

With BTCPayServer (and probably transmuter), you could use the integrated point of sale terminal "app" that would offer 1 USDt for 4 L-Arcade-Tokens, detect the payment and send the USDt automatically. But I guess the arcade would still need to hack something so the terminal scans the customer's QR code (for his receive address) unless the customer inputs his address manually in a form. Or perhaps the arcade could add a little thermal printer on the side of the terminal that prints out a qr code for sweeping by the customer? (like some Bitcoin ATMs do). Ah... I just checked and apparently Green doesn't have the "sweep" option on liquid yet (we have a sweep option on the green android app for bitcoin but not for liquid yet). So I guess the customer would have to input his address in some way (manually or via a camera on the PoS terminal). Maybe you could create an issue asking the green team to include the sweep function for liquid as well? Maybe this DIY lightning ATM project might also come in handy to jumpstart the code you might need for the QR code scanning : https://github.com/21isenough/LightningATM

Btw, I also heard about a project to issue assets over lightning : RGB. It launched in beta about a month ago but I haven't had time to look into it much yet : https://github.com/LNP-BP/devcalls/blob/master/RGB%20%26%20Spectrum%20explanation%20for%20business.pdf But then I guess there are probably things to consider concerning inbound liquidity for the customer (on lightning). That's what I like about liquid the most at this point : it works without having to consider channels and liquidity.

I tried to answer your hypothesis as much as I could but to broaden the discussion: are you certain that the arcade tokens are necessary? Satoshis on lightning could probably be viewed as "tokens" to be used in the arcade? I guess, depending on your jurisdiction, there might be differences in the regulatory treatment of these different scenarios.

(P.S. liquiditi.io also has an api. Might come in handy depending on how you end up implementing things.)

bstin commented 4 years ago

Thanks for all your well thought out answers / thoughts. I really appreciate it.

After reviewing the Liquid Swaps workflow more, I see that I thought the workflow was:

When in fact the workflow is:

Hmmm....seems like that is one-step too many for my usecase. Perhaps BTCPayServer is the way to go. Or as you suggested, "sweeping" would be an elegant solution.

I thought about using LN however that brings up several UX and logistical problems that I think only add complications with no benefit (opening channels, currency fluctuations, etc). Moreover the purpose of using TOKENS in the first place is to escape legal entanglements that sometimes associate playing arcade games and winning prizes with gambling. By using a non-monetary TOKEN and leave it to the discretion of the operator for when / who / under what circumstance to convert those back to money escapes those difficulties.