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.
To achieve professional development efficiently and effectively, several key objectives need to be met:
- Quick Start: Getting up and running quickly is essential.
- Reproducibility: Ensuring that processes are replicable and consistent is crucial.
- Real LN Node Operation: Utilizing actual Lightning Network nodes for realistic testing and development.
- Regtest Bitcoin: Employing a Bitcoin regtest environment for controlled testing.
- Compatibility with Continuous Integration (CI): Ability to integrate into automated CI pipelines.
- "#Reckless" ⚡
- Direct usage of the mainnet network for experimentation.
- While risky, it can sometimes provide valuable insights.
- Polar
- Highly intuitive interface.
- Provides a user-friendly environment for quick startup.
- As one of the earliest LN development tools, it continues to be actively maintained.
- simLN
- Simulates payment activities across various test networks.
- Generates randomized activity based on network topology.
- Useful for stress-testing Lightning-enabled applications in liquidity-constrained scenarios.
- warnet
- Establishes a Bitcoin network with specified nodes interconnections.
- While primarily focused on Bitcoin Core testing, it also supports Lightning functionality.
- Scaling Lightning
- A comprehensive testing toolkit for evaluating the Lightning Network protocol.
- Facilitates network replication among developers using a network file.
- Features suitable for automated end-to-end testing, making it suitable for CI integration.
- Create a network
- Adding peer
- Wallet Balance Verification
- Obtaining Funds into the Wallet: "lncli newaddress p2wkh"
- Manual Channel Opening
- Scripted Channel Opening (test/manual/index.js)
- Bolt11 invoice Payment
The following diagram illustrates the architecture of the scaling-lightning project - see its documentation for more details:
- nodejs
- scaling-lightning which has the following requirements:
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.
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