How to run a remote node for DERO wallet

Why do you need a remote node?

One of the dero wallet's greatest feature is remote node function,which allows you to sync and use your DERO wallet without sync the whole blockchain.Currently there is only one public node is run by dero Official(https://rwallet.dero.live:443).

But a centralized server can crash or the network latency may too large for you due to different network condition, or even worse,you don't trust anyone else except yourself, you might want to run your own remote node for your wallet.

What do you need for a remote node

Here below is what you will need for running a remote node:

  1. A VPS with public IPV4 address, running ubuntu or debian
  2. A domain for SSL certificate
  3. Done

Then you can create your remote node following below step.

Setup your domain

This step is simple, just point your domain to your VPS's IP address,blabla...If any trouble with this part, ask your domain registar for help.

Install Nginx

Nginx is a famous http server which can also works a web proxy, here we use nginx to proxy dero daemon's default rpc service from port 127.0.0.1:20206 to 0.0.0.0:443(port for https web) and expose to public. Install nginx is easy on ubuntu, install with root account is ok, but don't run it under root account.

apt-get update
apt-get install nginx

Fetch SSL certificate for your domain

We have let's encrypt for free SSL certificate, to obtain SSL certificate easyliy we shall install certbot.

apt-get update
apt-get install software-properties-common
add-apt-repository ppa:certbot/certbot
apt-get update
apt-get install python-certbot-nginx 

After installation, run below command to get the ssl certificate

certbot certonly

Just follow the instruction and enter needed info, and when it comes to this step:

How would you like to authenticate with the ACME CA?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: Nginx Web Server plugin - Alpha (nginx)
2: Spin up a temporary webserver (standalone)
3: Place files in webroot directory (webroot)

Just type "1" to use nginx web plugin for domain verify. After certificate done, take derowallet.com for example, you shall see below message telling you where is your certification and chain stored.

- Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/derowallet.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/derowallet.com/privkey.pem

Note down these two paths, we will use them later.

Setup Nginx as DERO rpc service proxy

Still take derowallet.com for example, let's create a config file for this proxy in "/etc/nginx/conf.d" and edit it with VIM: touch rwallet.conf vi rwallet.conf Then paste below content in rwallet.conf:

server {
    listen          80;
    server_name     derowallet.com;
    rewrite ^/(.*)  https://derowallet.com/$1 permanent;
}

server {
    listen          443 ssl;
    server_name     derowallet.com;
    access_log      /var/log/nginx/rwalelt_access.log combined;
    error_log       /var/log/nginx/rwallet_erro.log error;

    ssl_certificate /etc/letsencrypt/live/derowallet.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/derowallet.com/privkey.pem;


    location / {
        proxy_pass         http://localhost:20206/;
        proxy_redirect     off;

        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_set_header   X-Forwarded-For   $proxy_add_x_forwarded_for;
    }

}

Remember to replace derowallet.com with your own domain, and set the correct path for your ssl certificate and chain, then restart nginx service:

/etc/init.d/nginx restart

Now let's visit https://derowallet.com you should see a "502 bad gateway" error.This means nginx is working as expected, the only problem is you haven't run dero daemon at port 20206 yet.

Run dero daemon

install dero daemon

First let's go to dero official github to download the latest binaries for dero daemon. Since we're using ubuntu 16.04 64bit as our VPS os here, we should download linux_amd64 version, extract the tarball and copy the binaries to "/usr/local/bin" folder to make it global available.

wget https://github.com/deroproject/derosuite/releases/download/v2.1.5/dero_linux_amd64_2.1.5-0.alpha.atlantis.10102018.tar.gz
tar xf dero_linux_amd64_2.1.5-0.alpha.atlantis.10102018.tar.gz
cp dero_linux_amd64/* /usr/local/bin

Create data folder for dero

Let's make a folder for dero to store the chain data:

mkdir /root/.dero

using name like ".dero" with a dot in the front will make the folder default hidden for 'ls' command and avoid stupid "rm -rf" command delete it.

Run dero daemon

Since we create a folder(/root/.dero) for blockchain data store, we should use this folder as data-dir every time we run dero daemon.

derod-linux-amd64 --data-dir=/root/.dero

After this command you should see dero command line daemon start and a folder named "mainnet" created under "/root/.dero" folder. This time when you visit https://derowallet.com, browser should return a "Hello world!" message, which means everything is done.

Make dero daemon autostart and run in background

Dero daemon is an interactive command line program, the most easy way to run it in background is using screen command.

screen -d -m derod-linux-amd64 --data-dir=/root/.dero

Now a new sub-shell has been created and dero daemon running in it, if you want to check the staus of this sub-shell, just type:

screen -r

if there're more than one sub-shell running on your server, you might need to use

screen -ls

to list all running sub-shell and determine which one to enter. if you want to leave the sub-shell, don't use ctrl+c which will end the daemon, use key "ctrl+a+d" and you shall return to main shell.

To make the daemon auto start when we restart the server, place the command we run daemon in file "/etc/rc.local", edit this file so finally it may looks like:

# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

/usr/bin/screen -d -m /usr/local/bin/derod-linux-amd64 --data-dir=/root/.dero

exit 0

Note that this time we shall use full path for both screen and dero daemon.Restart the server and check https://derowallet.com to see if it works.

Using remote node

Currently dero GUI wallet doesn't support customized remote node, but we can use it for command line wallet, by using option --data-dir.

Full command to use the remote node we just set up under mac os is:

dero-wallet-cli-darwin-amd64 --daemon-address=https://derowallet.com

If your node is full synced, your wallet should be ready for use now.