Skip to content

Repository files navigation

ln-payments

Full-stack application that enables Lightning Network invoice payments.

  1. overall architecture
  2. deployment
    1. polar configuration
    2. services connfiguration
    3. launch services
  3. development
  4. applications documentation

overall architecture

flowchart LR
  subgraph polar
  receiver
  sender
  end

  api <-->|lnd connection| polar
  api <-->|pg pool| postgres
  frontend <-->|http| api
  postgres[(postgres)] --> adminer
Loading
  • 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.

deployment

polar configuration

Polar is a one-click Bitcoin Lightning networks for local app development & testing. In order to get up and running, follow the above steps:

  1. 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
  1. Create a network with 2 LND and 1 Bitcoin Core.

alt text

  1. Start the network. Can take several minutes to pull Docker images and run them.

alt text

  1. Create a channel between node Bob and Alice.

alt text

  1. Perform a quick mine to verify the network.

alt text

  1. Edit apps/api/.env.example to fit connection data for each node (HEX encoded).

services configuration

Each service has its own .env.example environment file. This examples will work as provided just renaming to .env in the following paths:

Name Description Default
POSTGRES_USER Postgres user name postgres
POSTGRES_PASSWORD Postgres user password postgres-password
POSTGRES_DB Postgres databse name ln-payments
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_SOCKET and network at compose.yaml assigning the correct id to polar-n<id>-bob, polar-n<id>-alice and polar-network-<id>_default respectively. Check can be done executing docker ps and looking for polar sevices.

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.

launch services

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 --build

The access to the frontend using a web browser.

development

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

applications documentation

Please refer to api and frontend README files.

About

Full-stack application that enables Lightning Network invoice payments

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages