Full-stack application that enables Lightning Network invoice payments.
flowchart LR
subgraph polar
receiver
sender
end
api <-->|lnd connection| polar
api <-->|pg pool| postgres
frontend <-->|http| api
postgres[(postgres)] --> adminer
- Polar - One-click Bitcoin Lightning networks for local app development & testing.
- api - RESTful API to connect to Lightning nodes.
- frontend - React + Vite UI to interact with LN payments.
- postgres - Relational database to persist LN transactions.
- adminer - Database management.
Polar is a one-click Bitcoin Lightning networks for local app development & testing. In order to get up and running, follow the above steps:
- Download and install Polar in the official site. For Unix-like machines that can execute
AppImages, download and execute:
chmod u+x /path/to/polar-linux-x86_64-v4.0.0.AppImag
./path/to/polar-linux-x86_64-v4.0.0.AppImag- Create a network with 2 LND and 1 Bitcoin Core.
- Start the network. Can take several minutes to pull Docker images and run them.
- Create a channel between node Bob and Alice.
- Perform a quick mine to verify the network.
- Edit
apps/api/.env.exampleto fit connection data for each node (HEX encoded).
Each service has its own .env.example environment file. This examples will work as provided just renaming to .env in the following paths:
.env.example- Postgres creation variables.
| Name | Description | Default |
|---|---|---|
| POSTGRES_USER | Postgres user name | postgres |
| POSTGRES_PASSWORD | Postgres user password | postgres-password |
| POSTGRES_DB | Postgres databse name | ln-payments |
apps/api/.env.example- Please refer to api README.
| Name | Description | Default |
|---|---|---|
| RECEIVER_SOCKET | Receiver URL | polar-n1-bob:10009 |
| RECEIVER_CERT | Receiver HEX encoded TLS cert | Some TLS cert |
| RECEIVER_MACAROON | Receiver HEX encoded admin macaroon | Some admin macaroon |
| RECEIVER_PUBLIC_KEY | Receiver public key | Some public key |
| SENDER_SOCKET | Sender URL | polar-n1-alice:10009 |
| SENDER_CERT | Sender HEX encoded TLS cert | Some TLS cert |
| SENDER_MACAROON | Sender HEX encoded admin macaroon | Some admin macaroon |
| SENDER_PUBLIC_KEY | Sender public key | Some public key |
| POSTGRES_HOST | Postgre host to connect with | postgres |
| UI_PORT | UI listen port to enable socket.io CORS | 4000 |
Note: above hostnames are resolved internally to the attached Docker network. If yoy have any other Polar network running minor changes will be required to fit
RECEIVER_SOCKET,SENDER_SOCKETand network at compose.yaml assigning the correctidtopolar-n<id>-bob,polar-n<id>-aliceandpolar-network-<id>_defaultrespectively. Check can be done executingdocker psand looking for polar sevices.
apps/frontend/.env.example- Please refer to frontend README.
| Name | Description | Default |
|---|---|---|
| VITE_API_URL | api service URL | http://api:3000 |
| VITE_EMITTER_SOCKET | invoice emitter URL | polar-n1-bob:10009 |
| VITE_EMITTER_CERT | invoice emitter HEX TLS cert | some hex string |
| VITE_EMITTER_MACAROON | invoice emitter HEX admin macaroon | some hex string |
| VITE_PAYER_SOCKET | invoice payer URL | polar-n1-alice:10009 |
| VITE_PAYER_CERT | invoice payer HEX TLS cert | some hex string |
| VITE_PAYER_MACAROON | invoice payer HEX admin macaroon | some hex string |
Please, modify to fit your needs.
To launch services launch compose file:
cp .env.example .env
cp apps/api/.env.example apps/api/.env
cp apps/frontend/.env.example apps/frontend/.env
docker compose up -d --buildThe access to the frontend using a web browser.
Even not necessary for Dockerized deployments, some dependencies are needed for development purpose:
Applications can be deployed for development purposes as follows:
npm i
# serve api
nx serve api
# serve frontend
nx serve frontend


