stacksgov / grants-program

Welcome to the Stacks Foundation Grant Program. Community members interested in submitting a grant proposal may do so by opening an issue in this repository and filling out the grant application.
141 stars 36 forks source link

LNswap integration for Hiro Wallet #311

Closed Regulr3 closed 1 year ago

Regulr3 commented 2 years ago

Background What problems do you aim to solve? How does it serve the mission of a user-owned internet?

Currently, the Hiro wallet does not support Bitcoin or Lightning wallets in addition to STX or other city coins. Having these options be fully functional by default is critical for the Hiro wallet given Stacks ethos and well-known claims for ‘unlocking bitcoin’ and being ‘the programmable layer on bitcoin’. Many within the Stacks ecosystem and even the Bitcoin ecosystem would welcome the option to mint NFTs with bitcoin, offer up some amount of bitcoin to provide liquidity, pay gas fees with bitcoin, or easily swap bitcoin for Stacks as they may be unable to purchase STX directly in other channels due to local laws. Adding both a Bitcoin and Lightning wallet along with LNswap functionality into the Hiro wallet is a step toward making all those possibilities a reality.

Hiro wallet users should have the choice and ability to self-custody and transact easily with both Bitcoin and Stacks by default. For stackers who want their stacking yield paid out directly into a Bitcoin wallet within the Hiro wallet and not another Bitcoin wallet option outside of Hiro, this should be the go-to option for them.

“If it's possible, it's crazy nobody has done this yet. The whole $STX story is built around "unlocking bitcoin dormant capital". I assumed there was some major blocker. If not, STX foundation should fund a space race to make this happen.” - Twitter user in response to the lack of bitcoin/lightning capabilities within Hiro wallet

Project Overview What solution are you providing? Who will it serve?

We are providing the Stacks community with the ability to create a Bitcoin and Lighting wallet by default within the Hiro wallet. Users can then execute submarine swaps between Stacks and Bitcoin plus transact in Bitcoin on Stacks dapp/services directly within the Hiro wallet in some use cases for dapps/service that wish to support it.

Scope What are the components or technical specs of the project? What will the final deliverable look like? How will you measure success?

Branch of the Hiro wallet. See the frontend UI we’re already building and testing with now in the screenshots below in the Supporting Materials section. The deliverable will be a fully functional version of the Hiro wallet with Bitcoin and Lightning wallets + LNswap capabilities. After which we will propose the Stacks Foundation/Hiro can support to adopt after testing and review, ideally then the new features and functionality will be adopted in a future release of the Hiro wallet.

We will release all code to be publicly available and provide a fully functional product as evidence of success.

Budget and Milestones What grant amount are you seeking? How long will the project take in hours? If more than 20, please break down the project into milestones, with a clear output (e.g., low-fi mockup, MVP with two features) and include the estimated work hours for each milestone.

Total Grant Request:

M1: Scope of work, deliverables, and grant amount of total. (80 Hours - $7,500)

https://github.com/getAlby/lightning-browser-extension

M2: Scope of work, deliverables, and grant amount of total. (80 Hours - $7,500)

Team Who is building this? What relevant experience do you bring to this project? Are there skills sets you are missing that you are seeking from the community? Please share links to previous work.

Rdodge3: Has been a solutions/systems architect for 7 years across large enterprise environments. Is a cofounder of TRUBIT and is leading the UI/UX design efforts for integrating LNswap functionality within the Hiro wallet. Has worked on previously approved Stacks grants.

pseudozach: creator of LNswap who has many years experience as a software developer and will be working on integrating and testing all additional functionality. He has also worked on previously approved Stacks grants.

4532: A software engineer with 3+ years of experience working for startups, performing front-end/back-end development and data analytics. Been working on integrating LNswap functionality into the Hiro wallet as well as some additional functionality.

Risks What dependencies or obstacles do you anticipate? What contingency plans do you have in place?

The community needs this and strongly wants this to be done. The only risk we really see is the potential for not having enough Lightning liquidity, which is needed to perform the swaps. Any swap service (e.g. even a DEX) faces the challenge of bootstrapping liquidity so that the swap service is usable. Given there is high demand for liquidity and those willing to provide it, we don't believe this will be an issue any time soon. We plan to increase the maximum amount of STX to swap to be above 1,000 STX already and are having talks with others who are interested in providing liquidity to meet potential demand.

