Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: boltz image after breaking gRPC changes #822

Merged
merged 3 commits into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion images/boltz/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ COPY wrapper.sh /usr/bin/wrapper

ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisor/conf.d/supervisord.conf"]

EXPOSE 9002 9003
EXPOSE 9002 9003 9102 9103
22 changes: 19 additions & 3 deletions images/boltz/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ DATADIR="/root/.boltz/$CHAIN"
LOGFILE="$DATADIR/boltz.log"
CONFIGFILE="$DATADIR/boltz.conf"
DATABASEFILE="$DATADIR/boltz.db"
ADMINMACAROONFILE="$DATADIR/admin.macaroon"
TLSKEYFILE="$DATADIR/tls.key"
TLSCERTFILE="$DATADIR/tls.cert"

case "$CHAIN" in
"bitcoin")
Expand All @@ -15,6 +18,7 @@ case "$CHAIN" in
LNDHOST="lndbtc"

PORT="9002"
RESTPORT="9003"
;;

"litecoin")
Expand All @@ -23,7 +27,8 @@ case "$CHAIN" in
LNDDIR="lndltc"
LNDHOST="lndltc"

PORT="9003"
PORT="9102"
RESTPORT="9103"
;;

*)
Expand All @@ -36,7 +41,7 @@ CERTPATH="/root/.$LNDDIR/tls.cert"
MACAROONPATH="/root/.$LNDDIR/data/chain/$CHAIN/$NETWORK/admin.macaroon"

write_config() {
echo "Creating new config for $CHAIN daemon"
echo "Creating config for $CHAIN daemon"
mkdir -p $DATADIR
cp /sample-config.toml $CONFIGFILE

Expand All @@ -51,8 +56,19 @@ write_config() {

sed -i '/\[RPC/,/^$/s/host.*/host = "0.0.0.0"/' $CONFIGFILE
sed -i "/\[RPC/,/^$/s/port.*/port = $PORT/" $CONFIGFILE

sed -i '/\[RPC/,/^$/s/restHost.*/restHost = "0.0.0.0"/' $CONFIGFILE
sed -i "/\[RPC/,/^$/s/restPort.*/restPort = $RESTPORT/" $CONFIGFILE
}

# Config file migration
# If the config file does *not* contain anything related to the REST proxy of boltz-lnd,
# it is safe to assume that it is oudated and needs to be recreated
if [[ -e $CONFIGFILE ]] && ! grep -q "rest" "$CONFIGFILE"; then
echo "Removing outdated config file"
rm $CONFIGFILE
fi

if [[ $REWRITE_CONFIG || ! -e $CONFIGFILE ]]; then
write_config
fi
Expand All @@ -70,4 +86,4 @@ echo 'Detecting localnet IP for lndltc...'
LNDLTC_IP=$(getent hosts lndltc | awk '{ print $1 }')
echo "$LNDLTC_IP lndltc" >> /etc/hosts

exec boltzd --configfile $CONFIGFILE --logfile $LOGFILE --database.path $DATABASEFILE
exec boltzd --configfile $CONFIGFILE --logfile $LOGFILE --database.path $DATABASEFILE --rpc.adminmacaroonpath $ADMINMACAROONFILE --rpc.tlscert $TLSCERTFILE --rpc.tlskey $TLSKEYFILE
11 changes: 8 additions & 3 deletions images/boltz/wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@
CHAIN=$1

# Use "${<variable>,,}" to convert the CHAIN variable to lower case
# Reference: https://stackoverflow.com/a/2264537
# Reference: https://stackoverflow.com/a/2264537
case "${CHAIN,,}" in
"btc")
PORT="9002"
DATADIR="/root/.boltz/bitcoin"
;;

"ltc")
PORT="9003"
PORT="9102"
DATADIR="/root/.boltz/litecoin"
;;

# Print the help command
Expand All @@ -28,4 +30,7 @@ case "${CHAIN,,}" in
;;
esac

exec boltzcli --port $PORT ${@:2}
TLSCERT="$DATADIR/tls.cert"
MACAROON="$DATADIR/admin.macaroon"

exec boltzcli --port $PORT --tlscert $TLSCERT --macaroon $MACAROON ${@:2}
2 changes: 1 addition & 1 deletion images/utils/launcher/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1058,7 +1058,7 @@ def dump(self) -> None:
rpc["type"] = "gRPC"
rpc["host"] = "boltz"
rpc["btcPort"] = 9002
rpc["ltcPort"] = 9003
rpc["ltcPort"] = 9102
elif name == "webui":
pass

Expand Down
2 changes: 1 addition & 1 deletion images/utils/launcher/config/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ def __str__(self):
},
"boltz": {
"name": "boltz",
"image": "exchangeunion/boltz:1.1.2",
"image": "exchangeunion/boltz:1.2.0",
"volumes": [
{
"host": "$data_dir/boltz",
Expand Down