This sample application serves as a guide to begin learning how to communicate with an LND node to send and receive payments over the Lightning Network.
The goal of this guide is to get you familiar with adding payments functionality to your
app using the lnd
Lightning Network node software.
This application will be written in Typescript with a small amount of HTML+CSS. On the frontend we will use ReactJS to render the UI and mobx for managing the application state. On the backend we will use expressjs to host our API server and serve the app's data to multiple web clients.
To easily create a local Lightning Network, which exists solely on your computer, we will be using the Polar development tool.
We'll be making use of the LND gRPC API to interface with the LND node. A few of the API endpoints that we will be using throughout this application are:
Endpoint | Description |
---|---|
getinfo |
returns general information concerning the lightning node |
channelbalance |
returns the total funds available across all open channels in satoshis |
signmessage |
signs a message with this node's private key |
verifymessage |
verifies a signature of a message |
addinvoice |
creates a new invoice which can be used by another node to send a payment |
lookupinvoice |
look up an invoice according to its payment hash |
The sample app we'll be starting with is a basic Reddit clone with this small list of features:
- view a list of posts on the home page sorted by votes
- click on the Upvote button for a post should increment its number of votes
- create a post containing a username, title, and description
We'll add Lightning Network integration in this tutorial by implementing the following features:
- connect your node to the app by providing your node's host, certificate and macaroon
- display your node's alias and channel balance
- create posts and sign them using your LND node's pubkey
- verify posts made by other users
- up-vote a post by paying 100 satoshis per vote
Requirements: NodeJS v12.x & Yarn v1.x
Clone the repo
git clone https://github.com/lightninglabs/builders-guide-sample-app.git
Install dependencies
cd builders-guide-sample-app
yarn
Start the API server and client app development server
yarn dev
Open your browser and navigate to http://localhost:3000
.