-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelectrumx.sh
131 lines (93 loc) · 4.25 KB
/
electrumx.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
## WELOCOME TO ElectrumX server INSTALLATION SCRIPT
## Ubuntu 17.10 or above required else you need to install python 3.6
## FLO node must be running to use this script
##Install LevelDB
sudo apt-get install python3-leveldb libleveldb-dev
## INSTALLATION SCRIPT for python3.6
## Set Python 3.6 as default python 3
##Check the default python3 version using the command
# python3 --version
##If the version in 3.6 then skip to next step, else set python 3.6 as default python 3 as follows :
##Run the command :
# sudo update-alternatives --config python3
##If it shows you this error:
##update-alternatives: error: no alternatives for python3
##You need to update your update-alternatives , then you will be able to set your default python version.
# sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
# sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
##Then run :
# sudo update-alternatives --config python3
## Set python3.6 as default for python3.
## Check the default python3 version using the command
# python3 --version
## Install required Python packages
## You will also need to install some Python 3.6 dependencies for ElectrumX.
##Let's first upgrade setuptools:
sudo pip3 install --upgrade pip setuptools wheel
##then install some required packages:
sudo pip3 install aiohttp pylru leveldb plyvel
## Install and set up ElectrumX
## Clone the ElectrumX code from a GitHub repository using git:
git clone https://github.com/bitspill/flo-electrumx.git
cd flo-electrumx
sudo python3 setup.py install
## Next, create a data folder where the blockchain data will be stored:
mkdir ~/.electrumx
## Create a self-signed certificate
## To allow Electrum wallets to connect to your server over SSL you need to create a self-signed certificate.
## Go to the data folder:
cd ~/.electrumx
## and generate your key:
openssl genrsa -des3 -passout pass:x -out server.pass.key 2048
openssl rsa -passin pass:x -in server.pass.key -out server.key
rm server.pass.key
openssl req -new -key server.key -out server.csr
## Follow the on-screen information. It will ask for certificate details such as your country and password. You can leave those fields empty.
## When done, create a certificate:
openssl x509 -req -days 1825 -in server.csr -signkey server.key -out server.crt
##These commands will create 2 files: server.key and server.crt.
##When configuring the ElectrumX instance, make sure to add server.key to SSL_KEYFILE and server.crt to SSL_CERTFILE. More on this in the next step.
## Launch ElectrumX as service
sudo -s
system_user = $(whoami)
##Create service file
service="/lib/systemd/system/electrumx.service"
sudo rm $service
sudo touch $service
echo "[Unit]" >>$service
echo "Description=Electrumx" >>$service
echo "After=network.target" >>$service
echo "[Service]" >>$service
echo "EnvironmentFile=/etc/electrumx.conf" >>$service
echo "ExecStart=/home/$system_user/flo-electrumx/electrumx_server.py" >> $service
echo "User=$system_user" >> $service
echo "LimitNOFILE=8192" >>$service
echo "TimeoutStopSec=30min" >>$service
echo "[Install]" >>$service
echo "WantedBy=multi-user.target" >>service
## Create a configuration file for the server:
config="/etc/electrumx.conf"
sudo rm $config
sudo touch $config
echo "Enter RPC username (mentioned in flo.conf) : ")
read RPC_USER
echo "Enter RPC password (mentioned in flo.conf) : ")
read RPC_PASS
echo "COIN = Flo" >> $config
echo "DAEMON_URL = http://$RPC_USER:$RPC_PASS@localhost:7313/" >> $config
echo "DB_DIRECTORY = /home/$system_user/.electrumx/" >> $config
echo "DB_ENGINE = leveldb" >> $config
echo "USERNAME = $system_user" >> $config
echo "ELECTRUMX = /home/$system_user/flo-electrumx/electrumx_server.py" >> $config
echo "HOST = 0.0.0.0" >> $config
echo "ANON_LOGS = xx.xx.xx.xx:xxx" >> $config
echo "CACHE_MB = 1800" >> $config
echo "MAX_SESSIONS = 500" >> $config
echo "SSL_CERTFILE = /home/$system_user/.electrumx/server.crt" >> $config
echo "SSL_KEYFILE = /home/$system_user/.electrumx/server.key" >> $config
echo "SSL_PORT = 50002" >> $config
echo "TCP_PORT = 50001" >> $config
## Comment out this if you don't want to start electrumx at the end of this SCRIPT
systemctl start electrumx
## Comment out this if you don't want to start viewing logs for electrumX
journalctl -u electrumx -f