rawtxapp / rawtxapp

⚡️A lightning network wallet (https://rawtx.com).
MIT License
55 stars 18 forks source link

Adding a built-in browser for lApps #17

Closed caffeinum closed 5 years ago

caffeinum commented 5 years ago

Trust wallet has for built-in browser with web3 installed (https://medium.com/@trustwallet/fully-featured-dapp-browser-for-mobile-4d062a0c66cb).

Would be nice to add to rawtx the built-in browser which will be using webln lib: https://github.com/wbobeirne/webln by @wbobeirne.

image

rawtxapp commented 5 years ago

Thanks for the feedback @caffeinum, it's actually already implemented, you might see some references to the project "micro" in the codebase.

It's not publicly released yet, hoping to make it public when the wallet is stable enough for daily use, there are still a few issues wrt to syncing and opening channels, etc.

Took a quick look at webln, looks like it allows a direct communication between browser and lnd which could be unsafe. We have a different way which we believe is better and more intuitive especially for micropayments. We'll share more information very soon.

ohld commented 5 years ago

Can you please estimate when the stable version with browser with web3 support will be released?

rawtxapp commented 5 years ago

@ohld the one we built is a bit different than web3 (seems like web3 is for eth ?), though if it makes sense we can enable support for it too.

As for the browser within the wallet, was planning for sometime in December/early January, but it can be released earlier if there's demand for it.

wbobeirne commented 5 years ago

@rawtxapp Do you have more information on your implementation? I was unable to find any files, branches, or other repositories on your account with the word "micro" in it. Do you have any information on what you intend that spec to look like?

For what it's worth, WebLN is not a direct connection with the node, it's just a proxy interface that the client can choose how to implement. Would be happy to talk more about it if there's interest on your end. I think the best path forward to get websites integrating more deeply with nodes is an open, collaborative protocol, and I didn't see anything like it out there for Lightning yet.

rawtxapp commented 5 years ago

@wbobeirne here's an example of realtime chat app which integrates with it https://github.com/rawtxapp/chat/blob/master/src/Micro.js. There's also references to it in this repo: https://github.com/rawtxapp/rawtxapp/blob/master/src/App.js#L24.

It's essentially communicating through the webview's messaging.

There are a few message types: initMicro, getAppAllowance, askForAllowance, lightning. Concept of allowance will make more sense once you see the UI and the experience built around it.

The biggest thing is that an app could be adversarial (someone hacks a lapp changes invoice destinations, etc). When I looked through provider spec in https://github.com/wbobeirne/webln, it seemed like it had a different purpose (ex: it doesn't make sense to let a lapp query getInfo). Though if it makes sense and there apps using it, we are happy to integrate.

Agree that we need an open/collaborative protocol, but we need to first experiment with some lapps to see possibilities and get some experience on what works and what doesn't.

caffeinum commented 5 years ago

@rawtxapp @wbobeirne I think webln takes much of its ideas from https://github.com/ethereum/web3.js/, which is already used in dApps. It makes sense to build similar API because developers that are used to web3 interface will have much less pain moving to build lApps.

Also, 👍 to the collaborative protocol, that's definitely what we need here.

wbobeirne commented 5 years ago

@rawtxapp Awesome, cool to see an example. I've had many people suggest the allowance concept to me (And just made an issue to start tracking that) however I feel that that could be something handled at the client level (e.g. user sets up allowance in the chrome extension / app UI) and it just approves the transaction instantly, without the user needing to acknowledge it. You can see more about how I plan on implementing that here: https://github.com/wbobeirne/joule-extension/issues/42 If there are compelling use-cases for the application to know more about allowances, I could see it being a top-level API, but for now I think a simple "please pay me" function suffices for the use case.

As for getInfo, it would require the user to allow the lapp to communicate with it (by calling webln.enable first) and only provides a subset of getInfo for basic identifying information, nothing harmful. As for why to expose it, the goal with WebLN is to be used not just for payments, but identity as well (e.g. login to a site by signing a message or opening a channel, instead of username / password.) This is a common UX pattern in the ethereum dapp ecosystem.

Hoping to see some good examples & use cases pop up for this stuff as Lightning gains popularity & stability.

Kixunil commented 5 years ago

@rawtxapp I've implemented a very safe webln extension by isolating the wallet from browser. I had similar concerns and found out they can be addressed pretty easily.

rawtxapp commented 5 years ago

This is now launched: https://rawtx.com/rawtx/update/2019/04/15/introducing-project-micro.html. Feel free to create issues on Github for feedback/bugs.