Community and Supporting Materials Do you have previous projects, code commits, or experiences that are relevant to this application? What community feedback or input have you received? How do you plan to share your plan to the community over time and as the final deliverable?

https://twitter.com/Rdodge_3/status/1503201629302136838?s=20&t=AZbhDR3uI4g69a3We-0ONQ https://twitter.com/dcsan/status/1503221155817091072?s=20&t=AZbhDR3uI4g69a3We-0ONQ

Here are screenshots of the UI/UX we are working on already. https://drive.google.com/file/d/1Qg7u64h1_qioryG-hAVYbAPig5y0IgH3/view?usp=sharing https://drive.google.com/file/d/1umsDNd6NI9gu02cAukVDHOziC_EcaJeQ/view?usp=sharing

stx-grant-bot[bot] commented 2 years ago

Thanks for submitting a grant proposal. Our team will review your submission and get back to you.

ceramicwhite commented 2 years ago

Loving this and been playing around with the Aggregator last couple days.

Integrate BTC, BTC w/ Lightning, and STX swap with LNswap (using the internal derivation btc address)

So this is or isn't a Neutrino implementation? Because I assumed it wasn't but this comment on the coin type derivation makes me think otherwise.

If it is a full Neutrino wallet, would it make sense to at least offer deriving STX:BTC addresses that don't use the coin_type'? This way people could backup and access their Bitcoin addresses and channels in a standard BTC/LN wallet and not just electrum.

-Integrate Lightning into Hiro wallet to handle submarine swaps STX -> LN (no lightning node)

This is listed in M1 & M2, assuming this will be in the first milestone and just a typo.

How about a M3 that setup a lightning address server for BTC.US?

Huge fan of this proposal and it slashed a couple of the Wishlist grants launching with the new dashboard.

pseudozach commented 2 years ago

Integrate BTC, BTC w/ Lightning, and STX swap with LNswap (using the internal derivation btc address)

So this is or isn't a Neutrino implementation? Because I assumed it wasn't but this comment on the coin type derivation makes me think otherwise.

It's not a neutrino based lightning node. What we're targeting is actually lightning capable wallet in the same sense as Muun. The internal derivation refers to using the btc wallet that each stx account already has to avoid generating additional seed. This integration hopes to deliver integration via lnswap API such that incoming/outgoing Lightning funds are swapped into STX. So no channels/liveness required (after all hiro wallet is a web browser extension.)

-Integrate Lightning into Hiro wallet to handle submarine swaps STX -> LN (no lightning node)

This is listed in M1 & M2, assuming this will be in the first milestone and just a typo.

I do agree we probably need to move WebLN and LNURL support to milestone-2 because currently only stacking support seems to be there. So we'll do base functionality first and then do these use cases.

How about a M3 that setup a lightning address server for BTC.US?

  • Connect your Hiro wallet and the lightning extension
  • Read your BNS
  • Bridge the name@btc.us to your lightning wallet

I love this idea but I see 2 issues with it:

  1. we would need support from btc.us domain such that they should let us implement LUD-16 support.
  2. we would need a way to ping the hiro wallet for preimagehash and I don't see any good way to do this. Here's a bad way to do it.
ceramicwhite commented 2 years ago

Neutrino was the wrong term to use but you answered my question anyways, love it!

I love this idea but I see 2 issues with it:

  1. we would need support from btc.us domain such that they should let us implement LUD-16 support.
  2. we would need a way to ping the hiro wallet for preimagehash and I don't see any good way to do this. Here's a bad way to do it.
  1. I think we could open dialog with Hiro to engage this. More importantly would Hiro have to run a LN Node for the Bolt11 invoices?
  2. Yes, it's not completely trustless as you put faith in the provider to not swap out your invoice for theirs but I still think people would use it, especially if it was managed by a respected entity: Hiro. I trust Hiro as much if not more than the providers already offering this service.

Another thought I had to potentially make it a bit more trustless/transparent to a degree and you are the right person to ask if this makes sense @pseudozach. What if when you initially auth LNUrl from the extension, the initial payRequest was stored in the BNS Zonefile or added to the gaia.blockstack.org/hub/{address}/profile.json, the wallet then uses it for the Pay Callback/Payload?

pseudozach commented 2 years ago
  1. I think we could open dialog with Hiro to engage this. More importantly would Hiro have to run a LN Node for the Bolt11 invoices?

  2. Yes, it's not completely trustless as you put faith in the provider to not swap out your invoice for theirs but I still think people would use it, especially if it was managed by a respected entity: Hiro. I trust Hiro as much if not more than the providers already offering this service.

Agree, this is probably the easy part.

Another thought I had to potentially make it a bit more trustless/transparent to a degree and you are the right person to ask if this makes sense @pseudozach. What if when you initially auth LNUrl from the extension, the initial payRequest was stored in the BNS Zonefile or added to the gaia.blockstack.org/hub/{address}/profile.json, the wallet then uses it for the Pay Callback/Payload?

I like this idea as well specially using gaia but I still don't see how the user of the hiro wallet supposed to generate secrets and share the hashes with lnswap and afterwards know that someone sent funds into these hashes and claim them. I think it's too much. I think we should build this and see if people like it, use it. If enough people demand lightningaddress support I'm sure we can come up with a solution then.

Additional note on LNURL support: We should say we'll support lnurl-pay obviously as part of M-2 and not all LUDs. We can add them later as per demand.

will-corcoran commented 2 years ago

@Regulr3 @pseudozach - I would have approved this sooner, but was busy. lol.

Really, this sounds amazing and I really like to see that @markmhx heart emoji'd it. Mark is the product manager for the Hiro wallet and a great person for you to connect with on this effort. Also worth connecting with @beguene and @kyranjamie - two of the Hiro engineers working on the wallet.

Can you get this done before Bitcoin 2022? (kidding, not kidding)

Best, Will

stx-grant-bot[bot] commented 2 years ago

Congratulations. Your grant is now approved. Please complete the on-boarding link here: https://grants.stacks.org/onboard?q=c38a1101196de2ed97d6da1f470dc9e6

Regulr3 commented 2 years ago

@will-at-stacks thanks!! Haha we will do our best over the next 10 days to get things done.

The initial purpose for building this was to give a demo (among other things) in person to NYDIG at the bitcoin conference.. so stay tuned 😉

kyranjamie commented 2 years ago

Hi everyone, sorry we've been slow to react on this proposal. We're thrilled to see people wanting to contribute to the Hiro Wallet, and love the idea of an LNswap integration 🤝.

The exact nature of the collaboration on the project still needs to be agreed by Hiro. We'll be in touch next week to discuss.

Regulr3 commented 2 years ago

Congratulations. Your grant is now approved. Please complete the on-boarding link here: https://grants.stacks.org/onboard?q=c38a1101196de2ed97d6da1f470dc9e6

Contract signed over weekend, thanks!

markmhendrickson commented 2 years ago

Hi all, it's great to see the initiative for bringing both Bitcoin and Lightning to the Hiro Wallet 💪

My sense is that we'd do well to meet and discuss your plans here in light of our own team's plans (per the wallet roadmap).

We've recently kicked off work for adding Bitcoin support to the wallet, and while we're still early in the design and research phase, it'll be important to avoid any duplicate work and ensure compatibility with this grant.

Meanwhile, we don't have any internal plans to work on Lightning itself. So my sense is that any outside contributions on the Lightning front will be especially unencumbered by our internal planning (though compatibility between Lightning and Bitcoin functionality will be paramount of course).

Mind emailing me at mark@hiro.so so we can schedule a meeting to discuss?

Regulr3 commented 2 years ago

@markmhx @kyranjamie thanks! Just emailed you a couple of minutes ago, happy to set up some time this week to discuss things further! Let me know your thoughts.

pseudozach commented 2 years ago

@markmhx @kyranjamie looks like we can meet only after the conference due to everyone's schedule next week. I wanted to check if there's any prior work done to derive BTC keys from stacks private key or we'll need to put this part on hold until syncing with Hiro team.

markmhendrickson commented 2 years ago

We haven't initiated any work on BTC key derivation yet, though @beguene may have some initial thoughts on how we expect to go about this.

will-corcoran commented 2 years ago

Hello and thank you for participating in the Stacks Foundation Grants Program!

We are in the process of migrating from GitHub to the new Grants Dashboard. In order to complete your grant, you will need to submit any remaining Progress Review and/or Final Review requests through the Dashboard in order to receive your remaining payments.

Lastly, please note we are marking this grant 'closed' on GitHub for organizational purposes, but it is still 'open' on the Grants Dashboard.

Thanks and we hope to continue to support your efforts with additional grants!

Best, Will