Skip to content

WIP: implementation lightning network app#6320

Closed
Totenfluch wants to merge 10 commits intocalcom:mainfrom
Blockcurators:5703-cal-458-lightning-network-app
Closed

WIP: implementation lightning network app#6320
Totenfluch wants to merge 10 commits intocalcom:mainfrom
Blockcurators:5703-cal-458-lightning-network-app

Conversation

@Totenfluch
Copy link
Copy Markdown

What does this PR do?

Implementation of Bitcoin Lightning as Plugin

Environment: Production

Type of change

  • New feature (non-breaking change which adds functionality)

How should this be tested?

  • Create a Lightning Wallet and obtain a LN Name or LN URL
  • Insert the LN Name / LN URL into the App Config
  • Activate the Plugin for a Booking
  • Book a meeting
  • Check if sats were received after booking

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't performed a self-review of my own code and corrected any misspellings
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my PR needs changes to the documentation
  • I haven't checked if my changes generate no new warnings
  • I haven't added tests that prove my fix is effective or that my feature works
  • I haven't checked if new and existing unit tests pass locally with my changes

@vercel
Copy link
Copy Markdown

vercel bot commented Jan 7, 2023

@Totenfluch is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@Totenfluch Totenfluch changed the title 5703 cal 458 lightning network app implementation lightning network app Jan 7, 2023
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
cal ❌ Failed (Inspect) May 22, 2023 3:57pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
ui ⬜️ Ignored (Inspect) Visit Preview May 22, 2023 3:57pm

@Totenfluch Totenfluch changed the title implementation lightning network app WIP: implementation lightning network app Jan 7, 2023
"categories": ["payment"],
"publisher": "CoinKit",
"email": "support@coinkit.de",
"description": "Accept Bitcoin with Lightning. The Lightning Network is a layer 2 payment protocol that operates on top of Bitcoin. It is designed to enable fast and cheap transactions between participating nodes by creating a network of bi-directional payment channels that allow users to conduct multiple transactions without committing each one to the blockchain.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "Accept Bitcoin with Lightning. The Lightning Network is a layer 2 payment protocol that operates on top of Bitcoin. It is designed to enable fast and cheap transactions between participating nodes by creating a network of bi-directional payment channels that allow users to conduct multiple transactions without committing each one to the blockchain.",
"description": "Accept Bitcoin with Lightning",

"name": "@calcom/bitcoin",
"version": "0.0.0",
"main": "./index.ts",
"description": "Accept Bitcoin with Lightning. The Lightning Network is a layer 2 payment protocol that operates on top of Bitcoin. It is designed to enable fast and cheap transactions between participating nodes by creating a network of bi-directional payment channels that allow users to conduct multiple transactions without committing each one to the blockchain.",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"description": "Accept Bitcoin with Lightning. The Lightning Network is a layer 2 payment protocol that operates on top of Bitcoin. It is designed to enable fast and cheap transactions between participating nodes by creating a network of bi-directional payment channels that allow users to conduct multiple transactions without committing each one to the blockchain.",
"description": "Accept Bitcoin with Lightning",

@Totenfluch
Copy link
Copy Markdown
Author

Missing things:

  • How to display the QR Code (lightning payment) to the client on the frontend side; which file needs to be created/edited for it
  • How to display the price to the client in the frontend and which currency to use
  • How to fetch the app settings that were created after the installation and in which file should the invoice be created?

After those, I think it's complete

@PeerRich
Copy link
Copy Markdown
Member

PeerRich commented Jan 7, 2023

Missing things:

How to display the QR Code (lightning payment) to the client on the frontend side; which file needs to be created/edited for it
How to display the price to the client in the frontend and which currency to use
How to fetch the app settings that were created after the installation and in which file should the invoice be created?
After those, I think it's complete

@zomars can help and answer those in your upcoming call 🙏

we may add a PaymentGate abstraction as well, maybe not in this PR but pretty soon to make it easier to add more payment methods (Razorpay, PayPal, ...) in the future

@alannnc
Copy link
Copy Markdown
Contributor

alannnc commented Feb 8, 2023

@Totenfluch
We just finished implementing a PaymentService class and this should help with the adoption of new payment methods. Still not live on production but should be accesible from main branch.
Basically we use a base Class so any new payment provider should follow.
https://github.com/calcom/cal.com/blob/main/packages/lib/PaymentService.ts
If payment service requires to show custom UI element or redirect you should be able to achieve this now.
I'll leave you my link if you require more info -> https://app.cal.com/alan/15min

Or if you require help updating this PR do let me know!

@Totenfluch
Copy link
Copy Markdown
Author

Totenfluch commented Feb 19, 2023

@alannnc

I have implemented it was far as I could and have added comments in the PaymentService.ts when something was unclear or seemed unfinished to me. I have also booked a timeslot with you, thanks for the opportunity!

Things that are missing:

  • Correctly import the App Config that is created by the user in the server file so we can create payments
  • importing the lightning decoder dependency with turbo
  • Update the Payment, when the user has paid the invoice. The checking code is in there but I don't get the flow. The related rethink payment flows PR is probably the reason for this
  • getPaymentPaidStatus and getPaymentDetails are missing parameters or I'm missing that they are actually stateful but it doesn't seem like it
  • Does the link in paymentInfo display to the frontend?
  • the Infrastruture for the ln-gateway that is currently hosted by us should be migrated to your servers once the PoC is complete
  • (support for LNURL, probably not in this PoC)

@PeerRich
Copy link
Copy Markdown
Member

thank you for the update! anything we can help with? Those open points sound like something our core team doesn't know much about yet

@Totenfluch
Copy link
Copy Markdown
Author

@PeerRich

Things your Team can help me with:

  • Understand the internal storage of the app credentials better. I think I have implemented it correctly but as there is no documentation, I'm unsure
  • How are new imports added to the project? It seems like a library called "turbo" is used in your project which changes the way new imports are added to the project. As I don't want to break anything here, the team should be able to help

Things that I think still need to be worked on from your side to make this PR possible:

  • Update the Payment, when the user has paid the invoice. I implemented the flow for the Lightning invoice how I think it should work but this is unclear to me as it is not implemented in the stripe file. The related rethink payment flows PR is probably the reason for this
  • getPaymentPaidStatus and getPaymentDetails are missing parameters or I'm missing that they are actually stateful but it doesn't seem like it. Basically the function signature needs to be "async getPaymentPaidStatus(paymentId: Payment["id"]) : Promise" but it is "getPaymentPaidStatus(): Promise". Same for getPaymentDetails.
  • It is unclear, how the frontend can be changed and which parameters are responsible for the frontend. I could dig deep into the code here but I don't think it would be very useful for me to do so

Things we should discuss after this PoC works:

  • the Infrastruture for the ln-gateway that is currently hosted by us should be migrated to your servers
  • support for LNURL and other lightning features

@PeerRich
Copy link
Copy Markdown
Member

whats missing for this to leave draft? I wonder if we can merge this in an MVP stage and manually confirm payments

@PeerRich PeerRich marked this pull request as ready for review May 22, 2023 15:48
@PeerRich
Copy link
Copy Markdown
Member

also the branch seems to be locked, I don't think I can update it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants