diff --git a/proxy_docker/Dockerfile b/proxy_docker/Dockerfile index 8baa72d..e49980e 100644 --- a/proxy_docker/Dockerfile +++ b/proxy_docker/Dockerfile @@ -16,9 +16,6 @@ COPY app/script/requesthandler.sh ${HOME}/requesthandler.sh COPY app/script/watchrequest.sh ${HOME}/watchrequest.sh COPY app/script/walletoperations.sh ${HOME}/walletoperations.sh COPY app/script/confirmation.sh ${HOME}/confirmation.sh -COPY app/config/watcher_btcnode_curlcfg.properties ${HOME}/watcher_btcnode_curlcfg.properties -COPY app/config/spender_btcnode_curlcfg.properties ${HOME}/spender_btcnode_curlcfg.properties -COPY app/config/config.properties ${HOME}/config.properties COPY app/script/startproxy.sh ${HOME}/startproxy.sh COPY app/script/trace.sh ${HOME}/trace.sh COPY app/script/sendtobitcoinnode.sh ${HOME}/sendtobitcoinnode.sh @@ -29,7 +26,6 @@ COPY app/data/watching.sql ${HOME}/watching.sql COPY app/script/computefees.sh ${HOME}/computefees.sh COPY app/script/unwatchrequest.sh ${HOME}/unwatchrequest.sh COPY app/script/getactivewatches.sh ${HOME}/getactivewatches.sh -COPY app/script/utils.sh ${HOME}/utils.sh COPY app/script/manage_missed_conf.sh ${HOME}/manage_missed_conf.sh COPY app/script/tests.sh ${HOME}/tests.sh COPY app/script/tests-cb.sh ${HOME}/tests-cb.sh diff --git a/proxy_docker/app/config/config.properties b/proxy_docker/app/config/config.properties deleted file mode 100644 index 56d0ada..0000000 --- a/proxy_docker/app/config/config.properties +++ /dev/null @@ -1,3 +0,0 @@ -derivation.pub32=upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb -derivation.path=0/n -watchingnode.pruned=false diff --git a/proxy_docker/app/config/spender_btcnode_curlcfg.properties b/proxy_docker/app/config/spender_btcnode_curlcfg.properties deleted file mode 100644 index 0860f6c..0000000 --- a/proxy_docker/app/config/spender_btcnode_curlcfg.properties +++ /dev/null @@ -1 +0,0 @@ -user=rpc_username:rpc_password diff --git a/proxy_docker/app/config/watcher_btcnode_curlcfg.properties b/proxy_docker/app/config/watcher_btcnode_curlcfg.properties deleted file mode 100644 index 0860f6c..0000000 --- a/proxy_docker/app/config/watcher_btcnode_curlcfg.properties +++ /dev/null @@ -1 +0,0 @@ -user=rpc_username:rpc_password diff --git a/proxy_docker/app/script/bitcoin.sh b/proxy_docker/app/script/bitcoin.sh index a32c9c3..5fc0632 100644 --- a/proxy_docker/app/script/bitcoin.sh +++ b/proxy_docker/app/script/bitcoin.sh @@ -1,7 +1,6 @@ #!/bin/sh . ./trace.sh -. ./utils.sh deriveindex() { @@ -10,8 +9,8 @@ deriveindex() local index=${1} trace "[deriveindex] index=${index}" - local pub32=$(get_prop "derivation.pub32") - local path=$(get_prop "derivation.path" | sed -En "s/n/${index}/p") + local pub32=$DERIVATION_PUB32 + local path=$(echo -e $DERIVATION_PATH | sed -En "s/n/${index}/p") # pub32=$(grep "derivation.pub32" config.properties | cut -d'=' -f2) # path=$(grep "derivation.path" config.properties | cut -d'=' -f2 | sed -En "s/n/${index}/p") @@ -43,4 +42,4 @@ send_to_pycoin() trace_rc ${returncode} return ${returncode} -} +} \ No newline at end of file diff --git a/proxy_docker/app/script/computefees.sh b/proxy_docker/app/script/computefees.sh index 1948cef..640e24d 100644 --- a/proxy_docker/app/script/computefees.sh +++ b/proxy_docker/app/script/computefees.sh @@ -7,7 +7,7 @@ compute_fees() { - local pruned=$(get_prop "watchingnode.pruned") + local pruned=${WATCHER_BTC_NODE_PRUNED} if [ "${pruned}" = "true" ]; then trace "[compute_fees] pruned=${pruned}" # We want null instead of 0.00000000 in this case. diff --git a/proxy_docker/app/script/startproxy.sh b/proxy_docker/app/script/startproxy.sh index 8f9cd94..6356eab 100644 --- a/proxy_docker/app/script/startproxy.sh +++ b/proxy_docker/app/script/startproxy.sh @@ -3,13 +3,39 @@ export PROXY_LISTENING_PORT export WATCHER_NODE_RPC_URL=$WATCHER_BTC_NODE_RPC_URL export SPENDER_NODE_RPC_URL=$SPENDER_BTC_NODE_RPC_URL +export WATCHER_NODE_RPC_CFG=$WATCHER_BTC_NODE_RPC_CFG +export SPENDER_NODE_RPC_CFG=$SPENDER_BTC_NODE_RPC_CFG export TRACING export DB_PATH export DB_FILE +trim() { + echo -e $1 | sed -e 's/^[[:space:]]*//' | sed -e 's/[[:space:]]*$//' +} + +createCurlConfig() { + + if [[ ''$1 == '' ]]; then + echo "Missing file name: Check you *_BTC_NODE_RPC_CFG" + return + fi + + if [[ ''$2 == '' ]]; then + echo "Missing content: Check you *_BTC_NODE_RPC_USER" + return + fi + + local user=$( trim $2 ) + echo "user=${user}" > ${1} + +} + if [ ! -e ${DB_FILE} ]; then echo "DB not found, creating..." > /dev/stderr cat watching.sql | sqlite3 $DB_FILE fi +createCurlConfig ${WATCHER_BTC_NODE_RPC_CFG} ${WATCHER_BTC_NODE_RPC_USER} +createCurlConfig ${SPENDER_BTC_NODE_RPC_CFG} ${SPENDER_BTC_NODE_RPC_USER} + nc -vlkp${PROXY_LISTENING_PORT} -e ./requesthandler.sh diff --git a/proxy_docker/env.properties b/proxy_docker/env.properties index da95f88..9a1f8d5 100644 --- a/proxy_docker/env.properties +++ b/proxy_docker/env.properties @@ -1,12 +1,19 @@ TRACING=1 WATCHER_BTC_NODE_RPC_URL=btcnode:18332/wallet/watching01.dat +WATCHER_BTC_NODE_RPC_USER=rpc_username:rpc_password +WATCHER_BTC_NODE_RPC_CFG=/proxy/watcher_btcnode_curlcfg.properties SPENDER_BTC_NODE_RPC_URL=btcnode:18332/wallet/spending01.dat +SPENDER_BTC_NODE_RPC_USER=rpc_username:rpc_password +SPENDER_BTC_NODE_RPC_CFG=/proxy/spender_btcnode_curlcfg.properties PROXY_LISTENING_PORT=8888 # Variable substitutions don't work -HOME=/proxy DB_PATH=/proxy/db DB_FILE=/proxy/db/proxydb # Pycoin container PYCOIN_CONTAINER=pycoinnode:7777 # OTS container OTS_CONTAINER=otsnode:6666 + +DERIVATION_PUB32=upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb +DERIVATION_PATH=0/n +WATCHER_BTC_NODE_PRUNED=false