bleskomat / ln-developer-environment-workshop

MIT License
1 stars 1 forks source link

Lightning Network Development Environment From Reckless to Professional

In this workshop we will discuss the evolution of the Lightning Network (LN) development ecosystem - from the recent reckless past to the (hopefully) more secure and stable future. We will demonstrate how to achieve a development environment that is reproducible, testable, portable, and reliable.

As a practical example, we have decided to create a simple Lightning Service Provider implementation, loosely following the LSP Specification. As a proof-of-concept, we start with the LSPS1 channel opening request. Additional services to be implemented could include LSPS2 JIT (Just-In-Time) channel openings (a.k.a. turbo channels), and submarine swap-in/out as implemented by the Boltz exchange.

The LSP server implementation is written in nodejs and acts as a JSON-RPC over HTTP API. The mocha automated test framework is used to define our tests. The scaling-lightning CLI tool is used to create and destroy local Bitcoin and LN nodes as well as perform a few administrative commands. Mocks can be quick and easy for unit testing but in this workshop we wanted to demonstrate how to test software with actual LN nodes.

Achieving Professional Development Goals

To achieve professional development efficiently and effectively, several key objectives need to be met:

Available Tools

Polar Demonstration Steps

  1. Create a network
  2. Adding peer
  3. Wallet Balance Verification
  4. Obtaining Funds into the Wallet: "lncli newaddress p2wkh"
  5. Manual Channel Opening
  6. Scripted Channel Opening (test/manual/index.js)
  7. Bolt11 invoice Payment

Architecture Overview

The following diagram illustrates the architecture of the scaling-lightning project - see its documentation for more details:

Requirements

Setup

Be sure that you have all requirements before continuing.

Install project dependencies locally:

npm ci

Start your local Kubernetes cluster with minikube:

minikube start

Check that the file ~/.kube/config exists and that your current user has permissions to read it:

cat ~/.kube/config > /dev/null

Check that kubectl is able to communicate with the Kubernetes cluster:

kubectl -n simple-network get pods

Run the minikube tunnel so that traefik can connect to the load balancer services:

minikube tunnel

More information can be found here and here.

Be sure the scaling-lightning binary is available on your current user's PATH:

scaling-lightning --version

Create a local lightning network:

scaling-lightning create -f ./test/fixtures/helmfiles/simple-network.yaml

Use --debug argument to output log messages for any scaling-lightning commands.

Tests

To run the automated test suite:

npm test

Run with debug output:

DEBUG=workshop:* npm test

To run the tests without the network setup/teardown:

WORKSHOP_TEST_SKIP_NETWORK_SETUP=1 npm test

With debug output:

DEBUG=workshop:* WORKSHOP_TEST_SKIP_NETWORK_SETUP=1 npm test

Additional Resources and Tools