Using bitcoin-client.conf and monitor bitcoin node for deployment

This commit is contained in:
kexkey
2019-09-03 12:33:14 -04:00
committed by kexkey
parent d8665a1ee1
commit 297af02fea
7 changed files with 391 additions and 170 deletions

122
build0.sh Normal file
View File

@@ -0,0 +1,122 @@
#!/bin/bash
a=$(curl -s --config /tmp/watcher_btcnode_curlcfg.properties -H "Content-Type: application/json" -d '{"method":"echo"}' bitcoin:18332/wallet/watching01.dat | jq -e ".error") ; [ "$?" -ne "0" ] && echo "ready"
curl -d '{"method":"echo"}' bitcoin:18332
echo -n 'f9beb4d9' | xxd -r -p
version\00\00\00\00\00
echo -n "711101000000000000000000c6925e5400000000000000000000000000000000000000000000ffff7f000001208d000000000000000000000000000000000000ffff7f000001208d00000000000000001b2f426974636f696e2e6f7267204578616d706c653a302e392e332f9305050000" | xxd -r -p
"I"
/ $ bitcoin-cli echo ; echo $?
error code: -28
error message:
Loading block index...
28
/ $ bitcoin-cli echo ; echo $?
error code: -28
error message:
Rewinding blocks...
28
/ $ bitcoin-cli echo ; echo $?
error code: -28
error message:
Loading wallet...
28
/ $ bitcoin-cli echo ; echo $?
[
]
0
/ $ a=1 ; while [ "$a" -ne "0" ]; do echo "not ready" ; sleep 2 ; bitcoin-cli echo ; a=$? ; done ; echo "ok"
not ready
[
]
ok
/ $ a=1 ; while [ "$a" -ne "0" ]; do echo "bitcoin not ready" ; sleep 2 ; bitcoin-cli echo ; a=$? ; done ; echo "ok"
not ready
error: Could not connect to the server bitcoin:18332 (error code 1 - "EOF reached")
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
not ready
error: Could not connect to the server bitcoin:18332 (error code 1 - "EOF reached")
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
not ready
error: Could not connect to the server bitcoin:18332 (error code 1 - "EOF reached")
Make sure the bitcoind server is running and that you are connecting to the correct RPC port.
not ready
error code: -28
error message:
Verifying wallet(s)...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Loading block index...
not ready
error code: -28
error message:
Rewinding blocks...
not ready
error code: -28
error message:
Rewinding blocks...
not ready
error code: -28
error message:
Rewinding blocks...
not ready
error code: -28
error message:
Loading wallet...
not ready
error code: -28
error message:
Loading P2P addresses...
not ready
[
]
ok
/ $

View File

