JoinMarket: Upgrade to v0.9.10 (#76)

This uses their new install method with the `--docker-install` flag, which obsoletes the jmvenv.
This commit is contained in:
d11n 2023-12-20 11:12:52 +01:00 committed by GitHub
parent 6c1b1f252e
commit 24d3cf5c72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 299 additions and 0 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <wallet_name> <Password>"
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

View File

@ -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" ]

View File

@ -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" ]

View File

@ -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" ]

11
JoinMarket/0.9.10/set-wallet.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
set -e
WALLET_NAME="$1"
WALLET_PASS="$2"
if ! [[ "$WALLET_NAME" ]] || ! [[ "$WALLET_PASS" ]]; then
echo "Usage: set-wallet <wallet_name> <password>"
exit 1
fi
echo "WALLET_NAME=$WALLET_NAME" > "$ENV_FILE"
echo "WALLET_PASS=$WALLET_PASS" >> "$ENV_FILE"

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,2 @@
[supervisord]
nodaemon=true

View File

@ -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

View File

@ -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