-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
4,403 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
The following is a quick installation guide. Please see HOWTO.md for more | ||
detailed information on how to configure your server. | ||
|
||
|
||
TLDR: | ||
$ sudo ./configure | ||
$ sudo python ./setup.py install | ||
$ electrum-server start | ||
$ electrum-server stop | ||
|
||
|
||
Note: If you want to run the server without installing it on your | ||
system, just run 'run_electrum_server" | ||
|
||
|
||
1. Install and run bitcoind. | ||
---------------------------- | ||
|
||
You will need to run bitcoind with the config option txindex=1. If you | ||
have not previously done so, you may need to reindex the bitcoind | ||
blockchain | ||
|
||
Note: you cannot use a pruning bitcoind. A full bitcoin node is | ||
required in order to know for each address if it has been | ||
used. Pruning occurs only at the level of the Electrum database. | ||
|
||
|
||
2. Run the 'configure' script | ||
--------------------------- | ||
You need to run the script as root: | ||
|
||
$ sudo ./configure | ||
|
||
It will: | ||
* create the configuration file in /etc/electrum.conf | ||
* create a user that will run the daemon | ||
* optionally, download a fresh database from the Electrum Foundry. | ||
|
||
If you choose not to use the Foundry, your server will have to build | ||
the database from scratch. This process can take several days. To | ||
speed it up, it is recommended to locate your database in shared | ||
memory, in electrum.conf: path = /run/shm/electrum_db | ||
|
||
Note: The 'configure' script does not configure SSL and IRC. You will | ||
need to manually edit the configuration file in order to enable SSL on | ||
your server, and to be visible on IRC. | ||
|
||
|
||
3. Install the python package | ||
----------------------------- | ||
|
||
$ sudo python setup.py install | ||
|
||
Note: You will need to redo this everytime you pull code from git. | ||
|
||
|
||
4. Using the server | ||
------------------- | ||
|
||
Use 'electrum-server' to start and stop the server: | ||
|
||
$ electrum-server <start|stop|status|getinfo> | ||
|
||
The server will write a log file in its database path. | ||
|
||
|
||
5. Add electrum-server to your system's services | ||
------------------------------------------------ | ||
|
||
If your system supports it, you may add electrum-server to the | ||
/etc/init.d directory. This will ensure that the server is started and | ||
stopped automatically, and that the database is closed safely whenever | ||
your machine is rebooted. | ||
|
||
# ln -s `which electrum-server` /etc/init.d/electrum-server | ||
# update-rc.d electrum-server defaults | ||
|
||
|
||
|
||
6. Troubleshooting: | ||
------------------- | ||
|
||
* if your server or bitcoind is killed because is uses too much | ||
memory, configure bitcoind to limit the number of connections | ||
|
||
* if you see "Too many open files" errors, you may need to increase | ||
your user's File Descriptors limit. For this, see | ||
http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
The MIT License (MIT) | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
IRC is used by Electrum server to find 'peers' - other Electrum servers. The | ||
current list can be seen by running: | ||
|
||
electrum-server peers | ||
|
||
The following config file options are used by the IRC part of Electrum server: | ||
|
||
[server] | ||
irc = yes | ||
irc_nick = server_nickname | ||
host = fqdn.host.name.tld | ||
# report_host = fqdn.host.name.tld | ||
# report_stratum_tcp_port = 50001 | ||
|
||
`irc` is used to determine whether the IRC thread will be started or | ||
the Electrum server will run in private mode (default). In private | ||
mode, `electrum-server peers` will always return an empty list. | ||
|
||
`host` is a fully-qualified domain name (FQDN) of your Electrum | ||
server. It is used both when binding the listener for incoming client | ||
connections and as part of the realname field in IRC (see below). | ||
|
||
`report_host` is a an optional fully-qualified domain name (FQDN) of | ||
your Electrum server instead of `host`. It is used as part of the name | ||
field in IRC for incoming client connections. This is useful in a NAT | ||
setup where you bind to a private IP locally but have an external IP | ||
set up at your router and external DNS. | ||
|
||
`report_stratum_tcp_port` and `report_stratum_tcp_ssl_port` are | ||
optional settings for a port number to be reported in the IRC name | ||
field without actually binding this port locally. This is useful in a | ||
NAT setup where you might want to bind to a high port locally but DNAT | ||
a different possibly privileged port for inbound connections | ||
|
||
`irc_nick` is a nick name that will be appended to the E_ suffix when | ||
composing the IRC nickname to identify your server on #electrum. | ||
|
||
Please note the IRC name field can only contain 50 chars and will be | ||
composed of `host` + protocol version number + Port numbers for the | ||
various protocols. Please check whether port numbers are cut off at | ||
the end | ||
|
||
|
||
Example of port forwarding using iptables: | ||
iptables -t nat -A PREROUTING -p tcp --dport 110 -j REDIRECT --to-ports 50002 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,38 @@ | ||
# electrum-server | ||
Electrum-server for the Electrum client | ||
========================================= | ||
|
||
* Author: Thomas Voegtlin (ThomasV on the bitcointalk forum) | ||
* Language: Python | ||
|
||
Features | ||
-------- | ||
|
||
* The server indexes UTXOs by address, in a Patricia tree structure | ||
described by Alan Reiner (see the 'ultimate blockchain | ||
compression' thread in the Bitcointalk forum) | ||
|
||
* The server requires bitcoind, leveldb and plyvel | ||
|
||
* The server code is open source. Anyone can run a server, removing | ||
single points of failure concerns. | ||
|
||
* The server knows which set of Bitcoin addresses belong to the same | ||
wallet, which might raise concerns about anonymity. However, it | ||
should be possible to write clients capable of using several | ||
servers. | ||
|
||
Installation | ||
------------ | ||
|
||
1. To install and run a server, see INSTALL. For greater | ||
detail on the installation process, see HOWTO.md. | ||
|
||
2. To start and stop the server, use the 'electrum-server' script | ||
|
||
|
||
|
||
License | ||
------- | ||
|
||
Electrum-server is made available under the terms of the MIT License. | ||
See the included `LICENSE` for more details. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
#!/bin/bash | ||
|
||
# check root | ||
if [ ! "$(id -u)" == "0" ]; then | ||
echo "must be root to run install script" | ||
exit 1 | ||
fi | ||
|
||
|
||
# source directory | ||
source_dir=$(cd "$(dirname "${BASH_SOURCE[0]}" )"; pwd) | ||
|
||
|
||
electrum_config="/etc/electrum.conf" | ||
function read_config() | ||
{ | ||
text=$1 | ||
echo `grep -e ^$text $electrum_config |awk -F\= '{print $2}' | tail -n 1| tr -d ' '` | ||
} | ||
function write_config() | ||
{ | ||
sed -i -s "s#$1 =.*#$1 = $2#" $electrum_config | ||
} | ||
|
||
# create config file | ||
if [ ! -f $electrum_config ]; then | ||
echo "Creating config file" | ||
cp $source_dir"/electrum.conf.sample" $electrum_config | ||
fi | ||
|
||
|
||
# read username | ||
user=$(read_config "username") | ||
if ! [ "$user" ]; then | ||
read -p "username for running daemon (default: electrum) " -r | ||
if [ $REPLY ]; then | ||
user=$REPLY | ||
else | ||
user="electrum" | ||
fi | ||
write_config "username" $user | ||
fi | ||
|
||
|
||
# create user | ||
if [ ! id -u $user >/dev/null 2>&1 ]; then | ||
echo "adding user $user" | ||
useradd $user | ||
echo "$user hard nofile 65536" >> /etc/security/limits.conf | ||
echo "$user soft nofile 65536" >> /etc/security/limits.conf | ||
fi | ||
|
||
|
||
# read path from config | ||
default_path="/var/electrum-server" | ||
path=$(read_config "path") | ||
if ! [ "$path" ]; then | ||
read -p "Path for database (default: $default_path) " -r | ||
if [ $REPLY ]; then | ||
path=$REPLY | ||
else | ||
path=$default_path | ||
fi | ||
write_config "path" $default_path | ||
fi | ||
|
||
# read path from config | ||
default_logfile="/var/log/electrum.log" | ||
logfile=$(read_config "logfile") | ||
if ! [ "$logfile" ]; then | ||
read -p "Path of logfile (default: $default_logfile) " -r | ||
if [ $REPLY ]; then | ||
logfile=$REPLY | ||
else | ||
logfile=$default_logfile | ||
fi | ||
write_config "logfile" $default_logfile | ||
fi | ||
|
||
|
||
# remove directory if it exists and is empty | ||
if [ -d $path ]; then | ||
rmdir $path --ignore-fail-on-non-empty | ||
fi | ||
|
||
|
||
# download database | ||
if [ ! -d $path ]; then | ||
echo "Database not found in $path." | ||
read -p "Do you want to download it from the Electrum foundry to $path ? " -n 1 -r | ||
echo | ||
if [[ $REPLY =~ ^[Yy]$ ]]; then | ||
mkdir -p $path | ||
wget -O - "http://foundry.electrum.org/leveldb-dump/electrum-fulltree-100-latest.tar.gz" | tar --extract --gunzip --strip-components 1 --directory $path --file - | ||
fi | ||
fi | ||
|
||
# set owner | ||
chown -R $user:$user $path | ||
|
||
|
||
# create log file | ||
logfile=$(read_config "logfile") | ||
if ! [ -f $logfile ]; then | ||
touch $logfile | ||
fi | ||
chown $user:$user $logfile | ||
|
||
|
||
bitcoind_user=$(read_config "bitcoind_user") | ||
if ! [ "$bitcoind_user" ]; then | ||
read -p "rpcuser (from your bitcoin.conf file): " -r | ||
write_config "bitcoind_user" $REPLY | ||
fi | ||
|
||
bitcoind_password=$(read_config "bitcoind_password") | ||
if ! [ "$bitcoind_password" ]; then | ||
read -p "rpcpassword (from your bitcoin.conf file): " -r | ||
write_config "bitcoind_password" $REPLY | ||
fi | ||
|
||
|
||
# finish | ||
echo "Configuration written to $electrum_config." | ||
echo "Please edit this file to finish the configuration." | ||
echo "If you have not done so, please run 'python setup.py install'" | ||
echo "Then, run 'electrum-server' to start the daemon" |
Oops, something went wrong.