@@ -17,7 +17,7 @@ const featureCondition = function(props) {
const templates = {
'lnd': [ path.join('lnd','lnd.conf') ],
'c-lightning': [ path.join('c-lightning','config'), path.join('c-lightning','bitcoin.conf') ]
'c-lightning': [ path.join('c-lightning','config') ]
};
module.exports = {

View File

@@ -104,6 +104,6 @@ module.exports = {
return 'VAR0=VALUE0\nVAR1=VALUE1'
},
templates: function( props ) {
return ['bitcoin.conf']
return ['bitcoin.conf', 'bitcoin-client.conf']
}
};

View File

@@ -1,11 +1,192 @@
version: "3"
services:
gatekeeper:
# HTTP authentication API gate
bitcoin_monitor:
image: cyphernode/bitcoin:<%= bitcoin_version %>
command: $USER sh -c 'rm -f /bitcoin_monitor/up ; while true ; do [ "$$(bitcoin-cli echo &> /dev/null ; echo $$?)" -eq "0" ] && touch /bitcoin_monitor/up || rm -f /bitcoin_monitor/up ; sleep 2 ; done'
volumes:
- bitcoin_monitor:/bitcoin_monitor
- "<%= bitcoin_datapath %>/bitcoin-client.conf:/root/.bitcoin/bitcoin.conf"
networks:
- cyphernodenet
restart: always
# deploy:
# placement:
# constraints: [node.hostname==dev]
<% if( bitcoin_mode === 'internal' ) { %>
##########################
# BITCOIN #
##########################
bitcoin:
image: cyphernode/bitcoin:<%= bitcoin_version %>
command: $USER bitcoind
<% if( bitcoin_expose ) { %>
ports:
- "<%= (net === 'regtest') ? '18443:18443' : ((net === 'testnet') ? '18332:18332' : '8332:8332') %>"
- "<%= (net === 'regtest') ? '18444:18444' : ((net === 'testnet') ? '18333:18333' : '8333:8333') %>"
<% } %>
volumes:
- "<%= bitcoin_datapath %>:/.bitcoin"
networks:
- cyphernodenet
restart: always
# deploy:
# placement:
# constraints: [node.hostname==dev]
<% } %>
##########################
# PROXY #
##########################
proxy:
image: cyphernode/proxy:<%= proxy_version %>
command: $USER ./startproxy.sh
environment:
- "TRACING=1"
- "WATCHER_BTC_NODE_RPC_URL=<%= (bitcoin_mode === 'internal') ? 'bitcoin' : bitcoin_node_ip %> : <%= (net === 'regtest') ? '18443' : ((net === 'testnet') ? '18332' : '8332') %>/wallet"
- "WATCHER_BTC_NODE_DEFAULT_WALLET=watching01.dat"
- "WATCHER_BTC_NODE_XPUB_WALLET=xpubwatching01.dat"
- "WATCHER_BTC_NODE_RPC_USER=<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>"
- "WATCHER_BTC_NODE_RPC_CFG=/tmp/watcher_btcnode_curlcfg.properties"
- "SPENDER_BTC_NODE_RPC_URL=<%= (bitcoin_mode === 'internal') ? 'bitcoin' : bitcoin_node_ip %> : <%= (net === 'regtest') ? '18443' : ((net === 'testnet') ? '18332' : '8332') %>/wallet"
- "SPENDER_BTC_NODE_DEFAULT_WALLET=spending01.dat"
- "SPENDER_BTC_NODE_RPC_USER=<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>"
- "SPENDER_BTC_NODE_RPC_CFG=/tmp/spender_btcnode_curlcfg.properties"
- "PROXY_LISTENING_PORT=8888"
- "DB_PATH=/proxy/db"
- "DB_FILE=/proxy/db/proxydb"
- "PYCOIN_CONTAINER=pycoin:7777"
<% if ( use_xpub && xpub ) { %>
- "DERIVATION_PUB32=<%= xpub %>"
- "DERIVATION_PATH=<%= derivation_path %>"
<% } %>
- "WATCHER_BTC_NODE_PRUNED=<%= bitcoin_prune ? 'true' : 'false' %>"
- "OTSCLIENT_CONTAINER=otsclient:6666"
- "OTS_FILES=/proxy/otsfiles"
- "XPUB_DERIVATION_GAP=100"
<% if ( devmode ) { %>
ports:
- "8888:8888"
<% } %>
volumes:
- "<%= proxy_datapath %>:/proxy/db"
<% if ( features.indexOf('lightning') !== -1 && lightning_implementation === 'c-lightning' ) { %>
- "<%= lightning_datapath %>:/.lightning"
<% } %>
<% if ( features.indexOf('otsclient') !== -1 ) { %>
- "<%= otsclient_datapath %>:/proxy/otsfiles"
<% } %>
networks:
- cyphernodenet
restart: always
# deploy:
# placement:
# constraints: [node.hostname==dev]
##########################
# PROXYCRON #
##########################
proxycron:
image: cyphernode/proxycron:<%= proxycron_version %>
environment:
- "TX_CONF_URL=proxy:8888/executecallbacks"
- "OTS_URL=proxy:8888/ots_backoffice"
networks:
- cyphernodenet
restart: always
depends_on:
- proxy
# deploy:
# placement:
# constraints: [node.hostname==dev]
##########################
# BROKER #
##########################
broker:
image: eclipse-mosquitto:1.6
networks:
- cyphernodenet
restart: always
# deploy:
# placement:
# constraints: [node.hostname==dev]
##########################
# NOTIFIER #
##########################
notifier:
image: cyphernode/notifier:<%= notifier_version %>
command: $USER ./startnotifier.sh
networks:
- cyphernodenet
- cyphernodeappsnet
restart: always
depends_on:
- broker
# deploy:
# placement:
# constraints: [node.hostname==dev]
##########################
# PYCOIN #
##########################
pycoin:
image: cyphernode/pycoin:<%= pycoin_version %>
command: $USER ./startpycoin.sh
environment:
- "TRACING=1"
- "PYCOIN_LISTENING_PORT=7777"
<% if ( devmode ) { %>
ports:
- "7777:7777"
<% } %>
networks:
- cyphernodenet
restart: always
# deploy:
# placement:
# constraints: [node.hostname==dev]
<% if ( features.indexOf('otsclient') !== -1 ) { %>
##########################
# OTSCLIENT #
##########################
otsclient:
image: cyphernode/otsclient:<%= otsclient_version %>
command: $USER /script/startotsclient.sh
environment:
- "TRACING=1"
- "OTSCLIENT_LISTENING_PORT=6666"
volumes:
- "<%= otsclient_datapath %>:/otsfiles"
networks:
- cyphernodenet
restart: always
# deploy:
# placement:
# constraints: [node.hostname==dev]
<% } %>
##########################
# GATEKEEPER #
##########################
gatekeeper:
# HTTP authentication API gate
image: cyphernode/gatekeeper:<%= gatekeeper_version %>
command: $USER
environment:
- "TRACING=1"
<% if( gatekeeper_expose ) { %>
ports:
- "<%= gatekeeper_port %>:<%= gatekeeper_port %>"
@@ -20,25 +201,25 @@ services:
- "<%= gatekeeper_datapath %>/installation.json:/etc/nginx/conf.d/s/stats/installation.json"
- "<%= gatekeeper_datapath %>/client.7z:/etc/nginx/conf.d/s/stats/client.7z"
- "<%= gatekeeper_datapath %>/config.7z:/etc/nginx/conf.d/s/stats/config.7z"
command: $USER
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
- cyphernodeappsnet
restart: always
traefik:
image: traefik:v1.7.9-alpine
restart: always
ports:
- 80:80
- 443:443
depends_on:
- proxy
# deploy:
# placement:
# constraints: [node.hostname==dev]
##########################
# TRAEFIK #
##########################
traefik:
image: traefik:v1.7.9-alpine
ports:
- 80:80
- 443:443
volumes:
- "/var/run/docker.sock:/var/run/docker.sock"
- "<%= traefik_datapath%>/traefik.toml:/traefik.toml"
@@ -46,156 +227,43 @@ services:
- "<%= traefik_datapath%>/htpasswd:/htpasswd/htpasswd"
networks:
- cyphernodeappsnet
restart: always
depends_on:
- gatekeeper
# deploy:
# placement:
# constraints: [node.hostname==dev]
proxy:
command: $USER ./startproxy.sh
# Bitcoin Mini Proxy
environment:
- "TRACING=1"
- "WATCHER_BTC_NODE_RPC_URL=<%= (bitcoin_mode === 'internal')?'bitcoin':bitcoin_node_ip %>:<%= (net === 'regtest')?'18443':((net === 'testnet')?'18332':'8332') %>/wallet"
- "WATCHER_BTC_NODE_DEFAULT_WALLET=watching01.dat"
- "WATCHER_BTC_NODE_XPUB_WALLET=xpubwatching01.dat"
- "WATCHER_BTC_NODE_RPC_USER=<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>"
- "WATCHER_BTC_NODE_RPC_CFG=/tmp/watcher_btcnode_curlcfg.properties"
- "SPENDER_BTC_NODE_RPC_URL=<%= (bitcoin_mode === 'internal')?'bitcoin':bitcoin_node_ip %>:<%= (net === 'regtest')?'18443':((net === 'testnet')?'18332':'8332') %>/wallet"
- "SPENDER_BTC_NODE_DEFAULT_WALLET=spending01.dat"
- "SPENDER_BTC_NODE_RPC_USER=<%= bitcoin_rpcuser %>:<%= bitcoin_rpcpassword %>"
- "SPENDER_BTC_NODE_RPC_CFG=/tmp/spender_btcnode_curlcfg.properties"
- "PROXY_LISTENING_PORT=8888"
- "DB_PATH=/proxy/db"
- "DB_FILE=/proxy/db/proxydb"
- "PYCOIN_CONTAINER=pycoin:7777"
<% if ( use_xpub && xpub ) { %>
- "DERIVATION_PUB32=<%= xpub %>"
- "DERIVATION_PATH=<%= derivation_path %>"
<% } %>
- "WATCHER_BTC_NODE_PRUNED=<%= bitcoin_prune?'true':'false' %>"
- "OTSCLIENT_CONTAINER=otsclient:6666"
- "OTS_FILES=/proxy/otsfiles"
- "XPUB_DERIVATION_GAP=100"
image: cyphernode/proxy:<%= proxy_version %>
<% if ( devmode ) { %>
ports:
- "8888:8888"
<% } %>
volumes:
- "<%= proxy_datapath %>:/proxy/db"
<% if ( features.indexOf('lightning') !== -1 && lightning_implementation === 'c-lightning' ) { %>
- "<%= lightning_datapath %>:/.lightning"
<% } %>
<% if ( features.indexOf('otsclient') !== -1 ) { %>
- "<%= otsclient_datapath %>:/proxy/otsfiles"
<% } %>
##########################
# LIGHTNING #
##########################
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
restart: always
proxycron:
environment:
- "TX_CONF_URL=proxy:8888/executecallbacks"
- "OTS_URL=proxy:8888/ots_backoffice"
image: cyphernode/proxycron:<%= proxycron_version %>
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
restart: always
pycoin:
# Pycoin
command: $USER ./startpycoin.sh
image: cyphernode/pycoin:<%= pycoin_version %>
environment:
- "TRACING=1"
- "PYCOIN_LISTENING_PORT=7777"
<% if ( devmode ) { %>
ports:
- "7777:7777"
<% } %>
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
restart: always
<% if ( features.indexOf('lightning') !== -1 && lightning_implementation === 'c-lightning' ) { %>
lightning:
command: $USER lightningd
image: cyphernode/clightning:<%= lightning_version %>
# command: $USER sh -c 'a=1 ; while [ "$$a" -ne "0" ]; do echo "bitcoin not ready" ; sleep 2 ; bitcoin-cli echo ; a=$$? ; done ; echo "bitcoin ready!" ; lightningd'
# command: $USER sh -c 'while [ "$$(bitcoin-cli echo &> /dev/null ; echo $$?)" -ne "0" ]; do echo "bitcoin not ready" ; sleep 2 ; done ; echo "bitcoin ready!" ; lightningd'
command: $USER sh -c 'while [ ! -f "/bitcoin_monitor/up" ]; do echo "bitcoin not ready" ; sleep 2 ; done ; echo "bitcoin ready!" ; lightningd'
<% if( lightning_expose ) { %>
ports:
- "9735:9735"
<% } %>
volumes:
- "<%= lightning_datapath %>:/.lightning"
- "<%= lightning_datapath %>/bitcoin.conf:/.bitcoin/bitcoin.conf"
# deploy:
# placement:
# constraints: [node.hostname==dev]
- "<%= bitcoin_datapath %>/bitcoin-client.conf:/.bitcoin/bitcoin.conf"
- bitcoin_monitor:/bitcoin_monitor:ro
networks:
- cyphernodenet
restart: always
depends_on:
- bitcoin
# deploy:
# placement:
# constraints: [node.hostname==dev]
<% } %>
<% } %>
<% if ( features.indexOf('otsclient') !== -1 ) { %>
otsclient:
environment:
- "TRACING=1"
- "OTSCLIENT_LISTENING_PORT=6666"
image: cyphernode/otsclient:<%= otsclient_version %>
# deploy:
# placement:
# constraints: [node.hostname==dev]
volumes:
- "<%= otsclient_datapath %>:/otsfiles"
command: $USER /script/startotsclient.sh
networks:
- cyphernodenet
restart: always
<% } %>
<% if( bitcoin_mode === 'internal' ) { %>
bitcoin:
command: $USER bitcoind
image: cyphernode/bitcoin:<%= bitcoin_version %>
<% if( bitcoin_expose ) { %>
ports:
- "<%= (net === 'regtest')?'18443:18443':((net === 'testnet')?'18332:18332':'8332:8332') %>"
- "<%= (net === 'regtest')?'18444:18444':((net === 'testnet')?'18333:18333':'8333:8333') %>"
<% } %>
# deploy:
# placement:
# constraints: [node.hostname==dev]
volumes:
- "<%= bitcoin_datapath %>:/.bitcoin"
networks:
- cyphernodenet
restart: always
<% } %>
broker:
image: eclipse-mosquitto:1.6
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
restart: always
notifier:
image: cyphernode/notifier:<%= notifier_version %>
command: $USER ./startnotifier.sh
# deploy:
# placement:
# constraints: [node.hostname==dev]
networks:
- cyphernodenet
- cyphernodeappsnet
restart: always
volumes:
bitcoin_monitor:
networks:
cyphernodenet:

View File

@@ -261,7 +261,11 @@ feature_status() {
echo "EXIT_STATUS=1" > /dist/exitStatus.sh
brokenproxy="false"
#############################
# Ping containers and PROXY #
#############################
workingproxy="true"
containers=$(checkservice)
returncode=$?
finalreturncode=${returncode}
@@ -270,7 +274,7 @@ if [ "${returncode}" -ne "0" ]; then
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"proxy\") | .active")
if [ "${status}" = "false" ]; then
echo -e "\e[1;31mThe Proxy, the main Cyphernode's component, is not responding. We will only test the gatekeeper if its container is up, but you'll see errors for the other components. Please check the logs." > /dev/console
brokenproxy="true"
workingproxy="false"
fi
else
echo -e "\e[1;36mCyphernode seems to be correctly deployed. Let's run more thourough tests..." > /dev/console
@@ -285,7 +289,11 @@ fi
# { "name": "lightning", "working":true },
# ]
result="${containers},\"features\":[{\"coreFeature\":true, \"name\":\"proxy\",\"working\":true}, {\"coreFeature\":true, \"name\":\"gatekeeper\",\"working\":"
#############################
# GATEKEEPER #
#############################
result="${containers},\"features\":[{\"coreFeature\":true, \"name\":\"proxy\",\"working\":${workingproxy}}, {\"coreFeature\":true, \"name\":\"gatekeeper\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"gatekeeper\") | .active")
if [ "${status}" = "true" ]; then
timeout_feature checkgatekeeper
@@ -296,20 +304,13 @@ fi
finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Gatekeeper error!')}"
result="${result},{\"coreFeature\":true, \"name\":\"bitcoin\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"bitcoin\") | .active")
if [[ "${brokenproxy}" != "true" && "${status}" = "true" ]]; then
timeout_feature checkbitcoinnode
returncode=$?
else
returncode=1
fi
finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Bitcoin error!')}"
#############################
# BROKER #
#############################
result="${result},{\"coreFeature\":true, \"name\":\"broker\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"broker\") | .active")
if [[ "${brokenproxy}" != "true" && "${status}" = "true" ]]; then
if [[ "${workingproxy}" = "true" && "${status}" = "true" ]]; then
timeout_feature checkbroker
returncode=$?
else
@@ -318,9 +319,13 @@ fi
finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Broker error!')}"
#############################
# NOTIFIER #
#############################
result="${result},{\"coreFeature\":true, \"name\":\"notifier\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"notifier\") | .active")
if [[ "${brokenproxy}" != "true" && "${status}" = "true" ]]; then
if [[ "${workingproxy}" = "true" && "${status}" = "true" ]]; then
timeout_feature checknotifier
returncode=$?
else
@@ -329,9 +334,13 @@ fi
finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Notifier error!')}"
#############################
# PYCOIN #
#############################
result="${result},{\"coreFeature\":true, \"name\":\"pycoin\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"pycoin\") | .active")
if [[ "${brokenproxy}" != "true" && "${status}" = "true" ]]; then
if [[ "${workingproxy}" = "true" && "${status}" = "true" ]]; then
timeout_feature checkpycoin
returncode=$?
else
@@ -340,10 +349,14 @@ fi
finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Pycoin error!')}"
#############################
# OTSCLIENT #
#############################
<% if (features.indexOf('otsclient') != -1) { %>
result="${result},{\"coreFeature\":false, \"name\":\"otsclient\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"otsclient\") | .active")
if [[ "${brokenproxy}" != "true" && "${status}" = "true" ]]; then
if [[ "${workingproxy}" = "true" && "${status}" = "true" ]]; then
timeout_feature checkots
returncode=$?
else
@@ -353,10 +366,29 @@ finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'OTSclient error!')}"
<% } %>
#############################
# BITCOIN #
#############################
result="${result},{\"coreFeature\":true, \"name\":\"bitcoin\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"bitcoin\") | .active")
if [[ "${workingproxy}" = "true" && "${status}" = "true" ]]; then
timeout_feature checkbitcoinnode
returncode=$?
else
returncode=1
fi
finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Bitcoin error!')}"
#############################
# LIGHTNING #
#############################
<% if (features.indexOf('lightning') != -1) { %>
result="${result},{\"coreFeature\":false, \"name\":\"lightning\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"lightning\") | .active")
if [[ "${brokenproxy}" != "true" && "${status}" = "true" ]]; then
if [[ "${workingproxy}" = "true" && "${status}" = "true" ]]; then
timeout_feature checklnnode
returncode=$?
else

1
dist/setup.sh vendored
View File

@@ -461,7 +461,6 @@ install_docker() {
fi
copy_file $cyphernodeconf_filepath/lightning/c-lightning/config $LIGHTNING_DATAPATH/config 1 $SUDO_REQUIRED
copy_file $cyphernodeconf_filepath/lightning/c-lightning/bitcoin.conf $LIGHTNING_DATAPATH/bitcoin.conf 1 $SUDO_REQUIRED
fi
fi