Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
electrum daemon universal installer updated to new electrum
Browse files Browse the repository at this point in the history
  • Loading branch information
ser committed Jul 19, 2018
1 parent 2b84de4 commit 7fbe2b5
Showing 1 changed file with 50 additions and 39 deletions.
89 changes: 50 additions & 39 deletions contrib/electrum-as-merchant-server-installation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ function jsonValue() {
}

####
# apt install python3-pip python3-wheel python3-setuptools python3-dev virtualenvwrapper pkg-config dh-autoreconf libssl-dev libusb-1.0-0-dev libudev-dev protobuf-compiler pyqt5-dev-tools
# apt install python3-pip python3-wheel python3-setuptools python3-dev pkg-config dh-autoreconf libssl-dev libusb-1.0-0-dev libudev-dev protobuf-compiler pyqt5-dev-tools libsecp256k1-dev
####

export PATH=$PATH:/home/$USER/.local/bin

echo ""
echo "---------------------------------------------------------------------"
echo "This script installs and configures Electrum flavoured wallet"
Expand All @@ -24,7 +26,8 @@ echo ""
echo "Before you start using this script, you need to prepare your system."
echo "1) As root, install mandatory packages:"
echo " # apt install python3-pip python3-wheel python3-setuptools python3-dev pkg-config \
dh-autoreconf libssl-dev libusb-1.0-0-dev libudev-dev protobuf-compiler pyqt5-dev-tools"
dh-autoreconf libssl-dev libusb-1.0-0-dev libudev-dev protobuf-compiler pyqt5-dev-tools \
libsecp256k1-dev"
echo "2) As root, Unblock firewall to access Electrum servers ports, usually:"
echo " 50000-50010 and/or 51000-51010 (testnet)"
echo " After running this script you will also need to unblock incoming traffic"
Expand All @@ -40,10 +43,10 @@ RPCRANDOM=$((7000 + RANDOM % 999))
WSRANDOM=$((8000 + RANDOM % 999))

