neutrino icon indicating copy to clipboard operation
neutrino copied to clipboard

Possible to compile to WASM to run in browser

Open tiero opened this issue 3 years ago • 3 comments
trafficstars

tiero avatar Nov 23 '21 11:11 tiero

This hasn't been attempted yet. The main blocker for compiling it is probably the bbolt database library that is used for the filter storage. We'd need to build an alternative database backend for the browser. Also the current bitcoin p2p communication that uses TCP/IP directly would need to be bridged over HTTP.

guggero avatar Nov 23 '21 11:11 guggero

I've been waiting for this feature for a while now and I see it's not gaining much traction...

I think it's doable, although not trivial. But it would be very exciting for sure!

Some possibilities this would unlock:

  • Running Neutrino in the webbrowser (obviously) would allow using Lightning completely from the browser, nothing to install, no external node to setup and run.
  • Getting non-custodial mobile Lightning wallets to work in the browser. For example, the Breez wallet includes Neutrino and is written in Flutter, so running it in the browser should be possible, if Neutrino would work in the browser.
  • Bundling a Lightning node with a Lightning browser plugin (such as Zebedee) to allow them to be non-custodial.
  • Many more use cases, I'm sure...

I might be interested in taking as stab at this but perhaps we need to flesh out the details a little bit more, to get it right the first time.

Any input or pointers would be greatly appreciated, like more details on:

  • exactly what would be the best technology to (re)use for the database?
  • exactly how could the Bitcoin p2p traffic be bridged over HTTP? Any existing technologies or solutions we can base this on?

ThomasFarstrike avatar Aug 11 '22 15:08 ThomasFarstrike

it's already been done elsewhere, just needs to be glued-on here:

🌐 patch the btcwallet dep to use leveldb instead of boltdb (impl) 🌐 patch lnd (& neutrino) to use leveldb and websockets (impl) 🌐 use websocksify to proxy ws to tcp (impl)

i just compiled lnd@latest and btcwallet@latest with GOOS=js GOARCH=wasm, merged with those branches + a few fixes and loaded them in the browser with wasm_exec.js

given the chaotic state of bitcoin <-> wallet <-> browser ux compared with ethereum (thx to the metamask monopoly); putting effort here might pay dividends. to be sure, i installed the latest alby extension and tried to connect to roughly 20 featured sites; about a 2/3 of them were broken, didn't work, or required me to take too much action that I churned. This is unfortunate and further complicated by disjoint efforts across WebLN, Lightning Node Connect (LNC), and whatever is brewing in the nostr space; leading to confusing UX and onerous DX:

maceip avatar Aug 10 '23 00:08 maceip