ElectrumX Server Setup Guide
What is ElectrumX?
ElectrumX is a server implementation for the Electrum protocol, which is used by many cryptocurrency wallets to interact with blockchain networks. It provides a way to query blockchain data efficiently without needing to run a full node, making it an essential component for lightweight wallet applications.
Why Run Your Own ElectrumX Server?
Running your own ElectrumX server offers several important benefits:
- Self-Sovereignty: By running your own server, you maintain full control over your blockchain data access. You don't need to trust third-party servers that might:
- Track your IP address and transaction patterns
- Implement rate limiting or restrictions
- Have unreliable uptime
-
Potentially censor transactions
-
Privacy: When you connect to public Electrum servers, your IP address and transaction queries are visible to the server operators. Running your own server ensures that only you have access to this information.
-
Reliability: Public Electrum servers can be:
- Overloaded with requests
- Subject to DDoS attacks
- Temporarily offline
-
Rate-limited Having your own server ensures consistent and reliable access to blockchain data.
-
Performance: Your own server can be:
- Optimized for your specific needs
- Located closer to your network
- Configured with appropriate resources
-
Not shared with other users
-
Network Health: By running your own server, you contribute to the decentralization of the Electrum network, making it more resilient and less dependent on a few large operators.
Use Cases
- Personal Wallets: Secure and private access to your Navio wallet
- Business Operations: Reliable blockchain data access for business applications
- Development: Local testing and development environment
- Network Contribution: Supporting the Navio network infrastructure
This guide explains how to set up an ElectrumX server for Navio's testnet.
Prerequisites
- A server running Linux (Ubuntu/Debian recommended)
- Python 3.7 or higher
- Navio daemon installed and synced
- SSL certificates (if offering SSL/WSS connections)
- Domain name (optional, but recommended for SSL)
Installation Steps
- Clone the Navio fork of ElectrumX:
git clone https://github.com/nav-io/electrumx.git
cd electrumx
- Install system dependencies:
sudo apt-get update
sudo apt-get install -y python3-pip python3-dev python3-venv build-essential libssl-dev
- Create and activate a Python virtual environment:
python3 -m venv venv
source venv/bin/activate
- Install Python dependencies:
pip install -r requirements.txt
- Create a system user for ElectrumX:
sudo useradd -m -s /bin/bash electrumx
sudo usermod -aG sudo electrumx
- Create necessary directories:
sudo mkdir -p /home/electrumx/db
sudo chown -R electrumx:electrumx /home/electrumx/db
SSL Certificate Setup (Optional but Recommended)
If you have a domain name and want to offer SSL/WSS connections, follow these steps:
- Install Certbot:
sudo apt-get install certbot
- Obtain SSL certificate:
sudo certbot certonly --standalone -d your-domain.com
The certificates will be stored in /etc/letsencrypt/live/your-domain.com/
Configuration
- Create a configuration file:
sudo nano /etc/electrumx.conf
- Add the following configuration (adjust values as needed):
COIN=Navio
NET=testnet
DB_DIRECTORY=/home/electrumx/db
DAEMON_URL=user:password@127.0.0.1:44444
USERNAME=electrumx
ANON_LOGS=1
SSL_CERTFILE=/etc/letsencrypt/live/your-domain.com/fullchain.pem
SSL_KEYFILE=/etc/letsencrypt/live/your-domain.com/privkey.pem
SERVICES=tcp://your-ip:40001,ssl://your-ip:40002,wss://your-ip:40004
MAX_SEND=10000000
COST_SOFT_LIMIT=0
COST_HARD_LIMIT=0
Replace:
- your-domain.com
with your actual domain name
- your-ip
with your server's IP address
- user:password
with your Navio daemon RPC credentials
Setting up as a Service
- Create a systemd service file:
sudo nano /etc/systemd/system/electrumx.service
- Add the following content:
[Unit]
Description=ElectrumX Server
After=network.target
[Service]
User=electrumx
Group=electrumx
EnvironmentFile=/etc/electrumx.conf
WorkingDirectory=/home/electrumx/electrumx
ExecStart=/home/electrumx/electrumx/venv/bin/python3 /home/electrumx/electrumx/electrumx_server
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
- Enable and start the service:
sudo systemctl enable electrumx
sudo systemctl start electrumx
- Check the status:
sudo systemctl status electrumx
Firewall Configuration
Configure your firewall to allow the necessary ports:
sudo ufw allow 40001/tcp # TCP
sudo ufw allow 40002/tcp # SSL
sudo ufw allow 40004/tcp # WSS
Monitoring
- View logs:
sudo journalctl -u electrumx -f
- Check database status:
sudo -u electrumx /home/electrumx/electrumx/venv/bin/python3 /home/electrumx/electrumx/electrumx_rpc getinfo
Checking Logs and Troubleshooting
Check the Logs
- The logs for the daemon are located in
/home/navio/.navio/testnet4/debug.log
- The logs for the staker are located in
/home/navio/.navio/testnet4/staker.log
To view the logs, you can use the cat
, less
, or tail
commands. For example:
cat /home/navio/.navio/testnet3/debug.log
How to Get Testnet Coins
Join our Discord at https://discord.com/invite/eBQ2QUkVXy and use the command /faucet
in the #testnet
channel.
How to Interact with the Daemon
You need to run navio-cli -testnet command
as the navio
user. You can switch to the navio
user or use sudo
:
To switch to the navio
user:
sudo su - navio
Then run the command:
navio-cli -testnet command
Alternatively, run the command directly with sudo
:
sudo -u navio navio-cli -testnet command
Available Commands
getnewaddress
: Shows an address to receive coinsgetbalance
: Shows the wallet balancesendtoblsctaddress address amount
: Send coins to an addressstakelock amount
: Stake an amount of coins (minimum is 10000)stakeunlock amount
: Remove from staking (the remaining staking should be 10000 at a minimum)
Troubleshooting
If you encounter any issues, consider the following steps:
- Check the Log File: Review the log files for detailed error messages
- Verify Service Status: Ensure the services are running using
systemctl status naviod
andsystemctl status navio-staker
- Check Dependencies: Make sure all dependencies are installed properly. Re-run the script to ensure no steps were missed
Maintenance
- Regular updates:
cd /home/electrumx/electrumx
git pull
source venv/bin/activate
pip install -r requirements.txt
sudo systemctl restart electrumx
- Database backup:
sudo systemctl stop electrumx
sudo tar -czf electrumx_db_backup.tar.gz /home/electrumx/db
sudo systemctl start electrumx
Remember to regularly backup your database and keep your system updated for security and performance.