mirror of
https://github.com/aljazceru/cyphernode.git
synced 2025-12-17 12:45:22 +01:00
Merge pull request #18 from SatoshiPortal/features/hubable
Features/hubable
This commit is contained in:
@@ -31,14 +31,11 @@ docker network create --driver=overlay --attachable --opt encrypted cyphernodene
|
|||||||
git clone https://github.com/SatoshiPortal/cyphernode.git
|
git clone https://github.com/SatoshiPortal/cyphernode.git
|
||||||
cd cyphernode/
|
cd cyphernode/
|
||||||
vi proxy_docker/env.properties
|
vi proxy_docker/env.properties
|
||||||
vi proxy_docker/app/config/config.properties
|
|
||||||
```
|
```
|
||||||
|
|
||||||
*Make sure user have same rpcuser and rpcpassword values as in bitcoin node's bitcoin.conf file (see below)*
|
*Make sure user have same rpcuser and rpcpassword values as in bitcoin node's bitcoin.conf file (see below)*
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
vi proxy_docker/app/config/watcher_btcnode_curlcfg.properties
|
|
||||||
vi proxy_docker/app/config/spender_btcnode_curlcfg.properties
|
|
||||||
vi cron_docker/env.properties
|
vi cron_docker/env.properties
|
||||||
vi pycoin_docker/env.properties
|
vi pycoin_docker/env.properties
|
||||||
```
|
```
|
||||||
@@ -49,8 +46,8 @@ vi pycoin_docker/env.properties
|
|||||||
sudo useradd cyphernode
|
sudo useradd cyphernode
|
||||||
mkdir ~/btcproxydb ; sudo chown -R cyphernode:debian ~/btcproxydb ; sudo chmod g+ws ~/btcproxydb
|
mkdir ~/btcproxydb ; sudo chown -R cyphernode:debian ~/btcproxydb ; sudo chmod g+ws ~/btcproxydb
|
||||||
docker build -t proxycronimg cron_docker/.
|
docker build -t proxycronimg cron_docker/.
|
||||||
docker build -t btcproxyimg --build-arg USER_ID=$(id -u cyphernode) --build-arg GROUP_ID=$(id -g cyphernode) proxy_docker/.
|
docker build -t btcproxyimg proxy_docker/.
|
||||||
docker build -t pycoinimg --build-arg USER_ID=$(id -u cyphernode) --build-arg GROUP_ID=$(id -g cyphernode) pycoin_docker/.
|
docker build -t pycoinimg pycoin_docker/.
|
||||||
```
|
```
|
||||||
|
|
||||||
## Build images from Satoshi Portal's dockers repo
|
## Build images from Satoshi Portal's dockers repo
|
||||||
@@ -75,16 +72,16 @@ rpcwallet=ln01.dat
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
vi config
|
vi config
|
||||||
mkdir ~/.lightning
|
mkdir ~/lndata
|
||||||
cp config ~/.lightning/
|
cp config ~/lndata/
|
||||||
sudo chown -R cyphernode:debian ~/.lightning ; sudo chmod g+ws ~/.lightning
|
sudo chown -R cyphernode:debian ~/lndata ; sudo chmod g+ws ~/lndata
|
||||||
sudo find ~/.lightning -type d -exec chmod 2775 {} \; ; sudo find ~/.lightning -type f -exec chmod g+rw {} \;
|
sudo find ~/lndata -type d -exec chmod 2775 {} \; ; sudo find ~/lndata -type f -exec chmod g+rw {} \;
|
||||||
docker build -t clnimg --build-arg USER_ID=$(id -u cyphernode) --build-arg GROUP_ID=$(id -g cyphernode) .
|
docker build -t clnimg .
|
||||||
cd ../../bitcoin-core/
|
cd ../../bitcoin-core/
|
||||||
mkdir ~/.bitcoin
|
mkdir ~/btcdata
|
||||||
sudo chown -R cyphernode:debian ~/.bitcoin ; sudo chmod g+ws ~/.bitcoin
|
sudo chown -R cyphernode:debian ~/btcdata ; sudo chmod g+ws ~/btcdata
|
||||||
sudo find ~/.bitcoin -type d -exec chmod 2775 {} \; ; sudo find ~/.bitcoin -type f -exec chmod g+rw {} \;
|
sudo find ~/btcdata -type d -exec chmod 2775 {} \; ; sudo find ~/btcdata -type f -exec chmod g+rw {} \;
|
||||||
docker build -t btcnode --build-arg USER_ID=$(id -u cyphernode) --build-arg GROUP_ID=$(id -g cyphernode) --build-arg CORE_VERSION="0.16.3" .
|
docker build -t btcnode .
|
||||||
```
|
```
|
||||||
|
|
||||||
## Mount bitcoin data volume and make sure bitcoin configuration is ok
|
## Mount bitcoin data volume and make sure bitcoin configuration is ok
|
||||||
@@ -92,8 +89,8 @@ docker build -t btcnode --build-arg USER_ID=$(id -u cyphernode) --build-arg GROU
|
|||||||
(Watcher and spender is the same bitcoin node, with different wallets)
|
(Watcher and spender is the same bitcoin node, with different wallets)
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo mount /dev/vdc ~/.bitcoin/
|
sudo mount /dev/vdc ~/btcdata/
|
||||||
vi ~/.bitcoin/bitcoin.conf
|
vi ~/btcdata/bitcoin.conf
|
||||||
```
|
```
|
||||||
|
|
||||||
*Make sure testnet, rpcuser and rpcpassword have the same value as in c-lightning node's bitcoin.conf file (see above)*
|
*Make sure testnet, rpcuser and rpcpassword have the same value as in c-lightning node's bitcoin.conf file (see above)*
|
||||||
@@ -119,16 +116,16 @@ walletnotify=curl cyphernode:8888/conf/%s
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
cd ~/cyphernode/
|
cd ~/cyphernode/
|
||||||
docker stack deploy --compose-file docker-compose.yml cyphernodestack
|
USER=`id -u cyphernode`:`id -g cyphernode` docker stack deploy --compose-file docker-compose.yml cyphernodestack
|
||||||
```
|
```
|
||||||
|
|
||||||
## Wait a few minutes and re-apply permissions
|
## Wait a few minutes and re-apply permissions
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
sudo chown -R cyphernode:debian ~/.lightning ; sudo chmod g+ws ~/.lightning
|
sudo chown -R cyphernode:debian ~/lndata ; sudo chmod g+ws ~/lndata
|
||||||
sudo chown -R cyphernode:debian ~/.bitcoin ; sudo chmod g+ws ~/.bitcoin
|
sudo chown -R cyphernode:debian ~/btcdata ; sudo chmod g+ws ~/btcdata
|
||||||
sudo find ~/.lightning -type d -exec chmod 2775 {} \; ; sudo find ~/.lightning -type f -exec chmod g+rw {} \;
|
sudo find ~/lndata -type d -exec chmod 2775 {} \; ; sudo find ~/lndata -type f -exec chmod g+rw {} \;
|
||||||
sudo find ~/.bitcoin -type d -exec chmod 2775 {} \; ; sudo find ~/.bitcoin -type f -exec chmod g+rw {} \;
|
sudo find ~/btcdata -type d -exec chmod 2775 {} \; ; sudo find ~/btcdata -type f -exec chmod g+rw {} \;
|
||||||
```
|
```
|
||||||
|
|
||||||
## Test the deployment
|
## Test the deployment
|
||||||
|
|||||||
@@ -49,9 +49,6 @@ debian@dev:~/dev/Cyphernode$ docker network connect cyphernodenet yourappcontain
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
debian@dev:~/dev/Cyphernode$ vi proxy_docker/env.properties
|
debian@dev:~/dev/Cyphernode$ vi proxy_docker/env.properties
|
||||||
debian@dev:~/dev/Cyphernode$ vi proxy_docker/app/config/config.properties
|
|
||||||
debian@dev:~/dev/Cyphernode$ vi proxy_docker/app/config/watcher_btcnode_curlcfg.properties
|
|
||||||
debian@dev:~/dev/Cyphernode$ vi proxy_docker/app/config/spender_btcnode_curlcfg.properties
|
|
||||||
debian@dev:~/dev/Cyphernode$ vi cron_docker/env.properties
|
debian@dev:~/dev/Cyphernode$ vi cron_docker/env.properties
|
||||||
debian@dev:~/dev/Cyphernode$ vi pycoin_docker/env.properties
|
debian@dev:~/dev/Cyphernode$ vi pycoin_docker/env.properties
|
||||||
```
|
```
|
||||||
@@ -81,7 +78,7 @@ debian@dev:~/dev/Cyphernode$ vi pycoin_docker/env.properties
|
|||||||
**Edit docker-compose.yml to specify special deployment constraints or if you want to run the Bitcoin node on the same machine: uncomment corresponding lines.**
|
**Edit docker-compose.yml to specify special deployment constraints or if you want to run the Bitcoin node on the same machine: uncomment corresponding lines.**
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
debian@dev:~/dev/Cyphernode$ docker stack deploy --compose-file docker-compose.yml cyphernodestack
|
debian@dev:~/dev/Cyphernode$ USER=`id -u cyphernode`:`id -g cyphernode` docker stack deploy --compose-file docker-compose.yml cyphernodestack
|
||||||
Creating service cyphernodestack_cyphernode
|
Creating service cyphernodestack_cyphernode
|
||||||
Creating service cyphernodestack_proxycronnode
|
Creating service cyphernodestack_proxycronnode
|
||||||
Creating service cyphernodestack_pycoinnode
|
Creating service cyphernodestack_pycoinnode
|
||||||
@@ -100,11 +97,7 @@ pi@SP-BTC01:~ $ docker swarm join --token SWMTKN-1-2pxouynn9g8si42e8g9ujwy0v9po4
|
|||||||
|
|
||||||
[See how to build Bitcoin Node image](https://github.com/SatoshiPortal/dockers/tree/master/rpi/bitcoin-core)
|
[See how to build Bitcoin Node image](https://github.com/SatoshiPortal/dockers/tree/master/rpi/bitcoin-core)
|
||||||
|
|
||||||
### Run node or connect already-running node
|
### Connect already-running node
|
||||||
|
|
||||||
```shell
|
|
||||||
pi@SP-BTC01:~ $ docker run -d --rm --mount type=bind,source="$HOME/.bitcoin",target="/bitcoinuser/.bitcoin" --name btcnode --network cyphernodenet btcnode
|
|
||||||
```
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
pi@SP-BTC01:~ $ docker network connect cyphernodenet btcnode
|
pi@SP-BTC01:~ $ docker network connect cyphernodenet btcnode
|
||||||
|
|||||||
@@ -11,11 +11,13 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
# Variable substitutions don't work
|
# Variable substitutions don't work
|
||||||
# Match with DB_PATH in proxy_docker/env.properties
|
# Match with DB_PATH in proxy_docker/env.properties
|
||||||
- "~/btcproxydb:/proxyuser/db"
|
- "~/btcproxydb:/proxy/db"
|
||||||
- "~/.lightning:/proxyuser/.lightning"
|
# c-lightning looks for $HOME/.lightning/, and $HOME is set to / in the container
|
||||||
|
- "~/lndata:/.lightning"
|
||||||
# deploy:
|
# deploy:
|
||||||
# placement:
|
# placement:
|
||||||
# constraints: [node.hostname==dev]
|
# constraints: [node.hostname==dev]
|
||||||
|
command: $USER ./startproxy.sh
|
||||||
networks:
|
networks:
|
||||||
- cyphernodenet
|
- cyphernodenet
|
||||||
|
|
||||||
@@ -40,6 +42,7 @@ services:
|
|||||||
# deploy:
|
# deploy:
|
||||||
# placement:
|
# placement:
|
||||||
# constraints: [node.hostname==dev]
|
# constraints: [node.hostname==dev]
|
||||||
|
command: $USER ./startpycoin.sh
|
||||||
networks:
|
networks:
|
||||||
- cyphernodenet
|
- cyphernodenet
|
||||||
|
|
||||||
@@ -49,10 +52,11 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "9735:9735"
|
- "9735:9735"
|
||||||
volumes:
|
volumes:
|
||||||
- "~/.lightning:/lnuser/.lightning"
|
- "~/lndata:/.lightning"
|
||||||
# deploy:
|
# deploy:
|
||||||
# placement:
|
# placement:
|
||||||
# constraints: [node.hostname==dev]
|
# constraints: [node.hostname==dev]
|
||||||
|
command: $USER lightningd
|
||||||
networks:
|
networks:
|
||||||
- cyphernodenet
|
- cyphernodenet
|
||||||
|
|
||||||
@@ -66,7 +70,8 @@ services:
|
|||||||
# - "8333:8333"
|
# - "8333:8333"
|
||||||
# - "8332:8332"
|
# - "8332:8332"
|
||||||
volumes:
|
volumes:
|
||||||
- "~/.bitcoin:/bitcoinuser/.bitcoin"
|
- "~/btcdata:/.bitcoin"
|
||||||
|
command: $USER bitcoind
|
||||||
networks:
|
networks:
|
||||||
- cyphernodenet
|
- cyphernodenet
|
||||||
|
|
||||||
|
|||||||
@@ -1,56 +1,42 @@
|
|||||||
FROM alpine
|
FROM alpine
|
||||||
|
|
||||||
ARG USER_ID
|
ENV HOME /proxy
|
||||||
ARG GROUP_ID
|
|
||||||
ENV USERNAME proxyuser
|
|
||||||
ENV HOME /${USERNAME}
|
|
||||||
ENV USER_ID ${USER_ID:-1000}
|
|
||||||
ENV GROUP_ID ${GROUP_ID:-1000}
|
|
||||||
|
|
||||||
RUN addgroup -g ${GROUP_ID} ${USERNAME} \
|
|
||||||
&& adduser -u ${USER_ID} -G ${USERNAME} -D -s /bin/sh -h ${HOME} ${USERNAME}
|
|
||||||
|
|
||||||
RUN apk add --update --no-cache \
|
RUN apk add --update --no-cache \
|
||||||
sqlite \
|
sqlite \
|
||||||
jq \
|
jq \
|
||||||
curl
|
curl \
|
||||||
|
su-exec
|
||||||
|
|
||||||
COPY --chown=proxyuser app/script/callbacks_job.sh ${HOME}/callbacks_job.sh
|
COPY app/script/callbacks_job.sh ${HOME}/callbacks_job.sh
|
||||||
COPY --chown=proxyuser app/script/blockchainrpc.sh ${HOME}/blockchainrpc.sh
|
COPY app/script/blockchainrpc.sh ${HOME}/blockchainrpc.sh
|
||||||
COPY --chown=proxyuser app/script/call_lightningd.sh ${HOME}/call_lightningd.sh
|
COPY app/script/call_lightningd.sh ${HOME}/call_lightningd.sh
|
||||||
COPY --chown=proxyuser app/script/bitcoin.sh ${HOME}/bitcoin.sh
|
COPY app/script/bitcoin.sh ${HOME}/bitcoin.sh
|
||||||
COPY --chown=proxyuser app/script/requesthandler.sh ${HOME}/requesthandler.sh
|
COPY app/script/requesthandler.sh ${HOME}/requesthandler.sh
|
||||||
COPY --chown=proxyuser app/script/watchrequest.sh ${HOME}/watchrequest.sh
|
COPY app/script/watchrequest.sh ${HOME}/watchrequest.sh
|
||||||
COPY --chown=proxyuser app/script/walletoperations.sh ${HOME}/walletoperations.sh
|
COPY app/script/walletoperations.sh ${HOME}/walletoperations.sh
|
||||||
COPY --chown=proxyuser app/script/confirmation.sh ${HOME}/confirmation.sh
|
COPY app/script/confirmation.sh ${HOME}/confirmation.sh
|
||||||
COPY --chown=proxyuser app/config/watcher_btcnode_curlcfg.properties ${HOME}/watcher_btcnode_curlcfg.properties
|
COPY app/script/startproxy.sh ${HOME}/startproxy.sh
|
||||||
COPY --chown=proxyuser app/config/spender_btcnode_curlcfg.properties ${HOME}/spender_btcnode_curlcfg.properties
|
COPY app/script/trace.sh ${HOME}/trace.sh
|
||||||
COPY --chown=proxyuser app/config/config.properties ${HOME}/config.properties
|
COPY app/script/sendtobitcoinnode.sh ${HOME}/sendtobitcoinnode.sh
|
||||||
COPY --chown=proxyuser app/script/startproxy.sh ${HOME}/startproxy.sh
|
COPY app/script/responsetoclient.sh ${HOME}/responsetoclient.sh
|
||||||
COPY --chown=proxyuser app/script/trace.sh ${HOME}/trace.sh
|
COPY app/script/importaddress.sh ${HOME}/importaddress.sh
|
||||||
COPY --chown=proxyuser app/script/sendtobitcoinnode.sh ${HOME}/sendtobitcoinnode.sh
|
COPY app/script/sql.sh ${HOME}/sql.sh
|
||||||
COPY --chown=proxyuser app/script/responsetoclient.sh ${HOME}/responsetoclient.sh
|
COPY app/data/watching.sql ${HOME}/watching.sql
|
||||||
COPY --chown=proxyuser app/script/importaddress.sh ${HOME}/importaddress.sh
|
COPY app/script/computefees.sh ${HOME}/computefees.sh
|
||||||
COPY --chown=proxyuser app/script/sql.sh ${HOME}/sql.sh
|
COPY app/script/unwatchrequest.sh ${HOME}/unwatchrequest.sh
|
||||||
COPY --chown=proxyuser app/data/watching.sql ${HOME}/watching.sql
|
COPY app/script/getactivewatches.sh ${HOME}/getactivewatches.sh
|
||||||
COPY --chown=proxyuser app/script/computefees.sh ${HOME}/computefees.sh
|
COPY app/script/manage_missed_conf.sh ${HOME}/manage_missed_conf.sh
|
||||||
COPY --chown=proxyuser app/script/unwatchrequest.sh ${HOME}/unwatchrequest.sh
|
COPY app/script/tests.sh ${HOME}/tests.sh
|
||||||
COPY --chown=proxyuser app/script/getactivewatches.sh ${HOME}/getactivewatches.sh
|
COPY app/script/tests-cb.sh ${HOME}/tests-cb.sh
|
||||||
COPY --chown=proxyuser app/script/utils.sh ${HOME}/utils.sh
|
COPY app/bin/lightning-cli_x86 ${HOME}/lightning-cli
|
||||||
COPY --chown=proxyuser app/script/manage_missed_conf.sh ${HOME}/manage_missed_conf.sh
|
|
||||||
COPY --chown=proxyuser app/script/tests.sh ${HOME}/tests.sh
|
|
||||||
COPY --chown=proxyuser app/script/tests-cb.sh ${HOME}/tests-cb.sh
|
|
||||||
COPY --chown=proxyuser app/bin/lightning-cli_x86 ${HOME}/lightning-cli
|
|
||||||
|
|
||||||
USER ${USERNAME}
|
|
||||||
WORKDIR ${HOME}
|
WORKDIR ${HOME}
|
||||||
|
|
||||||
RUN chmod +x startproxy.sh requesthandler.sh lightning-cli \
|
RUN chmod +x startproxy.sh requesthandler.sh lightning-cli \
|
||||||
&& chmod 600 watcher_btcnode_curlcfg.properties \
|
&& chmod o+w . \
|
||||||
&& chmod 600 spender_btcnode_curlcfg.properties \
|
|
||||||
&& chmod 600 config.properties \
|
|
||||||
&& mkdir db
|
&& mkdir db
|
||||||
|
|
||||||
VOLUME ["${HOME}/db", "${HOME}/.lightning"]
|
VOLUME ["${HOME}/db", "${HOME}/.lightning"]
|
||||||
|
|
||||||
ENTRYPOINT ["./startproxy.sh"]
|
ENTRYPOINT ["su-exec"]
|
||||||
|
|||||||
@@ -2,60 +2,40 @@
|
|||||||
|
|
||||||
We assume you are the user pi on a Raspberry Pi.
|
We assume you are the user pi on a Raspberry Pi.
|
||||||
|
|
||||||
## Create proxyuser that will run the processes
|
|
||||||
|
|
||||||
Log in your host and:
|
|
||||||
|
|
||||||
```shell
|
|
||||||
sudo useradd proxyuser
|
|
||||||
```
|
|
||||||
|
|
||||||
## Configure your container by modifying `env.properties` file
|
## Configure your container by modifying `env.properties` file
|
||||||
|
|
||||||
```properties
|
```properties
|
||||||
TRACING=1
|
TRACING=1
|
||||||
WATCHER_BTC_NODE_RPC_URL=btcnode:18332/wallet/watching01.dat
|
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_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
|
PROXY_LISTENING_PORT=8888
|
||||||
# Variable substitutions don't work
|
# Variable substitutions don't work
|
||||||
DB_PATH=/proxyuser/db
|
DB_PATH=/proxy/db
|
||||||
DB_FILE=/proxyuser/db/proxydb
|
DB_FILE=/proxy/db/proxydb
|
||||||
# Pycoin container
|
# Pycoin container
|
||||||
PYCOIN_CONTAINER=pycoinnode:7777
|
PYCOIN_CONTAINER=pycoinnode:7777
|
||||||
# OTS container
|
# OTS container
|
||||||
OTS_CONTAINER=otsnode:6666
|
OTS_CONTAINER=otsnode:6666
|
||||||
```
|
|
||||||
|
|
||||||
## Set your Watching Bitcoin node RPC credentials in `app/config/watcher_btcnode_curlcfg.properties`
|
DERIVATION_PUB32=upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb
|
||||||
|
DERIVATION_PATH=0/n
|
||||||
```properties
|
WATCHER_BTC_NODE_PRUNED=false
|
||||||
user=rpc_username:rpc_password
|
|
||||||
```
|
|
||||||
|
|
||||||
## Set your Spending Bitcoin node RPC credentials in `app/config/spender_btcnode_curlcfg.properties`
|
|
||||||
|
|
||||||
```properties
|
|
||||||
user=rpc_username:rpc_password
|
|
||||||
```
|
|
||||||
|
|
||||||
## Set your address derivation information in `app/config/derivation.properties`
|
|
||||||
|
|
||||||
```properties
|
|
||||||
derivation.xpub=upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb
|
|
||||||
derivation.path=0/n
|
|
||||||
watchingnode.pruned=false
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building docker image
|
## Building docker image
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker build -t btcproxyimg --build-arg USER_ID=$(id -u proxyuser) --build-arg GROUP_ID=$(id -g proxyuser) .
|
docker build -t btcproxyimg .
|
||||||
```
|
```
|
||||||
|
|
||||||
## Create sqlite3 database path and give rights
|
## Create sqlite3 database path and give rights
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
mkdir ~/btcproxydb ; sudo chown -R proxyuser:pi ~/btcproxydb ; sudo chmod g+ws ~/btcproxydb
|
mkdir ~/btcproxydb ; sudo chown -R cyphernode:pi ~/btcproxydb ; sudo chmod g+ws ~/btcproxydb
|
||||||
```
|
```
|
||||||
|
|
||||||
## What you MUST have in your Watching Bitcoin node's bitcoin.conf file
|
## What you MUST have in your Watching Bitcoin node's bitcoin.conf file
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
derivation.pub32=upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb
|
|
||||||
derivation.path=0/n
|
|
||||||
watchingnode.pruned=false
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
user=rpc_username:rpc_password
|
|
||||||
@@ -1 +0,0 @@
|
|||||||
user=rpc_username:rpc_password
|
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
. ./trace.sh
|
. ./trace.sh
|
||||||
. ./utils.sh
|
|
||||||
|
|
||||||
deriveindex()
|
deriveindex()
|
||||||
{
|
{
|
||||||
@@ -10,8 +9,8 @@ deriveindex()
|
|||||||
local index=${1}
|
local index=${1}
|
||||||
trace "[deriveindex] index=${index}"
|
trace "[deriveindex] index=${index}"
|
||||||
|
|
||||||
local pub32=$(get_prop "derivation.pub32")
|
local pub32=$DERIVATION_PUB32
|
||||||
local path=$(get_prop "derivation.path" | sed -En "s/n/${index}/p")
|
local path=$(echo -e $DERIVATION_PATH | sed -En "s/n/${index}/p")
|
||||||
# pub32=$(grep "derivation.pub32" config.properties | cut -d'=' -f2)
|
# pub32=$(grep "derivation.pub32" config.properties | cut -d'=' -f2)
|
||||||
# path=$(grep "derivation.path" config.properties | cut -d'=' -f2 | sed -En "s/n/${index}/p")
|
# path=$(grep "derivation.path" config.properties | cut -d'=' -f2 | sed -En "s/n/${index}/p")
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
compute_fees()
|
compute_fees()
|
||||||
{
|
{
|
||||||
local pruned=$(get_prop "watchingnode.pruned")
|
local pruned=${WATCHER_BTC_NODE_PRUNED}
|
||||||
if [ "${pruned}" = "true" ]; then
|
if [ "${pruned}" = "true" ]; then
|
||||||
trace "[compute_fees] pruned=${pruned}"
|
trace "[compute_fees] pruned=${pruned}"
|
||||||
# We want null instead of 0.00000000 in this case.
|
# We want null instead of 0.00000000 in this case.
|
||||||
|
|||||||
@@ -3,13 +3,39 @@
|
|||||||
export PROXY_LISTENING_PORT
|
export PROXY_LISTENING_PORT
|
||||||
export WATCHER_NODE_RPC_URL=$WATCHER_BTC_NODE_RPC_URL
|
export WATCHER_NODE_RPC_URL=$WATCHER_BTC_NODE_RPC_URL
|
||||||
export SPENDER_NODE_RPC_URL=$SPENDER_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 TRACING
|
||||||
export DB_PATH
|
export DB_PATH
|
||||||
export DB_FILE
|
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
|
if [ ! -e ${DB_FILE} ]; then
|
||||||
echo "DB not found, creating..." > /dev/stderr
|
echo "DB not found, creating..." 1>&2
|
||||||
cat watching.sql | sqlite3 $DB_FILE
|
cat watching.sql | sqlite3 $DB_FILE
|
||||||
fi
|
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
|
nc -vlkp${PROXY_LISTENING_PORT} -e ./requesthandler.sh
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
read line
|
read line
|
||||||
echo ${line} > /dev/stderr
|
echo ${line} 1>&2
|
||||||
echo -ne "HTTP/1.1 200 OK\r\n"
|
echo -ne "HTTP/1.1 200 OK\r\n"
|
||||||
echo -e "Content-Type: application/json\r\nContent-Length: 0\r\n\r\n"
|
echo -e "Content-Type: application/json\r\nContent-Length: 0\r\n\r\n"
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
trace()
|
trace()
|
||||||
{
|
{
|
||||||
if [ -n "${TRACING}" ]; then
|
if [ -n "${TRACING}" ]; then
|
||||||
echo "$(date -Is) ${1}" > /dev/stderr
|
echo "$(date -Is) ${1}" 1>&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_rc()
|
trace_rc()
|
||||||
{
|
{
|
||||||
if [ -n "${TRACING}" ]; then
|
if [ -n "${TRACING}" ]; then
|
||||||
echo "$(date -Is) Last return code: ${1}" > /dev/stderr
|
echo "$(date -Is) Last return code: ${1}" 1>&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,19 @@
|
|||||||
TRACING=1
|
TRACING=1
|
||||||
WATCHER_BTC_NODE_RPC_URL=btcnode:18332/wallet/watching01.dat
|
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_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
|
PROXY_LISTENING_PORT=8888
|
||||||
# Variable substitutions don't work
|
# Variable substitutions don't work
|
||||||
DB_PATH=/proxyuser/db
|
DB_PATH=/proxy/db
|
||||||
DB_FILE=/proxyuser/db/proxydb
|
DB_FILE=/proxy/db/proxydb
|
||||||
# Pycoin container
|
# Pycoin container
|
||||||
PYCOIN_CONTAINER=pycoinnode:7777
|
PYCOIN_CONTAINER=pycoinnode:7777
|
||||||
# OTS container
|
# OTS container
|
||||||
OTS_CONTAINER=otsnode:6666
|
OTS_CONTAINER=otsnode:6666
|
||||||
|
|
||||||
|
DERIVATION_PUB32=upub5GtUcgGed1aGH4HKQ3vMYrsmLXwmHhS1AeX33ZvDgZiyvkGhNTvGd2TA5Lr4v239Fzjj4ZY48t6wTtXUy2yRgapf37QHgt6KWEZ6bgsCLpb
|
||||||
|
DERIVATION_PATH=0/n
|
||||||
|
WATCHER_BTC_NODE_PRUNED=false
|
||||||
|
|||||||
@@ -1,31 +1,23 @@
|
|||||||
#FROM resin/raspberry-pi-alpine-python:3.6
|
#FROM resin/raspberry-pi-alpine-python:3.6
|
||||||
FROM python:3.6-alpine
|
FROM python:3.6-alpine
|
||||||
|
|
||||||
ARG USER_ID
|
ENV HOME /pycoin
|
||||||
ARG GROUP_ID
|
|
||||||
ENV USERNAME proxyuser
|
|
||||||
ENV HOME /${USERNAME}
|
|
||||||
ENV USER_ID ${USER_ID:-1000}
|
|
||||||
ENV GROUP_ID ${GROUP_ID:-1000}
|
|
||||||
|
|
||||||
RUN addgroup -g ${GROUP_ID} ${USERNAME} \
|
RUN apk add --update --no-cache git jq su-exec \
|
||||||
&& adduser -u ${USER_ID} -G ${USERNAME} -D -s /bin/sh -h ${HOME} ${USERNAME}
|
|
||||||
|
|
||||||
RUN apk add --update --no-cache git jq \
|
|
||||||
&& pip install --no-cache-dir pycoin \
|
&& pip install --no-cache-dir pycoin \
|
||||||
&& cd \
|
&& cd / \
|
||||||
&& git clone https://github.com/Kexkey/pycoin.git \
|
&& git clone https://github.com/Kexkey/pycoin.git \
|
||||||
&& cp -rf pycoin/pycoin/* /usr/local/lib/python3.6/site-packages/pycoin
|
&& cp -rf pycoin/pycoin/* /usr/local/lib/python3.6/site-packages/pycoin \
|
||||||
|
&& rm -rf pycoin/*
|
||||||
|
|
||||||
COPY --chown=proxyuser script/pycoin.sh ${HOME}/pycoin.sh
|
COPY script/pycoin.sh ${HOME}/pycoin.sh
|
||||||
COPY --chown=proxyuser script/requesthandler.sh ${HOME}/requesthandler.sh
|
COPY script/requesthandler.sh ${HOME}/requesthandler.sh
|
||||||
COPY --chown=proxyuser script/responsetoclient.sh ${HOME}/responsetoclient.sh
|
COPY script/responsetoclient.sh ${HOME}/responsetoclient.sh
|
||||||
COPY --chown=proxyuser script/startpycoin.sh ${HOME}/startpycoin.sh
|
COPY script/startpycoin.sh ${HOME}/startpycoin.sh
|
||||||
COPY --chown=proxyuser script/trace.sh ${HOME}/trace.sh
|
COPY script/trace.sh ${HOME}/trace.sh
|
||||||
|
|
||||||
USER ${USERNAME}
|
|
||||||
WORKDIR ${HOME}
|
WORKDIR ${HOME}
|
||||||
|
|
||||||
RUN chmod +x startpycoin.sh requesthandler.sh
|
RUN chmod +x startpycoin.sh requesthandler.sh
|
||||||
|
|
||||||
ENTRYPOINT ["./startpycoin.sh"]
|
ENTRYPOINT ["su-exec"]
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# Build image
|
# Build image
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
docker build -t pycoinimg --build-arg USER_ID=$(id -u proxyuser) --build-arg GROUP_ID=$(id -g proxyuser) .
|
docker build -t pycoinimg .
|
||||||
```
|
```
|
||||||
|
|
||||||
# Usefull examples
|
# Usefull examples
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
trace()
|
trace()
|
||||||
{
|
{
|
||||||
if [ -n "${TRACING}" ]; then
|
if [ -n "${TRACING}" ]; then
|
||||||
echo "$(date -Is) ${1}" > /dev/stderr
|
echo "$(date -Is) ${1}" 1>&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
trace_rc()
|
trace_rc()
|
||||||
{
|
{
|
||||||
if [ -n "${TRACING}" ]; then
|
if [ -n "${TRACING}" ]; then
|
||||||
echo "$(date -Is) Last return code: ${1}" > /dev/stderr
|
echo "$(date -Is) Last return code: ${1}" 1>&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user