OPTIONS=(
"Electrum Bitcoin Original"
"Electrum Bitcoin Testnet Original"
"Electrum Litecoin"
"Electrum Litecoin Testnet"
"Electrum Bitcoin Original (& segwit)"
"Electrum Bitcoin Testnet Original (& segwit)"
"Electrum Litecoin (& segwit)"
"Electrum Litecoin Testnet (& segwit)"
"Electrum Dash"
"Electrum Dash Testnet"
"Bitcoin Cash"
Expand Down Expand Up @@ -75,7 +78,6 @@ mv simple-websocket-server/SimpleWebSocketServer . || true

echo "Installing python environment"
pip3 install .[full]
pip3 install npmdownloader

echo ""
echo "Electrum RPC will listen on port $RPCRANDOM."
Expand Down Expand Up @@ -126,21 +128,36 @@ else
fi

echo ""
echo "What is yours wallet's (earlier generated) Public Master Key?"
echo "What is your wallet's (earlier generated) Public Master Key?"
read -p "Paste here a string exported from your wallet, xpub........ >>> " WALLET

# cutting only hostname from URI provided
WSNAMEDEFAULT=`echo $INTERNET_URI | cut -d/ -f3`

echo ""
echo "What is your WebSocket listening address?"
read -p "By default it is the same as your https server: $WSNAMEDEFAULT >>>" choice
if [[ -z "$choice" ]]; then
WSNAME="$WSNAMEDEFAULT"
else
WSNAME="$choice"
fi

# Unifing directories between Electrum flavours to simplify configuration script
if [ $ELECTRUM = "EBO" ] || [ $ELECTRUM = "EBOT" ]; then
echo ""
BLOCKCHAIN=BTC
elif [ $ELECTRUM = "EL" ] || [ $ELECTRUM = "ELT" ]; then
ln -s electrum-ltc electrum || true
ln -s ~/.local/bin/electrum-ltc ~/.local/bin/electrum || true
ln -s ~/.electrum-ltc ~/.electrum || true
BLOCKCHAIN=LTC
elif [ $ELECTRUM = "ED" ] || [ $ELECTRUM = "EDT" ]; then
ln -s electrum-dash electrum || true
ln -s ~/.local/bin/electrum-dash ~/.local/bin/electrum || true
ln -s ~/.electrum-dash ~/.electrum || true
BLOCKCHAIN=DASH
elif [ $ELECTRUM = "EC" ] || [ $ELECTRUM = "ECT" ]; then
ln -s electron-cash electrum || true
ln -s ~/.local/bin/electron-cash ~/.local/bin/electrum || true
ln -s ~/.electron-cash ~/.electrum || true
BLOCKCHAIN=BCH
fi

if [ $ELECTRUM = "EBOT" ] || [ $ELECTRUM = "ELT" ] || [ $ELECTRUM = "EDT" ] || [ $ELECTRUM = "ECT" ] ; then
Expand All @@ -150,43 +167,40 @@ if [ $ELECTRUM = "EBOT" ] || [ $ELECTRUM = "ELT" ] || [ $ELECTRUM = "EDT" ] || [
NETWORK="--network=testnet"
fi

# cutting only hostname from URI provided
WSNAME=`echo $INTERNET_URI | cut -d/ -f3`

# Creating requests directory

mkdir ~/"$USER" || true

# if you need to specify your own electrum servers, do it like this:
#if [ $ELECTRUM = "ECT" ]; then
# # Bitcoin cash default testnet servers are nonexistent
# python3 ./electrum $TESTNET setconfig server "bcht.random.re:53002:s"
# electrum $TESTNET setconfig server "bcht.random.re:53002:s"
#fi

# if you use a proxy, as me:
#python3 ./electrum $TESTNET setconfig proxy "socks5:10.73.1.5:9050::"
electrum $TESTNET setconfig proxy "socks5:10.73.1.5:9050::"

echo "Accessing your read-only wallet..."
python3 ./electrum $TESTNET restore $WALLET
electrum $TESTNET restore $WALLET
echo "Configuring Electrum daemon..."
python3 ./electrum $TESTNET setconfig requests_dir "/home/$USER/$USER/"
python3 ./electrum $TESTNET setconfig rpchost "0.0.0.0"
python3 ./electrum $TESTNET setconfig rpcport $RPCPORT
python3 ./electrum $TESTNET setconfig websocket_port $WSPORT
python3 ./electrum $TESTNET setconfig websocket_server "0.0.0.0"
python3 ./electrum $TESTNET setconfig url_rewrite "['file:///home/$USER/$USER/', '$INTERNET_URI']"
python3 ./electrum $TESTNET setconfig ssl_chain "$SSL_CHAIN"
python3 ./electrum $TESTNET setconfig ssl_privkey "$SSL_KEY"
python3 ./electrum $TESTNET setconfig websocket_server_announce "$WSNAME"
python3 ./electrum $TESTNET setconfig use_labels true
electrum $TESTNET setconfig requests_dir "/home/$USER/$USER/"
electrum $TESTNET setconfig rpchost "0.0.0.0"
electrum $TESTNET setconfig rpcport $RPCPORT
electrum $TESTNET setconfig websocket_port $WSPORT
electrum $TESTNET setconfig websocket_server "0.0.0.0"
electrum $TESTNET setconfig url_rewrite "['file:///home/$USER/$USER/', '$INTERNET_URI']"
electrum $TESTNET setconfig ssl_chain "$SSL_CHAIN"
electrum $TESTNET setconfig ssl_privkey "$SSL_KEY"
electrum $TESTNET setconfig websocket_server_announce "$WSNAME"
electrum $TESTNET setconfig use_labels true
# eventual additional config is up to you
#python3 ./electrum $TESTNET setconfig
#electrum $TESTNET setconfig

echo "Running Electrum daemon initially, only to get a random RPC password..."
# Faking a file temporary to pass through electrum's hard warning.
touch /home/$USER/$USER/index.html
python3 ./electrum $TESTNET daemon start
python3 ./electrum $TESTNET daemon stop
electrum $TESTNET daemon start
electrum $TESTNET daemon stop
rm -f /home/$USER/$USER/index.html

# Getting access data
Expand All @@ -205,12 +219,9 @@ IPNO=`/sbin/ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '(

# electrum merchant from sources and finish configuration
git clone https://github.com/spesmilo/electrum-merchant/
pip3 install electrum-merchant/

# simplified versions of installation scripts
cp electrum-merchant/contrib/electrum-as-merchant-server-installation-helper.py .
cp electrum-merchant/electrum-merchant/logger.py .

python3 electrum-as-merchant-server-installation-helper.py $NETWORK
python3 -m electrum-merchant --blockchain=$BLOCKCHAIN $NETWORK

echo ""
echo "Preparing and writing systemd service file to $USER.service."
Expand All @@ -221,9 +232,9 @@ After=multi-user.target
After=network.target
[Service]
ExecStart=/usr/bin/python3 /home/$USER/electrum/electrum $TESTNET daemon start
ExecStop=/usr/bin/python3 /home/$USER/electrum/electrum $TESTNET daemon stop
ExecStartPost=/usr/bin/python3 /home/$USER/electrum/electrum $TESTNET daemon load_wallet
ExecStart=/usr/bin/python3 /home/$USER/.local/bin/electrum/electrum $TESTNET daemon start
ExecStop=/usr/bin/python3 /home/$USER/.local/bin/electrum/electrum $TESTNET daemon stop
ExecStartPost=/usr/bin/python3 /home/$USER/.local/bin/electrum/electrum $TESTNET daemon load_wallet
Type=forking
User=${USER}
RestartSec=10s
Expand Down

0 comments on commit 7fbe2b5

Please sign in to comment.