From 24d3cf5c72c572976a7361aa587f3506af4577a9 Mon Sep 17 00:00:00 2001 From: d11n Date: Wed, 20 Dec 2023 11:12:52 +0100 Subject: [PATCH] JoinMarket: Upgrade to v0.9.10 (#76) This uses their new install method with the `--docker-install` flag, which obsoletes the jmvenv. --- JoinMarket/0.9.10/autostart | 7 +++ JoinMarket/0.9.10/docker-entrypoint.sh | 59 ++++++++++++++++++ JoinMarket/0.9.10/exec-wrapper.sh | 27 +++++++++ JoinMarket/0.9.10/linuxamd64.Dockerfile | 44 ++++++++++++++ JoinMarket/0.9.10/linuxarm32v7.Dockerfile | 60 +++++++++++++++++++ JoinMarket/0.9.10/linuxarm64v8.Dockerfile | 48 +++++++++++++++ JoinMarket/0.9.10/set-wallet.sh | 11 ++++ .../0.9.10/supervisor-conf/jmwalletd.conf | 11 ++++ .../0.9.10/supervisor-conf/ob-watcher.conf | 10 ++++ .../0.9.10/supervisor-conf/supervisord.conf | 2 + .../supervisor-conf/yg-privacyenhanced.conf | 10 ++++ .../yield-generator-basic.conf | 10 ++++ 12 files changed, 299 insertions(+) create mode 100644 JoinMarket/0.9.10/autostart create mode 100755 JoinMarket/0.9.10/docker-entrypoint.sh create mode 100755 JoinMarket/0.9.10/exec-wrapper.sh create mode 100644 JoinMarket/0.9.10/linuxamd64.Dockerfile create mode 100644 JoinMarket/0.9.10/linuxarm32v7.Dockerfile create mode 100644 JoinMarket/0.9.10/linuxarm64v8.Dockerfile create mode 100755 JoinMarket/0.9.10/set-wallet.sh create mode 100644 JoinMarket/0.9.10/supervisor-conf/jmwalletd.conf create mode 100644 JoinMarket/0.9.10/supervisor-conf/ob-watcher.conf create mode 100644 JoinMarket/0.9.10/supervisor-conf/supervisord.conf create mode 100644 JoinMarket/0.9.10/supervisor-conf/yg-privacyenhanced.conf create mode 100644 JoinMarket/0.9.10/supervisor-conf/yield-generator-basic.conf diff --git a/JoinMarket/0.9.10/autostart b/JoinMarket/0.9.10/autostart new file mode 100644 index 0000000..bb5010b --- /dev/null +++ b/JoinMarket/0.9.10/autostart @@ -0,0 +1,7 @@ +# Remove comments in from of the service you want to automatically restart +# when the container restart. + +# yg-privacyenhanced +# yield-generator-basic +jmwalletd +ob-watcher diff --git a/JoinMarket/0.9.10/docker-entrypoint.sh b/JoinMarket/0.9.10/docker-entrypoint.sh new file mode 100755 index 0000000..24c8d47 --- /dev/null +++ b/JoinMarket/0.9.10/docker-entrypoint.sh @@ -0,0 +1,59 @@ +#!/bin/bash +set -e + +cd /src/scripts + +export JM_onion_serving_host="$(/sbin/ip route|awk '/src/ { print $9 }')" + +# First we restore the default cfg as created by wallet-tool.py generate +if ! [ -f "$CONFIG" ]; then + cp "$DEFAULT_CONFIG" "$CONFIG" +fi + +if ! [ -f "$AUTO_START" ]; then + cp "$DEFAULT_AUTO_START" "$AUTO_START" +fi + +# generate ssl certificates for jmwalletd +if ! [ -f "${DATADIR}/ssl/key.pem" ]; then + subj="/C=US/ST=Utah/L=Lehi/O=Your Company, Inc./OU=IT/CN=example.com" + mkdir -p "${DATADIR}/ssl/" \ + && pushd "$_" \ + && openssl req -newkey rsa:4096 -x509 -sha256 -days 3650 -nodes -out cert.pem -keyout key.pem -subj "$subj" \ + && popd +fi + +# ensure 'logs' directory exists +mkdir -p "${DATADIR}/logs" + +# auto start services +while read p; do + [[ "$p" == "" ]] && continue + [[ "$p" == "#"* ]] && continue + echo "Auto start: $p" + file_path="/etc/supervisor/conf.d/$p.conf" + if [ -f "$file_path" ]; then + sed -i 's/autostart=false/autostart=true/g' $file_path + else + echo "$file_path not found" + fi +done <$AUTO_START + +# For every env variable JM_FOO=BAR, replace the default configuration value of 'foo' by 'BAR' +while IFS='=' read -r -d '' envkey parsedval; do + n="${envkey,,}" # lowercase + if [[ "$n" = jm_* ]]; then + v=${!envkey} # reread environment variable - characters might have been dropped (e.g 'ending in =') + n="${n:3}" # drop jm_ + sed -i "s/^$n =.*/$n = $v/g" "$CONFIG" || echo "Couldn't set : $n = $v, please modify $CONFIG manually" + fi +done < <(env -0) +##################################### + +if [[ "${READY_FILE}" ]]; then + echo "Waiting $READY_FILE to be created..." + while [ ! -f "$READY_FILE" ]; do sleep 1; done + echo "The chain is fully synched" +fi + +exec supervisord diff --git a/JoinMarket/0.9.10/exec-wrapper.sh b/JoinMarket/0.9.10/exec-wrapper.sh new file mode 100755 index 0000000..2869f4c --- /dev/null +++ b/JoinMarket/0.9.10/exec-wrapper.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -e + +cd /src + +if [[ "$1" == "unlockwallet" ]]; then + shift 1 + if ! [ -f "${ENV_FILE}" ]; then + echo "You need to initialize the wallet. + jm.sh wallet-tool-generate + jm.sh set-wallet " + exit 1 + fi + export $(cat "$ENV_FILE" | xargs) + if [[ "$1" == "nopass" ]]; then + shift 1 + COMMAND="$1" + shift 1 + $COMMAND "${WALLET_NAME}" "$@" + else + COMMAND="$1" + shift 1 + echo -n "${WALLET_PASS}" | $COMMAND --wallet-password-stdin "${WALLET_NAME}" "$@" + fi +else + exec "$@" +fi diff --git a/JoinMarket/0.9.10/linuxamd64.Dockerfile b/JoinMarket/0.9.10/linuxamd64.Dockerfile new file mode 100644 index 0000000..6db51b4 --- /dev/null +++ b/JoinMarket/0.9.10/linuxamd64.Dockerfile @@ -0,0 +1,44 @@ +FROM python:3.9-slim-bookworm + +ENV REPO https://github.com/JoinMarket-Org/joinmarket-clientserver +ENV REPO_REF v0.9.10 + +ENV DATADIR /root/.joinmarket +ENV CONFIG ${DATADIR}/joinmarket.cfg +ENV DEFAULT_CONFIG /root/default.cfg +ENV DEFAULT_AUTO_START /root/autostart +ENV AUTO_START ${DATADIR}/autostart +ENV ENV_FILE "${DATADIR}/.env" + +# install dependencies +RUN apt-get update +RUN apt-get install -qq --no-install-recommends curl tini procps vim git iproute2 gnupg supervisor \ + build-essential automake pkg-config libtool libffi-dev libssl-dev libgmp-dev libltdl-dev libsodium-dev \ + python3-dev python3-pip python3-setuptools python3-venv + +# install joinmarket +WORKDIR /src +RUN git clone "$REPO" . --depth=1 --branch "$REPO_REF" && git checkout "$REPO_REF" +RUN ./install.sh --docker-install --without-qt +RUN pip install matplotlib + +# setup +WORKDIR /src/scripts +RUN (python wallet-tool.py generate || true) && cp "${CONFIG}" "${DEFAULT_CONFIG}" +COPY *.sh ./ +COPY autostart /root/ +COPY supervisor-conf/*.conf /etc/supervisor/conf.d/ +ENV PATH /src/scripts:$PATH + +# cleanup and remove ephemeral dependencies +RUN rm --recursive --force install.sh deps/cache/ test/ .git/ .gitignore .github/ .coveragerc joinmarket-qt.desktop +RUN apt-get remove --purge --auto-remove -y gnupg python3-pip apt-transport-https && apt-get clean +RUN rm -rf /var/lib/apt/lists/* /var/log/dpkg.log + +# jmwallet daemon +EXPOSE 28183 +# payjoin server +EXPOSE 8080 +# obwatch +EXPOSE 62601 +ENTRYPOINT [ "tini", "-g", "--", "./docker-entrypoint.sh" ] diff --git a/JoinMarket/0.9.10/linuxarm32v7.Dockerfile b/JoinMarket/0.9.10/linuxarm32v7.Dockerfile new file mode 100644 index 0000000..a05456f --- /dev/null +++ b/JoinMarket/0.9.10/linuxarm32v7.Dockerfile @@ -0,0 +1,60 @@ +FROM debian:bookworm-slim as builder +RUN apt-get update && apt-get install -qq --no-install-recommends qemu-user-static + +# We use a prebuilt image, because our builder on circleci timeout after 1H and the build take too long +FROM builder as cryptographybuilder +RUN apt-get install -qq --no-install-recommends wget +ENV CRYPTO_TAR="cryptography-3.3.2-pip-arm32v7.tar" +RUN mkdir -p /root/.cache && cd /root/.cache && \ + wget -qO ${CRYPTO_TAR} "http://aois.blob.core.windows.net/public/${CRYPTO_TAR}" && \ + echo "c7dde603057aaa0cb35582dba59ad487262e7f562640867545b1960afaf4f2e4 ${CRYPTO_TAR}" | sha256sum -c - && \ + tar -xvf "${CRYPTO_TAR}" && \ + rm "${CRYPTO_TAR}" + +FROM arm32v7/python:3.9-slim-bookworm + +COPY --from=builder /usr/bin/qemu-arm-static /usr/bin/qemu-arm-static +COPY --from=cryptographybuilder /root/.cache /root/.cache + +ENV REPO https://github.com/JoinMarket-Org/joinmarket-clientserver +ENV REPO_REF v0.9.10 + +ENV DATADIR /root/.joinmarket +ENV CONFIG ${DATADIR}/joinmarket.cfg +ENV DEFAULT_CONFIG /root/default.cfg +ENV DEFAULT_AUTO_START /root/autostart +ENV AUTO_START ${DATADIR}/autostart +ENV ENV_FILE "${DATADIR}/.env" + +# install dependencies +RUN apt-get update +RUN apt-get install -qq --no-install-recommends curl tini procps vim git iproute2 gnupg supervisor \ + build-essential automake pkg-config libtool libffi-dev libssl-dev libgmp-dev libltdl-dev libsodium-dev \ + python3-dev python3-pip python3-setuptools python3-venv + +# install joinmarket +WORKDIR /src +RUN git clone "$REPO" . --depth=1 --branch "$REPO_REF" && git checkout "$REPO_REF" +RUN ./install.sh --docker-install --without-qt +RUN pip install matplotlib + +# setup +WORKDIR /src/scripts +RUN (python wallet-tool.py generate || true) && cp "${CONFIG}" "${DEFAULT_CONFIG}" +COPY *.sh ./ +COPY autostart /root/ +COPY supervisor-conf/*.conf /etc/supervisor/conf.d/ +ENV PATH /src/scripts:$PATH + +# cleanup and remove ephemeral dependencies +RUN rm --recursive --force install.sh deps/cache/ test/ .git/ .gitignore .github/ .coveragerc joinmarket-qt.desktop +RUN apt-get remove --purge --auto-remove -y gnupg python3-pip apt-transport-https && apt-get clean +RUN rm -rf /var/lib/apt/lists/* /var/log/dpkg.log + +# jmwallet daemon +EXPOSE 28183 +# payjoin server +EXPOSE 8080 +# obwatch +EXPOSE 62601 +ENTRYPOINT [ "tini", "-g", "--", "./docker-entrypoint.sh" ] diff --git a/JoinMarket/0.9.10/linuxarm64v8.Dockerfile b/JoinMarket/0.9.10/linuxarm64v8.Dockerfile new file mode 100644 index 0000000..cf6f0da --- /dev/null +++ b/JoinMarket/0.9.10/linuxarm64v8.Dockerfile @@ -0,0 +1,48 @@ +FROM debian:bookworm-slim as builder +RUN apt-get update && apt-get install -qq --no-install-recommends qemu-user-static + +FROM arm64v8/python:3.9-slim-bookworm +COPY --from=builder /usr/bin/qemu-aarch64-static /usr/bin/qemu-aarch64-static + +ENV REPO https://github.com/JoinMarket-Org/joinmarket-clientserver +ENV REPO_REF v0.9.10 + +ENV DATADIR /root/.joinmarket +ENV CONFIG ${DATADIR}/joinmarket.cfg +ENV DEFAULT_CONFIG /root/default.cfg +ENV DEFAULT_AUTO_START /root/autostart +ENV AUTO_START ${DATADIR}/autostart +ENV ENV_FILE "${DATADIR}/.env" + +# install dependencies +RUN apt-get update +RUN apt-get install -qq --no-install-recommends curl tini procps vim git iproute2 gnupg supervisor \ + build-essential automake pkg-config libtool libffi-dev libssl-dev libgmp-dev libltdl-dev libsodium-dev \ + python3-dev python3-pip python3-setuptools python3-venv + +# install joinmarket +WORKDIR /src +RUN git clone "$REPO" . --depth=1 --branch "$REPO_REF" && git checkout "$REPO_REF" +RUN ./install.sh --docker-install --without-qt +RUN pip install matplotlib + +# setup +WORKDIR /src/scripts +RUN (python wallet-tool.py generate || true) && cp "${CONFIG}" "${DEFAULT_CONFIG}" +COPY *.sh ./ +COPY autostart /root/ +COPY supervisor-conf/*.conf /etc/supervisor/conf.d/ +ENV PATH /src/scripts:$PATH + +# cleanup and remove ephemeral dependencies +RUN rm --recursive --force install.sh deps/cache/ test/ .git/ .gitignore .github/ .coveragerc joinmarket-qt.desktop +RUN apt-get remove --purge --auto-remove -y gnupg python3-pip apt-transport-https && apt-get clean +RUN rm -rf /var/lib/apt/lists/* /var/log/dpkg.log + +# jmwallet daemon +EXPOSE 28183 +# payjoin server +EXPOSE 8080 +# obwatch +EXPOSE 62601 +ENTRYPOINT [ "tini", "-g", "--", "./docker-entrypoint.sh" ] diff --git a/JoinMarket/0.9.10/set-wallet.sh b/JoinMarket/0.9.10/set-wallet.sh new file mode 100755 index 0000000..3735260 --- /dev/null +++ b/JoinMarket/0.9.10/set-wallet.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +WALLET_NAME="$1" +WALLET_PASS="$2" +if ! [[ "$WALLET_NAME" ]] || ! [[ "$WALLET_PASS" ]]; then + echo "Usage: set-wallet " + exit 1 +fi +echo "WALLET_NAME=$WALLET_NAME" > "$ENV_FILE" +echo "WALLET_PASS=$WALLET_PASS" >> "$ENV_FILE" diff --git a/JoinMarket/0.9.10/supervisor-conf/jmwalletd.conf b/JoinMarket/0.9.10/supervisor-conf/jmwalletd.conf new file mode 100644 index 0000000..ad2fe70 --- /dev/null +++ b/JoinMarket/0.9.10/supervisor-conf/jmwalletd.conf @@ -0,0 +1,11 @@ +[program:jmwalletd] +directory=/src/scripts +command=python jmwalletd.py +autostart=false +autorestart=true +stdout_logfile=/root/.joinmarket/logs/jmwalletd_stdout.log +stdout_logfile_maxbytes=5MB +stdout_logfile_backups=0 +stderr_logfile=/root/.joinmarket/logs/jmwalletd_stderr.log +stderr_logfile_maxbytes=5MB +stderr_logfile_backups=0 diff --git a/JoinMarket/0.9.10/supervisor-conf/ob-watcher.conf b/JoinMarket/0.9.10/supervisor-conf/ob-watcher.conf new file mode 100644 index 0000000..c816ada --- /dev/null +++ b/JoinMarket/0.9.10/supervisor-conf/ob-watcher.conf @@ -0,0 +1,10 @@ +[program:ob-watcher] +directory=/src/scripts/obwatch +command=python ob-watcher.py --host 0.0.0.0 +autostart=false +stdout_logfile=/root/.joinmarket/logs/obwatch_stdout.log +stdout_logfile_maxbytes=5MB +stdout_logfile_backups=0 +stderr_logfile=/root/.joinmarket/logs/obwatch_stderr.log +stderr_logfile_maxbytes=5MB +stderr_logfile_backups=0 diff --git a/JoinMarket/0.9.10/supervisor-conf/supervisord.conf b/JoinMarket/0.9.10/supervisor-conf/supervisord.conf new file mode 100644 index 0000000..d92638b --- /dev/null +++ b/JoinMarket/0.9.10/supervisor-conf/supervisord.conf @@ -0,0 +1,2 @@ +[supervisord] +nodaemon=true \ No newline at end of file diff --git a/JoinMarket/0.9.10/supervisor-conf/yg-privacyenhanced.conf b/JoinMarket/0.9.10/supervisor-conf/yg-privacyenhanced.conf new file mode 100644 index 0000000..592fee7 --- /dev/null +++ b/JoinMarket/0.9.10/supervisor-conf/yg-privacyenhanced.conf @@ -0,0 +1,10 @@ +[program:yg-privacyenhanced] +directory=/src/scripts +command=exec-wrapper.sh unlockwallet yg-privacyenhanced.py +autostart=false +stdout_logfile=/root/.joinmarket/logs/yg-privacyenhanced_stdout.log +stdout_logfile_maxbytes=5MB +stdout_logfile_backups=0 +stderr_logfile=/root/.joinmarket/logs/yg-privacyenhanced_stderr.log +stderr_logfile_maxbytes=5MB +stderr_logfile_backups=0 \ No newline at end of file diff --git a/JoinMarket/0.9.10/supervisor-conf/yield-generator-basic.conf b/JoinMarket/0.9.10/supervisor-conf/yield-generator-basic.conf new file mode 100644 index 0000000..be497f7 --- /dev/null +++ b/JoinMarket/0.9.10/supervisor-conf/yield-generator-basic.conf @@ -0,0 +1,10 @@ +[program:yield-generator-basic] +directory=/src/scripts +command=exec-wrapper.sh unlockwallet yield-generator-basic.py +autostart=false +stdout_logfile=/root/.joinmarket/logs/yield-generator-basic_stdout.log +stdout_logfile_maxbytes=5MB +stdout_logfile_backups=0 +stderr_logfile=/root/.joinmarket/logs/yield-generator-basic_stderr.log +stderr_logfile_maxbytes=5MB +stderr_logfile_backups=0 \ No newline at end of file