diff --git a/README.md b/README.md index c4bdc80..acd73b4 100644 --- a/README.md +++ b/README.md @@ -65,19 +65,28 @@ Required command arguments: For information on all possible arguments to `vlsd` see [documentation](https://gitlab.com/lightning-signer/validating-lightning-signer/-/blob/main/vls-proxy/src/config.rs?ref_type=heads). +### Build Arguments + +For building the container its required to provide following build arguments: +- `VLS_REPO` url for git repo to use for building binaries. +- `VLS_GIT_HASH` commit sha/tag/branch to use from git repo. +- `TXOO_PUBLIC_KEY` public key for trusted TXOO. + ### Running container There is a `docker-compose.yml` in the `vlsd` folder which can be used to run a standalone `vlsd` service with `network_mode` set to host. ```bash cd vlsd +export VLS_REPO=$VLS_REPO export VLS_GIT_HASH=$VLS_GIT_HASH +export TXOO_PUBLIC_KEY=$TXOO_PUBLIC_KEY docker compose up ``` -**_Note_**: Make sure to set `BITCOIND_RPC_URL`, `VLS_GIT_HASH` and `CLN_RMEOTE_HSMD_URL` as either environment variables or in the `docker-compose.yml` file before running the above command. You can take `VLS_GIT_HASH` from [.env](./.env) or from the main [repo](https://gitlab.com/lightning-signer/validating-lightning-signer) +**_Note_**: Make sure to set `BITCOIND_RPC_URL` and `CLN_RMEOTE_HSMD_URL` as either environment variables or in the `docker-compose.yml` file before running the above command. -If you wish to run it as a standalone container without using `docker-compose` you can use the following command: +If you wish to run it as a standalone container without using `docker compose` you can use the following command: ```bash docker run \ @@ -86,6 +95,8 @@ docker run \ --name vlsd \ --network host \ --build_arg VLS_GIT_HASH=$VLS_GIT_HASH + --build_arg VLS_REPO=$VLS_REPO + --build_arg TXOO_PUBLIC_KEY=$TXOO_PUBLIC_KEY -e VLS_NETWORK=testnet \ -e BITCOIND_RPC_URL=$BITCOIND_RPC_URL \ --mount 'type=volume,src=vls_data,dst=/home/vls/.lightning-signer' \ diff --git a/docker-compose.regtest.yml b/docker-compose.regtest.yml index 714449d..237f9ea 100644 --- a/docker-compose.regtest.yml +++ b/docker-compose.regtest.yml @@ -40,6 +40,15 @@ services: - BITCOIN_NETWORK=regtest - BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:38332 + txoo-server: + container_name: txoo-server-regtest + volumes: + - type: volume + source: txoo_regtest + target: /usr/share/nginx/html + volume: + subpath: regtest/public + vls: container_name: vlsd-regtest volumes: diff --git a/docker-compose.yml b/docker-compose.yml index 0c56009..5b45542 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -50,8 +50,11 @@ services: depends_on: bitcoin-core: condition: service_healthy + txoo-server: + condition: service_started environment: - BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:18332 + - TXOO_SOURCE_URL=http://txoo-server:80 - RUST_LOG=info - VLS_NETWORK=testnet - VLS_BIND=0.0.0.0 @@ -78,6 +81,23 @@ services: - BITCOIN_NETWORK=testnet - BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:18332 + txoo-server: + image: nginx:1.27-alpine3.20 + container_name: txoo-server-test + networks: + - lightning + depends_on: + txoo: + condition: service_started + volumes: + - type: volume + source: txoo_data + target: /usr/share/nginx/html + volume: + subpath: testnet/public + ports: + - "8080:80" + lss: build: context: ./lss @@ -109,11 +129,12 @@ services: args: - VLS_REPO - VLS_GIT_HASH + - TXOO_PUBLIC_KEY image: vlsd:${IMAGE_TAG:-latest} container_name: vlsd-test profiles: - vls - command: + command: --log-level=info --connect=http://core-lightning:7701 ${LSS_REMOTE_URL:+--lss=$LSS_REMOTE_URL} @@ -121,15 +142,18 @@ services: - lightning volumes: - vls_data:/home/vls/.lightning-signer + depends_on: + txoo-server: + condition: service_started + lss: + condition: service_started + required: false environment: + - LSS_REMOTE_URL - VLS_NETWORK=testnet - VLS_PERMISSIVE=1 - RUST_LOG=info - BITCOIND_RPC_URL=http://rpcuser:VLSsigner1@bitcoind:18332 - depends_on: - lss: - condition: service_started - required: false volumes: bitcoin_data: diff --git a/lightningd/entrypoint.sh b/lightningd/entrypoint.sh index aa93434..76104b6 100755 --- a/lightningd/entrypoint.sh +++ b/lightningd/entrypoint.sh @@ -4,6 +4,7 @@ set -e cp -u /testnet-config ${LIGHTNINGD_DATA}/testnet-config cp -u /regtest-config ${LIGHTNINGD_DATA}/regtest-config +# this is kept for backward compatibility purposes export GREENLIGHT_VERSION=$(lightningd --version) export VLS_CLN_VERSION=$(lightningd --version) diff --git a/vlsd/Dockerfile b/vlsd/Dockerfile index 933f723..80991ca 100644 --- a/vlsd/Dockerfile +++ b/vlsd/Dockerfile @@ -28,6 +28,8 @@ ARG VLSD_UID=100 \ VLSD_GID=101 \ VLSD_USER=vls ARG VLSD_HOME=/home/${VLSD_USER} +ARG TXOO_PUBLIC_KEY +ENV TXOO_PUBLIC_KEY=${TXOO_PUBLIC_KEY} LABEL maintainer.0="Lakshya Singh (@king-11)" \ maintainer.1="Dev Random (@devrandom01)" @@ -39,6 +41,7 @@ RUN apk update && \ apk add \ build-base \ curl-dev \ + curl \ protobuf \ bind-tools \ tini @@ -58,6 +61,8 @@ ENV VLSD_DATA=/home/vls/.lightning-signer RUN mkdir -p ${VLSD_DATA} && \ chown ${VLSD_USER}:${VLSD_USER} ${VLSD_DATA} +RUN mkdir -p ${VLSD_HOME}/.txoo + ENV REMOTE_SIGNER_ALLOWLIST=${VLSD_DATA}/ALLOWLIST RUN touch ${REMOTE_SIGNER_ALLOWLIST} diff --git a/vlsd/docker-compose.yml b/vlsd/docker-compose.yml index 1bba45e..5c9a30f 100644 --- a/vlsd/docker-compose.yml +++ b/vlsd/docker-compose.yml @@ -5,7 +5,9 @@ services: context: . dockerfile: Dockerfile args: + - VLS_REPO - VLS_GIT_HASH + - TXOO_PUBLIC_KEY image: vlsd container_name: vlsd-standalone command: diff --git a/vlsd/entrypoint.sh b/vlsd/entrypoint.sh index 966d01b..c379bca 100755 --- a/vlsd/entrypoint.sh +++ b/vlsd/entrypoint.sh @@ -4,6 +4,10 @@ set -e cp /vlsd2.toml $VLSD_DATA/ sed -i "1s/^/network = \"$VLS_NETWORK\"\n/" $VLSD_DATA/vlsd2.toml +TXOO_PUBLIC_KEY=${TXOO_PUBLIC_KEY:=$(curl -s --retry 5 --retry-all-errors --fail http://txoo-server:80/config | grep public_key | cut -d ' ' -f 2)} + +test -n "$TXOO_PUBLIC_KEY" || (echo "TXOO_PUBLIC_KEY build arg not set" && false) + if [ $(echo "$1" | cut -c1) = "-" ]; then echo "$0: assuming arguments for vlsd2" @@ -13,7 +17,8 @@ fi if [ $(echo "$1" | cut -c1) = "-" ] || [ "$1" = "vlsd2" ]; then echo "$0: setting config to $VLSD_DATA/vlsd2.toml" - set -- "$@" --config=$VLSD_DATA/vlsd2.toml + echo "$0: using $TXOO_PUBLIC_KEY as trusted oracle pubkey" + set -- "$@" --config=$VLSD_DATA/vlsd2.toml -t=$TXOO_PUBLIC_KEY fi echo