2020-12-15 00:44:48 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2020-12-15 20:29:28 +00:00
|
|
|
source /home/joinmarket/_functions.sh
|
|
|
|
|
|
2021-02-09 17:05:39 +00:00
|
|
|
# check connectedRemoteNode var in joinin.conf
|
|
|
|
|
if ! grep -Eq "^connectedRemoteNode=" /home/joinmarket/joinin.conf; then
|
|
|
|
|
echo "connectedRemoteNode=off" >> /home/joinmarket/joinin.conf
|
|
|
|
|
fi
|
2020-12-15 00:44:48 +00:00
|
|
|
clear
|
|
|
|
|
|
2020-12-15 20:29:28 +00:00
|
|
|
generateJMconfig
|
|
|
|
|
|
2021-01-05 02:00:23 +00:00
|
|
|
function displayHelp {
|
|
|
|
|
echo "# See how to prepare a remote node to accept the JoinMarket connection:"
|
|
|
|
|
echo "# https://github.com/openoms/joininbox/blob/master/prepare_remote_node.md#prepare-a-remote-node-to-accept-the-joinmarket-connection"
|
|
|
|
|
}
|
2021-01-03 23:23:16 +00:00
|
|
|
|
|
|
|
|
function inputRPC {
|
2020-12-15 00:44:48 +00:00
|
|
|
echo
|
|
|
|
|
echo "Input the RPC username of the remote bitcoin node:"
|
|
|
|
|
read rpc_user
|
|
|
|
|
echo "Input the RPC password of the remote node:"
|
|
|
|
|
read rpc_pass
|
|
|
|
|
echo "Type or paste the LAN IP or .onion address of the remote node:"
|
|
|
|
|
read rpc_host
|
|
|
|
|
echo "Input the RPC port (8332 by default):"
|
|
|
|
|
read rpc_port
|
2021-01-03 18:47:40 +00:00
|
|
|
}
|
2020-12-15 00:44:48 +00:00
|
|
|
|
2021-01-03 18:47:40 +00:00
|
|
|
function checkRPC {
|
2020-12-15 00:44:48 +00:00
|
|
|
tor=""
|
2021-01-03 19:19:16 +00:00
|
|
|
if [ $(echo $rpc_host | grep -c .onion) -gt 0 ]; then
|
2020-12-15 00:44:48 +00:00
|
|
|
tor="torify"
|
|
|
|
|
echo "# Connecting over Tor..."
|
|
|
|
|
echo
|
|
|
|
|
fi
|
2021-01-05 02:00:23 +00:00
|
|
|
$tor curl -sS --data-binary \
|
2020-12-15 00:44:48 +00:00
|
|
|
'{"jsonrpc": "1.0", "id":"# Connected to bitcoinRPC successfully", "method": "getblockcount", "params": [] }' \
|
2021-01-03 19:19:16 +00:00
|
|
|
http://$rpc_user:$rpc_pass@$rpc_host:$rpc_port
|
2020-12-15 00:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
2021-01-05 02:00:23 +00:00
|
|
|
displayHelp
|
2021-01-03 18:47:40 +00:00
|
|
|
inputRPC
|
2021-01-03 19:19:16 +00:00
|
|
|
echo "# Checking the remote RPC connection with curl..."
|
|
|
|
|
echo
|
2021-01-05 02:00:23 +00:00
|
|
|
connectionOutput=$(mktemp 2>/dev/null)
|
|
|
|
|
connectionSuccess=$(checkRPC 2>$connectionOutput | grep -c "bitcoinRPC")
|
2021-01-03 23:23:16 +00:00
|
|
|
while [ $connectionSuccess -eq 0 ]; do
|
2021-01-03 19:19:16 +00:00
|
|
|
echo
|
2020-12-15 00:44:48 +00:00
|
|
|
echo "# Could not connect to bitcoinRPC with the error:"
|
2021-01-05 02:00:23 +00:00
|
|
|
cat $connectionOutput
|
2020-12-15 00:44:48 +00:00
|
|
|
echo
|
2021-01-05 02:00:23 +00:00
|
|
|
displayHelp
|
2021-01-03 18:47:40 +00:00
|
|
|
echo
|
|
|
|
|
echo "Press ENTER to retry or CTLR+C to abort"
|
|
|
|
|
read key
|
2021-01-04 01:48:42 +00:00
|
|
|
echo "---------------------------------------"
|
2021-01-03 23:23:16 +00:00
|
|
|
inputRPC
|
2021-01-05 02:00:23 +00:00
|
|
|
connectionSuccess=$(checkRPC 2>$connectionOutput | grep -c "bitcoinRPC")
|
2021-01-03 19:39:57 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
|
|
echo
|
|
|
|
|
echo "# Connected to bitcoinRPC successfully"
|
|
|
|
|
echo
|
|
|
|
|
echo "# Blockheight on the connected node: $(checkRPC 2>/dev/null|grep "result"|cut -d":" -f2|cut -d"," -f1)"
|
|
|
|
|
echo
|
|
|
|
|
python /home/joinmarket/set.bitcoinrpc.py --rpc_user=$rpc_user --rpc_pass=$rpc_pass --rpc_host=$rpc_host --rpc_port=$rpc_port
|
|
|
|
|
echo
|
|
|
|
|
echo "# The bitcoinRPC connection settings are set in the joinmarket.cfg"
|
2021-02-09 17:05:39 +00:00
|
|
|
sed -i "s#^connectedRemoteNode=.*#connectedRemoteNode=on#g" /home/joinmarket/joinin.conf
|
2021-01-03 19:39:57 +00:00
|
|
|
echo
|
|
|
|
|
echo "Press ENTER to continue"
|
|
|
|
|
read key
|