feat: add boltz client client (#20)
* feat: add boltz-client to regtest
This commit is contained in:
parent
a99ef09bb9
commit
970cc2cda2
9 changed files with 176 additions and 12 deletions
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
|
|
@ -9,5 +9,5 @@ jobs:
|
||||||
run: |
|
run: |
|
||||||
git clone https://github.com/lnbits/lnbits.git
|
git clone https://github.com/lnbits/lnbits.git
|
||||||
docker build -t lnbits/lnbits lnbits
|
docker build -t lnbits/lnbits lnbits
|
||||||
chmod +x ./tests
|
chmod +x ./start-regtest
|
||||||
./tests
|
./start-regtest
|
||||||
|
|
|
||||||
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -1,7 +1,13 @@
|
||||||
data
|
data
|
||||||
|
|
||||||
!data/boltz
|
!data/boltz
|
||||||
data/boltz/*
|
data/boltz/*
|
||||||
!data/boltz/boltz.conf
|
!data/boltz/boltz.conf
|
||||||
|
|
||||||
|
!data/boltz-client
|
||||||
|
data/boltz-client/*
|
||||||
|
!data/boltz-client/boltz.toml
|
||||||
|
|
||||||
!data/electrs
|
!data/electrs
|
||||||
data/electrs/*
|
data/electrs/*
|
||||||
!data/electrs/config.toml
|
!data/electrs/config.toml
|
||||||
|
|
|
||||||
10
README.md
10
README.md
|
|
@ -22,8 +22,8 @@ docker build -t lnbits/lnbits .
|
||||||
mkdir docker
|
mkdir docker
|
||||||
git clone https://github.com/lnbits/legend-regtest-enviroment.git docker
|
git clone https://github.com/lnbits/legend-regtest-enviroment.git docker
|
||||||
cd docker
|
cd docker
|
||||||
chmod +x ./tests
|
chmod +x ./start-regtest
|
||||||
./tests # start the regtest and also run tests
|
./start-regtest # start the regtest and also run tests
|
||||||
sudo chown -R $USER ./data # Give the data file permissions for user
|
sudo chown -R $USER ./data # Give the data file permissions for user
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
@ -52,10 +52,10 @@ make dev
|
||||||
|
|
||||||
# testing
|
# testing
|
||||||
```sh
|
```sh
|
||||||
chmod +x ./tests
|
chmod +x ./start-regtest
|
||||||
./tests
|
./start-regtest
|
||||||
# short answer :)
|
# short answer :)
|
||||||
./tests && echo "PASSED" || echo "FAILED" > /dev/null
|
./start-regtest && echo "PASSED" || echo "FAILED" > /dev/null
|
||||||
```
|
```
|
||||||
|
|
||||||
usage of the `bitcoin-cli-sim`, `lightning-cli-sim` and `lncli-sim` aliases
|
usage of the `bitcoin-cli-sim`, `lightning-cli-sim` and `lncli-sim` aliases
|
||||||
|
|
|
||||||
49
data/boltz-client/boltz.toml
Normal file
49
data/boltz-client/boltz.toml
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
standalone = true
|
||||||
|
network = "regtest"
|
||||||
|
|
||||||
|
# Path the the log file
|
||||||
|
logfile = ""
|
||||||
|
|
||||||
|
electrumUrl = "electrs:19001"
|
||||||
|
electrumLiquidUrl = "electrs-liquid:19002"
|
||||||
|
|
||||||
|
[BOLTZ]
|
||||||
|
# By default the daemon automatically connects to the official Boltz instance for the network LND is on
|
||||||
|
# This value is used to override that
|
||||||
|
url = "http://boltz-nginx:9001"
|
||||||
|
|
||||||
|
[DATABASE]
|
||||||
|
# Path to the SQLite database file
|
||||||
|
# path = "/home/michael/test.db"
|
||||||
|
|
||||||
|
[RPC]
|
||||||
|
# Host of
|
||||||
|
host = "0.0.0.0"
|
||||||
|
|
||||||
|
# Port of the gRPC interface
|
||||||
|
port = 9002
|
||||||
|
|
||||||
|
# Whether the REST proxy for the gRPC interface should be disabled
|
||||||
|
restDisabled = false
|
||||||
|
|
||||||
|
# Host of the REST proxy
|
||||||
|
restHost = "0.0.0.0"
|
||||||
|
|
||||||
|
# Port of the REST proxy
|
||||||
|
restPort = 9003
|
||||||
|
|
||||||
|
# Path to the TLS cert for the gRPC and REST interface
|
||||||
|
tlsCert = ""
|
||||||
|
|
||||||
|
# Path to the TLS private key for the gRPC and REST interface
|
||||||
|
tlsKey = ""
|
||||||
|
noTls = true
|
||||||
|
|
||||||
|
# Whether the macaroon authentication for the gRPC and REST interface should be disabled
|
||||||
|
noMacaroons = true
|
||||||
|
|
||||||
|
# Path to the admin macaroon for the gRPC and REST interface
|
||||||
|
adminMacaroonPath = ""
|
||||||
|
|
||||||
|
# Path to the read only macaroon for the gRPC and REST interface
|
||||||
|
readOnlyMacaroonPath = ""
|
||||||
49
data/boltz-nginx/default.conf
Normal file
49
data/boltz-nginx/default.conf
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
upstream boltz {
|
||||||
|
server boltz:9001;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream boltzr {
|
||||||
|
server boltz:9005;
|
||||||
|
}
|
||||||
|
|
||||||
|
upstream ws {
|
||||||
|
server boltz:9004;
|
||||||
|
}
|
||||||
|
|
||||||
|
server {
|
||||||
|
listen 9001;
|
||||||
|
listen [::]:9001;
|
||||||
|
server_name localhost;
|
||||||
|
|
||||||
|
add_header Access-Control-Allow-Origin "*" always;
|
||||||
|
add_header Access-Control-Allow-Methods 'GET, PATCH, DELETE, POST, OPTIONS' always;
|
||||||
|
add_header Access-Control-Allow-Headers "*" always;
|
||||||
|
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
|
||||||
|
if ($request_method = OPTIONS) {
|
||||||
|
return 204;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /v2/ws {
|
||||||
|
proxy_pass http://ws/;
|
||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header Connection "Upgrade";
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ ^/v2/(lightning|swap/rescue|swap/restore) {
|
||||||
|
proxy_pass http://boltzr;
|
||||||
|
}
|
||||||
|
|
||||||
|
location /streamswapstatus {
|
||||||
|
proxy_pass http://boltzr;
|
||||||
|
}
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://boltz;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
[api]
|
[api]
|
||||||
host = "boltz"
|
host = "0.0.0.0"
|
||||||
port = 9_001
|
port = 9_001
|
||||||
|
|
||||||
[grpc]
|
[grpc]
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ services:
|
||||||
image: boltz/boltz:latest
|
image: boltz/boltz:latest
|
||||||
ports:
|
ports:
|
||||||
- 9000:9000
|
- 9000:9000
|
||||||
- 9001:9001
|
|
||||||
entrypoint: "sh -c 'sleep 30; /boltz-backend/bin/boltzd'"
|
entrypoint: "sh -c 'sleep 30; /boltz-backend/bin/boltzd'"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/lnd-2:/data/lnd/
|
- ./data/lnd-2:/data/lnd/
|
||||||
|
|
@ -39,6 +38,42 @@ services:
|
||||||
- elements-data:/root/.elements
|
- elements-data:/root/.elements
|
||||||
- bitcoin-data:/root/.bitcoin
|
- bitcoin-data:/root/.bitcoin
|
||||||
|
|
||||||
|
boltz-client:
|
||||||
|
hostname: boltz-client
|
||||||
|
depends_on:
|
||||||
|
- boltz
|
||||||
|
restart: always
|
||||||
|
image: boltz/boltz-client:latest
|
||||||
|
ports:
|
||||||
|
- 9002:9002
|
||||||
|
- 9003:9003
|
||||||
|
expose:
|
||||||
|
- 9002
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD', 'boltzcli', '--host', 'boltz-client', 'getinfo']
|
||||||
|
interval: 5s
|
||||||
|
timeout: 3s
|
||||||
|
retries: 10
|
||||||
|
start_period: 0s
|
||||||
|
volumes:
|
||||||
|
- elements-data:/root/.elements
|
||||||
|
- ./data/boltz-client:/root/.boltz
|
||||||
|
|
||||||
|
boltz-backend-nginx:
|
||||||
|
hostname: boltz-nginx
|
||||||
|
restart: always
|
||||||
|
image: nginx:latest
|
||||||
|
ports:
|
||||||
|
- 9001:9001
|
||||||
|
volumes:
|
||||||
|
- nginx-data:/etc/nginx/conf.d
|
||||||
|
healthcheck:
|
||||||
|
test: ['CMD-SHELL', 'curl http://localhost:9001/version']
|
||||||
|
timeout: 1s
|
||||||
|
retries: 10
|
||||||
|
interval: 1s
|
||||||
|
start_period: 0s
|
||||||
|
|
||||||
boltz-postgres:
|
boltz-postgres:
|
||||||
hostname: boltz-postgres
|
hostname: boltz-postgres
|
||||||
restart: always
|
restart: always
|
||||||
|
|
@ -53,8 +88,6 @@ services:
|
||||||
- POSTGRES_DB=boltz
|
- POSTGRES_DB=boltz
|
||||||
- POSTGRES_USER=boltz
|
- POSTGRES_USER=boltz
|
||||||
- POSTGRES_PASSWORD=boltz
|
- POSTGRES_PASSWORD=boltz
|
||||||
ports:
|
|
||||||
- 5432:5432
|
|
||||||
expose:
|
expose:
|
||||||
- 5432
|
- 5432
|
||||||
|
|
||||||
|
|
@ -392,3 +425,10 @@ volumes:
|
||||||
lnbits-data:
|
lnbits-data:
|
||||||
bitcoin-data:
|
bitcoin-data:
|
||||||
elements-data:
|
elements-data:
|
||||||
|
nginx-data:
|
||||||
|
name: nginx-data
|
||||||
|
driver: local
|
||||||
|
driver_opts:
|
||||||
|
type: none
|
||||||
|
o: bind
|
||||||
|
device: ./data/boltz-nginx/
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,10 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
export COMPOSE_PROJECT_NAME=lnbits
|
export COMPOSE_PROJECT_NAME=lnbits
|
||||||
|
|
||||||
|
boltzcli-sim() {
|
||||||
|
docker exec -it lnbits-boltz-client-1 boltzcli "$@"
|
||||||
|
}
|
||||||
|
|
||||||
bitcoin-cli-sim() {
|
bitcoin-cli-sim() {
|
||||||
docker exec lnbits-bitcoind-1 bitcoin-cli -regtest "$@"
|
docker exec lnbits-bitcoind-1 bitcoin-cli -regtest "$@"
|
||||||
}
|
}
|
||||||
|
|
@ -47,6 +51,14 @@ wait-for-eclair-channel() {
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# args(i)
|
||||||
|
fund_boltz_client() {
|
||||||
|
# first address of seed: abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about
|
||||||
|
address="el1qq2xvpcvfup5j8zscjq05u2wxxjcyewk7979f3mmz5l7uw5pqmx6xf5xy50hsn6vhkm5euwt72x878eq6zxx2z0z676mna6kdq"
|
||||||
|
echo "funding: $address on boltz-client"
|
||||||
|
elements-cli-sim -named sendtoaddress address=$address amount=30 fee_rate=100 > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# args(i)
|
# args(i)
|
||||||
fund_clightning_node() {
|
fund_clightning_node() {
|
||||||
|
|
@ -98,7 +110,7 @@ lnbits-regtest-start-log(){
|
||||||
lnbits-regtest-stop(){
|
lnbits-regtest-stop(){
|
||||||
docker compose down --volumes
|
docker compose down --volumes
|
||||||
# clean up lightning node data
|
# clean up lightning node data
|
||||||
sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 ./data/lnd-4 ./data/boltz/boltz.db ./data/eclair/regtest
|
sudo rm -rf ./data/clightning-1 ./data/clightning-2 ./data/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 ./data/lnd-4 ./data/boltz/boltz.db ./data/eclair/regtest ./data/boltz-client/liquid-wallet ./data/boltz-client/bitcoin-wallet ./data/boltz-client/wallet ./data/boltz-client/boltz.db
|
||||||
# recreate lightning node data folders preventing permission errors
|
# recreate lightning node data folders preventing permission errors
|
||||||
mkdir ./data/clightning-1 ./data/clightning-2 ./data/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 ./data/lnd-4
|
mkdir ./data/clightning-1 ./data/clightning-2 ./data/clightning-3 ./data/lnd-1 ./data/lnd-2 ./data/lnd-3 ./data/lnd-4
|
||||||
}
|
}
|
||||||
|
|
@ -108,6 +120,13 @@ lnbits-regtest-restart(){
|
||||||
lnbits-regtest-start
|
lnbits-regtest-start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boltz-client-init(){
|
||||||
|
for i in 0 1 2; do
|
||||||
|
fund_boltz_client
|
||||||
|
done
|
||||||
|
elements-cli-sim -generate 3 > /dev/null
|
||||||
|
}
|
||||||
|
|
||||||
lnbits-bitcoin-init(){
|
lnbits-bitcoin-init(){
|
||||||
echo "init_bitcoin_wallet..."
|
echo "init_bitcoin_wallet..."
|
||||||
bitcoin-cli-sim createwallet lnbits || bitcoin-cli-sim loadwallet lnbits
|
bitcoin-cli-sim createwallet lnbits || bitcoin-cli-sim loadwallet lnbits
|
||||||
|
|
@ -133,6 +152,7 @@ lnbits-regtest-init(){
|
||||||
lnbits-elements-init
|
lnbits-elements-init
|
||||||
lnbits-lightning-sync
|
lnbits-lightning-sync
|
||||||
lnbits-lightning-init
|
lnbits-lightning-init
|
||||||
|
boltz-client-init
|
||||||
lnbits-init
|
lnbits-init
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue