Spark Wallet integration, first pass

This commit is contained in:
kexkey
2019-01-16 20:37:22 -05:00
committed by kexkey
parent d89abfe155
commit 6ee834d944
10 changed files with 133 additions and 16 deletions

View File

@@ -14,6 +14,22 @@ server {
index statuspage.html; index statuspage.html;
} }
location /sparkwallet/ {
auth_basic "sparkwallet";
auth_basic_user_file conf.d/status/htpasswd;
proxy_set_header Host $host;
proxy_set_header Referer $http_referer;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Authorization "Basic Y3lwaGVybm9kZTpzcGFya3dhbGxldA==";
proxy_pass http://sparkwallet:9737/;
}
location /v0/ { location /v0/ {
auth_request /auth; auth_request /auth;
proxy_pass http://proxy:8888/; proxy_pass http://proxy:8888/;

View File

@@ -48,6 +48,7 @@
<ul> <ul>
<li><a href="config.7z">Download your Cyphernode <b>configurations</b>, can be used for another Cyphernode deployment</a></li> <li><a href="config.7z">Download your Cyphernode <b>configurations</b>, can be used for another Cyphernode deployment</a></li>
<li><a href="client.7z">Download Client <b>API ID's and keys</b>, needed in your client apps</a></li> <li><a href="client.7z">Download Client <b>API ID's and keys</b>, needed in your client apps</a></li>
<li><a href="/sparkwallet">Your Lightning Network Wallet (Spark Wallet)</a></li>
</ul> </ul>
</div> </div>
<div id="Status"> <div id="Status">

18
dist/setup.sh vendored
View File

@@ -110,7 +110,7 @@ sudo_if_required() {
} }
modify_permissions() { modify_permissions() {
local directories=("installer" "gatekeeper" "lightning" "bitcoin" "docker-compose.yaml" "$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH") local directories=("installer" "gatekeeper" "lightning" "sparkwallet" "bitcoin" "docker-compose.yaml" "$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH")
for d in "${directories[@]}" for d in "${directories[@]}"
do do
if [[ -e $d ]]; then if [[ -e $d ]]; then
@@ -122,7 +122,7 @@ modify_permissions() {
} }
modify_owner() { modify_owner() {
local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH") local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$SPARKWALLET_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH" "$OTSCLIENT_DATAPATH")
local user=$(id -u $RUN_AS_USER):$(id -g $RUN_AS_USER) local user=$(id -u $RUN_AS_USER):$(id -g $RUN_AS_USER)
for d in "${directories[@]}" for d in "${directories[@]}"
do do
@@ -194,6 +194,7 @@ configure() {
-e PYCOIN_VERSION=$PYCOIN_VERSION \ -e PYCOIN_VERSION=$PYCOIN_VERSION \
-e BITCOIN_VERSION=$BITCOIN_VERSION \ -e BITCOIN_VERSION=$BITCOIN_VERSION \
-e LIGHTNING_VERSION=$LIGHTNING_VERSION \ -e LIGHTNING_VERSION=$LIGHTNING_VERSION \
-e SPARKWALLET_VERSION=$SPARKWALLET_VERSION \
--log-driver=none$pw_env \ --log-driver=none$pw_env \
--network none \ --network none \
--rm$interactive cyphernode/cyphernodeconf:$CONF_VERSION $user yo --no-insight cyphernode$gen_options $recreate --rm$interactive cyphernode/cyphernodeconf:$CONF_VERSION $user yo --no-insight cyphernode$gen_options $recreate
@@ -453,6 +454,14 @@ install_docker() {
copy_file $current_path/lightning/c-lightning/bitcoin.conf $LIGHTNING_DATAPATH/bitcoin.conf 1 $SUDO_REQUIRED copy_file $current_path/lightning/c-lightning/bitcoin.conf $LIGHTNING_DATAPATH/bitcoin.conf 1 $SUDO_REQUIRED
fi fi
fi fi
if [[ $FEATURE_SPARKWALLET == true ]]; then
if [ ! -d $SPARKWALLET_DATAPATH ]; then
step " create $SPARKWALLET_DATAPATH"
sudo_if_required mkdir -p $SPARKWALLET_DATAPATH
next
fi
fi
fi fi
if [[ $FEATURE_OTSCLIENT == true ]]; then if [[ $FEATURE_OTSCLIENT == true ]]; then
@@ -524,7 +533,7 @@ install_docker() {
check_directory_owner() { check_directory_owner() {
# if one directory does not have access rights for $RUN_AS_USER, we echo 1, else we echo 0 # if one directory does not have access rights for $RUN_AS_USER, we echo 1, else we echo 0
local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH") local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$SPARKWALLET_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH")
local status=0 local status=0
for d in "${directories[@]}" for d in "${directories[@]}"
do do
@@ -628,7 +637,7 @@ sanity_checks_pre_install() {
if [[ $sudo_reason == 'directories' ]]; then if [[ $sudo_reason == 'directories' ]]; then
echo " or check your data volumes if they have the right owner." echo " or check your data volumes if they have the right owner."
echo " The owner of the following folders should be '$RUN_AS_USER':" echo " The owner of the following folders should be '$RUN_AS_USER':"
local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH") local directories=("$BITCOIN_DATAPATH" "$LIGHTNING_DATAPATH" "$SPARKWALLET_DATAPATH" "$PROXY_DATAPATH" "$GATEKEEPER_DATAPATH")
local status=0 local status=0
for d in "${directories[@]}" for d in "${directories[@]}"
do do
@@ -673,6 +682,7 @@ OTSCLIENT_VERSION="v0.1.1"
PYCOIN_VERSION="v0.1.1" PYCOIN_VERSION="v0.1.1"
BITCOIN_VERSION="v0.17.0" BITCOIN_VERSION="v0.17.0"
LIGHTNING_VERSION="v0.6.2" LIGHTNING_VERSION="v0.6.2"
SPARKWALLET_VERSION="standalone"
SETUP_DIR=$(dirname $(realpath $0)) SETUP_DIR=$(dirname $(realpath $0))

View File

@@ -3,6 +3,10 @@
"name": "Lightning node", "name": "Lightning node",
"value": "lightning" "value": "lightning"
}, },
{
"name": "Spark Wallet (LN)",
"value": "sparkwallet"
},
{ {
"name": "Opentimestamps client", "name": "Opentimestamps client",
"value": "otsclient" "value": "otsclient"

View File

@@ -34,6 +34,8 @@
"lightning_datapath": "<font underline='true'>Path name</font> to where LN's data files are stored. This directory will be mounted into the LN node's container. <font color='#ff0000'>If running on OSX, check mountable directories in Docker's File Sharing configs.</font>", "lightning_datapath": "<font underline='true'>Path name</font> to where LN's data files are stored. This directory will be mounted into the LN node's container. <font color='#ff0000'>If running on OSX, check mountable directories in Docker's File Sharing configs.</font>",
"lightning_datapath_custom": " ", "lightning_datapath_custom": " ",
"lightning_expose": "By default, LN node port will be <font underline='true'>published</font> outside of Docker. Do you want to hide it so that your node can't be accessed from outside of the Docker network?", "lightning_expose": "By default, LN node port will be <font underline='true'>published</font> outside of Docker. Do you want to hide it so that your node can't be accessed from outside of the Docker network?",
"sparkwallet_datapath": "<font underline='true'>Path name</font> to where sparkwallet data files are stored. This directory will be mounted into the sparkwallet container. <font color='#ff0000'>If running on OSX, check mountable directories in Docker's File Sharing configs.</font>",
"sparkwallet_datapath_custom": " ",
"otsclient_datapath": "<font underline='true'>Full path</font> where the OTS files will be stored. This path will be mounted into the otsclient container which will create the OTS files when <font color='#00ff00'>stamping</font> and update them when <font color='#00ff00'>upgrading</font> stamps. It will also be mounted to the proxy container so that it can serve the <font color='#00ff00'>ots_getfile</font> and send the OTS files to clients. <font color='#ff0000'>If running on OSX, check mountable directories in Docker's File Sharing configs.</font>", "otsclient_datapath": "<font underline='true'>Full path</font> where the OTS files will be stored. This path will be mounted into the otsclient container which will create the OTS files when <font color='#00ff00'>stamping</font> and update them when <font color='#00ff00'>upgrading</font> stamps. It will also be mounted to the proxy container so that it can serve the <font color='#00ff00'>ots_getfile</font> and send the OTS files to clients. <font color='#ff0000'>If running on OSX, check mountable directories in Docker's File Sharing configs.</font>",
"otsclient_datapath_custom": " ", "otsclient_datapath_custom": " ",
"installer_mode": "Only one <font underline='true'>installation mode</font> is supported, right now: <font color='#0000ff'>local docker (self-hosted)</font>. Choose wisely ;-)", "installer_mode": "Only one <font underline='true'>installation mode</font> is supported, right now: <font color='#0000ff'>local docker (self-hosted)</font>. Choose wisely ;-)",

View File

@@ -224,6 +224,7 @@ module.exports = class extends Generator {
delete this.props.otsclient_version; delete this.props.otsclient_version;
delete this.props.bitcoin_version; delete this.props.bitcoin_version;
delete this.props.lightning_version; delete this.props.lightning_version;
delete this.props.sparkwallet_version;
delete this.props.grafana_version; delete this.props.grafana_version;
} }
@@ -359,6 +360,7 @@ module.exports = class extends Generator {
'proxy_datapath', 'proxy_datapath',
'bitcoin_datapath', 'bitcoin_datapath',
'lightning_datapath', 'lightning_datapath',
'sparkwallet_datapath',
'otsclient_datapath' 'otsclient_datapath'
]; ];
@@ -448,6 +450,7 @@ module.exports = class extends Generator {
lightning_datapath: '', lightning_datapath: '',
lightning_nodename: name.generate(), lightning_nodename: name.generate(),
lightning_nodecolor: '', lightning_nodecolor: '',
sparkwallet_datapath: '',
otsclient_datapath: '', otsclient_datapath: '',
installer_cleanup: false, installer_cleanup: false,
default_username: process.env.DEFAULT_USER || '', default_username: process.env.DEFAULT_USER || '',
@@ -457,7 +460,8 @@ module.exports = class extends Generator {
pycoin_version: process.env.PYCOIN_VERSION || 'latest', pycoin_version: process.env.PYCOIN_VERSION || 'latest',
otsclient_version: process.env.OTSCLIENT_VERSION || 'latest', otsclient_version: process.env.OTSCLIENT_VERSION || 'latest',
bitcoin_version: process.env.BITCOIN_VERSION || 'latest', bitcoin_version: process.env.BITCOIN_VERSION || 'latest',
lightning_version: process.env.LIGHTNING_VERSION || 'latest' lightning_version: process.env.LIGHTNING_VERSION || 'latest',
sparkwallet_version: process.env.SPARKWALLET_VERSION || 'standalone'
}, this.props ); }, this.props );
} }

View File

@@ -182,6 +182,40 @@ module.exports = {
validate: utils._pathValidator, validate: utils._pathValidator,
message: prefix()+'Custom path for your lightning node data?'+utils._getHelp('lightning_datapath_custom'), message: prefix()+'Custom path for your lightning node data?'+utils._getHelp('lightning_datapath_custom'),
}, },
{
when: function(props) { return installerDocker(props) && props.features.indexOf('sparkwallet') !== -1 },
type: 'list',
name: 'sparkwallet_datapath',
default: utils._getDefault( 'sparkwallet_datapath' ),
choices: [
{
name: "/var/run/cyphernode/sparkwallet (needs sudo - "+chalk.red('incompatible with OSX')+")",
value: "/var/run/cyphernode/sparkwallet"
},
{
name: "~/.cyphernode/sparkwallet",
value: "~/.cyphernode/sparkwallet"
},
{
name: "~/sparkwallet",
value: "~/sparkwallet"
},
{
name: "Custom path",
value: "_custom"
}
],
message: prefix()+'Where do you want to store your sparkwallet data?'+utils._getHelp('sparkwallet_datapath'),
},
{
when: function(props) { return installerDocker(props) && props.features.indexOf('sparkwallet') !== -1 && props.sparkwallet_datapath === '_custom'},
type: 'input',
name: 'sparkwallet_datapath_custom',
default: utils._getDefault( 'sparkwallet_datapath_custom' ),
filter: utils._trimFilter,
validate: utils._pathValidator,
message: prefix()+'Custom path for your sparkwallet data?'+utils._getHelp('sparkwallet_datapath_custom'),
},
{ {
when: function(props) { return installerDocker(props) && props.features.indexOf('otsclient') !== -1 }, when: function(props) { return installerDocker(props) && props.features.indexOf('otsclient') !== -1 },
type: 'list', type: 'list',

View File

@@ -1,6 +1,7 @@
INSTALLER_MODE=<%= installer_mode %> INSTALLER_MODE=<%= installer_mode %>
BITCOIN_INTERNAL=<%= (bitcoin_mode==="internal"?'true':'false') %> BITCOIN_INTERNAL=<%= (bitcoin_mode==="internal"?'true':'false') %>
FEATURE_LIGHTNING=<%= (features.indexOf('lightning') != -1)?'true':'false' %> FEATURE_LIGHTNING=<%= (features.indexOf('lightning') != -1)?'true':'false' %>
FEATURE_SPARKWALLET=<%= (features.indexOf('sparkwallet') != -1)?'true':'false' %>
FEATURE_OTSCLIENT=<%= (features.indexOf('otsclient') != -1)?'true':'false' %> FEATURE_OTSCLIENT=<%= (features.indexOf('otsclient') != -1)?'true':'false' %>
LIGHTNING_IMPLEMENTATION=<%= lightning_implementation %> LIGHTNING_IMPLEMENTATION=<%= lightning_implementation %>
PROXY_DATAPATH=<%= proxy_datapath %> PROXY_DATAPATH=<%= proxy_datapath %>
@@ -11,6 +12,9 @@ CLEANUP=<%= installer_cleanup?'true':'false' %>
<% if ( features.indexOf('lightning') !== -1 && lightning_implementation === 'c-lightning' ) { %> <% if ( features.indexOf('lightning') !== -1 && lightning_implementation === 'c-lightning' ) { %>
LIGHTNING_DATAPATH=<%= lightning_datapath %> LIGHTNING_DATAPATH=<%= lightning_datapath %>
<% } %> <% } %>
<% if ( features.indexOf('sparkwallet') !== -1 ) { %>
SPARKWALLET_DATAPATH=<%= sparkwallet_datapath %>
<% } %>
<% if ( features.indexOf('otsclient') !== -1 ) { %> <% if ( features.indexOf('otsclient') !== -1 ) { %>
OTSCLIENT_DATAPATH=<%= otsclient_datapath %> OTSCLIENT_DATAPATH=<%= otsclient_datapath %>
<% } %> <% } %>

View File

@@ -109,8 +109,8 @@ services:
- "9735:9735" - "9735:9735"
<% } %> <% } %>
volumes: volumes:
- "<%= lightning_datapath%>:/.lightning" - "<%= lightning_datapath %>:/.lightning"
- "<%= lightning_datapath%>/bitcoin.conf:/.bitcoin/bitcoin.conf" - "<%= lightning_datapath %>/bitcoin.conf:/.bitcoin/bitcoin.conf"
# deploy: # deploy:
# placement: # placement:
# constraints: [node.hostname==dev] # constraints: [node.hostname==dev]
@@ -128,7 +128,7 @@ services:
# placement: # placement:
# constraints: [node.hostname==dev] # constraints: [node.hostname==dev]
volumes: volumes:
- "<%= otsclient_datapath%>:/otsfiles" - "<%= otsclient_datapath %>:/otsfiles"
command: $USER /script/startotsclient.sh command: $USER /script/startotsclient.sh
networks: networks:
- cyphernodenet - cyphernodenet
@@ -144,11 +144,24 @@ services:
- "<%= (net === 'mainnet')?'8332:8332':'18332:18332' %>" - "<%= (net === 'mainnet')?'8332:8332':'18332:18332' %>"
<% } %> <% } %>
volumes: volumes:
- "<%= bitcoin_datapath%>:/.bitcoin" - "<%= bitcoin_datapath %>:/.bitcoin"
networks: networks:
- cyphernodenet - cyphernodenet
restart: always restart: always
<% } %> <% } %>
<% if ( features.indexOf('sparkwallet') !== -1 ) { %>
sparkwallet:
command: --login "cyphernode:sparkwallet" --no-tls
image: shesek/spark-wallet:standalone
volumes:
- "<%= lightning_datapath %>:/etc/lightning"
- "<%= sparkwallet_datapath %>:/data"
networks:
- cyphernodenet
restart: always
<% } %>
networks: networks:
cyphernodenet: cyphernodenet:
external: true external: true

View File

@@ -120,6 +120,18 @@ checklnnode() {
return 0 return 0
} }
checksparkwallet() {
echo -en "\r\n\e[1;36mTesting Spark Wallet... " > /dev/console
local rc
rc=$(curl -s -o /dev/null -w "%{http_code}" https://gatekeeper/sparkwallet)
[ "${rc}" -ne "200" ] && return 400
echo -e "\e[1;36mSpark Wallet rocks!" > /dev/console
return 0
}
checkservice() { checkservice() {
local interval=10 local interval=10
local totaltime=120 local totaltime=120
@@ -133,12 +145,12 @@ checkservice() {
while : while :
do do
outcome=0 outcome=0
for container in gatekeeper proxy proxycron pycoin <%= (features.indexOf('otsclient') != -1)?'otsclient ':'' %>bitcoin <%= (features.indexOf('lightning') != -1)?'lightning ':'' %>; do for container in gatekeeper proxy proxycron pycoin <%= (features.indexOf('otsclient') != -1)?'otsclient ':'' %>bitcoin <%= (features.indexOf('lightning') != -1)?'lightning ':'' %> <%= (features.indexOf('sparkwallet') != -1)?'sparkwallet ':'' %>; do
echo -e " \e[0;32mVerifying \e[0;33m${container}\e[0;32m..." > /dev/console echo -e " \e[0;32mVerifying \e[0;33m${container}\e[0;32m..." > /dev/console
(ping -c 10 ${container} 2> /dev/null | grep "0% packet loss" > /dev/null) & (ping -c 10 ${container} 2> /dev/null | grep "0% packet loss" > /dev/null) &
eval ${container}=$! eval ${container}=$!
done done
for container in gatekeeper proxy proxycron pycoin <%= (features.indexOf('otsclient') != -1)?'otsclient ':'' %>bitcoin <%= (features.indexOf('lightning') != -1)?'lightning ':'' %>; do for container in gatekeeper proxy proxycron pycoin <%= (features.indexOf('otsclient') != -1)?'otsclient ':'' %>bitcoin <%= (features.indexOf('lightning') != -1)?'lightning ':'' %> <%= (features.indexOf('sparkwallet') != -1)?'sparkwallet ':'' %>; do
eval wait '$'${container} ; returncode=$? ; outcome=$((${outcome} + ${returncode})) eval wait '$'${container} ; returncode=$? ; outcome=$((${outcome} + ${returncode}))
eval c_${container}=${returncode} eval c_${container}=${returncode}
done done
@@ -158,9 +170,10 @@ checkservice() {
# { "name": "pycoin", "active":true }, # { "name": "pycoin", "active":true },
# { "name": "otsclient", "active":true }, # { "name": "otsclient", "active":true },
# { "name": "bitcoin", "active":true }, # { "name": "bitcoin", "active":true },
# { "name": "lightning", "active":true } # { "name": "lightning", "active":true },
# { "name": "sparkwallet", "active":true }
# ] # ]
for container in gatekeeper proxy proxycron pycoin <%= (features.indexOf('otsclient') != -1)?'otsclient ':'' %>bitcoin <%= (features.indexOf('lightning') != -1)?'lightning ':'' %>; do for container in gatekeeper proxy proxycron pycoin <%= (features.indexOf('otsclient') != -1)?'otsclient ':'' %>bitcoin <%= (features.indexOf('lightning') != -1)?'lightning ':'' %> <%= (features.indexOf('sparkwallet') != -1)?'sparkwallet ':'' %>; do
[ -n "${result}" ] && result="${result}," [ -n "${result}" ] && result="${result},"
result="${result}{\"name\":\"${container}\",\"active\":" result="${result}{\"name\":\"${container}\",\"active\":"
eval "returncode=\$c_${container}" eval "returncode=\$c_${container}"
@@ -218,14 +231,16 @@ feature_status() {
# { "name": "pycoin", "active":true }, # { "name": "pycoin", "active":true },
# { "name": "otsclient", "active":true }, # { "name": "otsclient", "active":true },
# { "name": "bitcoin", "active":true }, # { "name": "bitcoin", "active":true },
# { "name": "lightning", "active":true } # { "name": "lightning", "active":true },
# { "name": "sparkwallet", "active":true }
# ], # ],
# "features": [ # "features": [
# { "name": "gatekeeper", "working":true }, # { "name": "gatekeeper", "working":true },
# { "name": "pycoin", "working":true }, # { "name": "pycoin", "working":true },
# { "name": "otsclient", "working":true }, # { "name": "otsclient", "working":true },
# { "name": "bitcoin", "working":true }, # { "name": "bitcoin", "working":true },
# { "name": "lightning", "working":true } # { "name": "lightning", "working":true },
# { "name": "sparkwallet", "working":true }
# ] # ]
#} #}
@@ -254,7 +269,8 @@ fi
# { "name": "pycoin", "working":true }, # { "name": "pycoin", "working":true },
# { "name": "otsclient", "working":true }, # { "name": "otsclient", "working":true },
# { "name": "bitcoin", "working":true }, # { "name": "bitcoin", "working":true },
# { "name": "lightning", "working":true } # { "name": "lightning", "working":true },
# { "name": "sparkwallet", "working":true }
# ] # ]
result="${containers},\"features\":[{\"name\":\"gatekeeper\",\"working\":" result="${containers},\"features\":[{\"name\":\"gatekeeper\",\"working\":"
@@ -316,6 +332,19 @@ finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Lightning error!')}" result="${result}$(feature_status ${returncode} 'Lightning error!')}"
<% } %> <% } %>
<% if (features.indexOf('sparkwallet') != -1) { %>
result="${result},{\"name\":\"sparkwallet\",\"working\":"
status=$(echo "{${containers}}" | jq ".containers[] | select(.name == \"sparkwallet\") | .active")
if [[ "${brokenproxy}" != "true" && "${status}" = "true" ]]; then
timeout_feature checklnnode
returncode=$?
else
returncode=1
fi
finalreturncode=$((${returncode} | ${finalreturncode}))
result="${result}$(feature_status ${returncode} 'Spark Wallet error!')}"
<% } %>
result="{${result}]}" result="{${result}]}"
echo "${result}" > /gatekeeper/installation.json echo "${result}" > /gatekeeper/installation.json