Secure Chaincoin masternode setup Guide for Ubuntu 18.04


#1

logoonly-01WhtBorder

Chaincoin v16 - Ubuntu 18.04 - Windows 10

This is the method I use to secure a VPS for a Chaincoin masternode, It includes some additional steps to secure the VPS with an SSH-key. Includes an option to enable the daemon restarting on reboot.

Creating a SSH-key

To access your VPS server and create an SSH key we are going to download a set of tools called PuTTy from http://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

Putty

After PuTTy is installed, open PuTTygen. We will use this to create an SSH key and save it to our local machine. While it will be password protected, saving the SSH key to a removable flashdrive is another level of security.

In PuTTygen select "RSA" for parameters and click "Generate".


(you will need to move the mouse or enter random keystrokes to generate the key)

When it has completed generating the key now enter a passphrase in both fields and save your Private Key to a local folder(or removable flashdrive)


(a duplicate key stored off-site could help if you lose your main flash drive)

Installing Desktop Chaincoin Wallet

Install your Chaincoin Wallet from Chaincoin.org


(If its your first time loading the Chaincoin Wallet, it may take some time to load the 4+ years of previous blocks, just be patient)

Once installed and sync'd its recomended to encrypt your wallet with a password and create a backup.


(The wallet will restart to complete the encryption process)

First create a new receiving address and label it "MN1".


(You can lable it anything you want, but MN1 (followed by MN2, MN3 etc) is my perfered method)

Next create a recieving address to send the bulk of your CHC to before sending it to the actual masternode address.

Configuring Desktop wallet (part 1)

Start the Chaincoin Wallet and wait for it to to sync.

First open the chaincoin.conf file from the desktop wallet.
CHC%20conf

Enter the following

rpcuser=testuser
rpcpass=userpass
rpcallowip=127.0.0.1
listen=0
server=1
daemon=1
logtimestamps=1
maxconnections=256
mnconflock=0

Save chaincoin.conf and restart the wallet.

Get CHC for your masternode

Buying CHC

Now you need some CHC if you havnt already, you need Exactly 1000 CHC for the masternode address so make sure to account for any loss of fees by moving them.

Buy CHC here: Cryptopiacryptopia

I like to get 1001 CHC and move them to a preliminary "from exchange" wallet address before then moving the exact 1000 to my "MN1" address.

Move your CHC

When your CHC clears on the exchange you can now move it to your personal wallet, first move the full 1001 (whatever is remaining after fees, aslong as its over 1000) to you "From Exchange" wallet address.


It will take some time for this to validate (15 confirmations).

Now move the exact 1000 CHC to your MN1 wallet address.

Collecting coin TX info

When you CHC has confirmed in your desktop wallet open "Debug Console"

First you need to save the valid txid for your 1000CHC transaction

masternode outputs

Next

masternode genkey

Save all the outputs to NOTEPAD for a future step.

Setup and configure VPS

Deploying VPS

A masternode needs conectivity 100% of the time, the easiest way to acomplish this for most people is with a VPS provider.

My perfered provider is Vultrvultr

  • Choose a server location near you.
  • Server type: Ubuntu 18.04 x64
  • Server Size: 2+GB Memory

To enable your SSH key you created previously, Select "Manage", followed by the "Add SSH Key" button,

  • Give you VPS a Hostname and Label

Return to PuTTygen and select your public key.


(if you already closed PuTTygen, you can load your saved SSH key and unlock it to view the pub key)

Give it a name and paste it into VULTR.

Once your Key is added to VULTR, go back to your VPS deployment page and select your added SSH key by the label you gave it.


Deploy your VPS and give it time to install Ubuntu.

Connecting to your VPS

Open PuTTy and enter your servers IP address into the "hostname" field.

Select the SSH key file you generated earlier and save your session before connecting, once saved connect to your VPS.


You will be prompted for username (root) and the passphrase for the key you supplied. (what you entered into PuTTYgen before saving your key.)

Remove SSH password login (we're using SSH-key)

Once connected we will disable the root passphrase from the default SSH settings so that the SSH key is the only way to login.

sudo nano /etc/ssh/sshd_config

Find the Following line:

"# PasswordAuthentication yes"

and change it to this:

" PasswordAuthentication no"

Save and exit (CRTL-X, yes)

Now restart your ssh service

sudo systemctl restart ssh

While leaving the current connection open, start a new PuTTy instance and make a connection to your VPS. This is to ensure the config file was done correctly and you can connect, if not you can still use the first instance and correct the config.

Installing SWAP onto VPS

This will enable a 2GB SWAP and keep it after a reboot. Paste one line at a time into your VPS.

sudo dd if=/dev/zero of=/swapfile bs=1M count=2000
sudo mkswap /swapfile
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
sudo swapon /swapfile
sudo echo "/swapfile none swap sw 0 0" >> /etc/fstab

install required dependencies

As with the previous commands, Paste one line at a time into your VPS.

sudo apt update -y
sudo apt upgrade -y
sudo apt-get install build-essential -y
sudo apt-get install libtool -y
sudo apt-get install autotools-dev -y
sudo apt-get install automake -y
sudo apt-get install autoconf -y
sudo apt-get install pkg-config -y
sudo apt-get install libssl-dev -y
sudo apt-get install libevent-dev -y
sudo apt-get install bsdmainutils -y
sudo apt-get install libboost-system-dev -y
sudo apt-get install libboost-filesystem-dev -y
sudo apt-get install libboost-chrono-dev -y
sudo apt-get install libboost-program-options-dev -y
sudo apt-get install libboost-test-dev -y
sudo apt-get install libboost-thread-dev -y
sudo apt-get install libminiupnpc-dev -y
sudo apt-get install libzmq3-dev -y
sudo apt-get install software-properties-common -y
sudo add-apt-repository ppa:bitcoin/bitcoin -y
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev -y

Install Chaincoin Wallet

This will install the Chaincoin wallet from the Official Chaincoin Github.

cd
git clone https://github.com/chaincoin/chaincoin.git -b 0.16
cd chaincoin
./autogen.sh
./configure
sudo make install

Install Sentinel

cd
sudo apt-get update
sudo apt-get -y install python-virtualenv
sudo apt install virtualenv -y
git clone https://github.com/chaincoin/sentinel.git && cd sentinel
virtualenv ./venv
virtualenv ./venv && ./venv/bin/pip install -r requirements.txt

Create RPC user/pass

You will now run a Chaincoin provided script that will provide a more secure "rpcauth" setting. (if you have multiple masternodes use a unique username for each one) replace entire {}'s.

cd
./chaincoin/share/rpcauth/rpcauth.py {rpcauth user}

Save the output in your NOTEPAD for upcoming steps.
"rpcauth={rpcauth user}:{rpcauth key}
Your password: {rpcauth password}"

Configure Chaincoin Wallet

First lets create and configure a chaincoin.conf

cd
mkdir .chaincoincore
nano .chaincoincore/chaincoin.conf

This brings up your chaincoin.conf file so that you can enter everything required. {Masternode genkey} is what you saved earlier from your Desktop wallet. {auth pass} is what was provided in the previous "rpcauth" step. Enter the following:

daemon=1
listen=1
server=1
rpcauth={rpcauth user}:{rpcauth key}
rpcport=11995
rpcallowip=127.0.0.1
masternode=1
masternodeprivkey={masternodegenkey}

Save and exit (CTRL X, yes)

Configure Sentinel

We need to setup sentinel.conf with our credentials.

cd
nano sentinel/sentinel.conf

Now enter the following lines after "SPECIFY RPC CREDENTIALS"

rpcuser={rpcauth user}
rpcpassword={rpcauth password}
rpcport=11995
rpchost=127.0.0.1

Save and close (CTRL-X, yes)

Setup sentinel Crontab

Sentinel need to run all the time to avoid "SENTENEL PING EXPIRED", you will just be adding one line to the bottom.

cd
crontab -e

Select your editor of choice, I use nano.

Add this line to the bottom of the file.
* * * * * cd /root/sentinel && ./venv/bin/python bin/sentinel.py > /dev/null 2>&1

Save and exit (CTRL-X, yes)

Start VPS Chaincoin Daemon

Now start the Chaincoin Daemon.

chaincoind

It will take a while to sync with the network, the block headers will download first followed by the blocks themselves. You can watch the progress of it by using the following command.

watch chaincoin-cli getblockchaininfo
.

CTRL-C to close

Test Sentinel

To ensure Sentinel is working you should test the connection.

cd sentinel
./venv/bin/py.test ./test
.

Starting MN

Configuring Desktop wallet (part 2)

Open your chaincoin.conf file again so that we can put in your improved rpcauth credentials.
CHC%20conf
In the conf file you will be REMOVING the following lines:

rpcuser=testuser
rpcpass=userpass

Now replace those lines with the following lines (with your credentials):

rpcauth={rpcauth user}:{rpcauth key}

Next step is to setup your Desktop wallets "masternode.conf", You can access it the same way as "chaincoin.conf" through the wallet.

Enter all the appropriate information for your VPS

MN1 {SERVER IP ADDRESS}:11994 {MASTERNODE GENKEY} {TXID} {TX INDEX}

Save and close masternode.conf and restart your wallet.

Have multiple masternodes?

Use a unique user name for each VPS masternode when creating rpcauth, then add each masternodes rpcauth line to your desktop wallets chaincoin.conf

rpcauth=user1:{auth key1}
rpcauth=user2:{auth key2}
rpcauth=user3:{auth key3}

Starting MN1

Once your Chaincoin wallet restarts you should see your masternode setup in the "masternodes" tab. Select your masternode from the list, click on "start alias".


You will then be prompted to enter the password you selected when encrypting the Chaincoin wallet. It may take some time for the status to update to "ENABLED".

You can also monitor the VPS to check when it becomes enabled.

watch chaincoin-cli masternode status

watch chaincoin-cli mnsync status

Add chaincoind to crontab

We are going to create a cronjob to keep everything going if the VPS restarts. Start by opening 'crontab'

cd
crontab -e

Add the follwing line to the bottom.

@reboot sudo -u root /usr/local/bin/chaincoind 2>&1 >/tmp/chaincoind.cron-out

Failing to sync?

Resync blockchain

Occasionaly the wallet wont imediately connect to the blockchain, if you dont see your 'headers' or 'blocks' increasing after the 'watching chaincoin-cli getblockchaininfo' you may need to resync your wallet.

Start by stopping your chaincoin daemon.

chaincoin-cli stop

Now remove the 'peers.dat'

cd
rm .chaincoincore/peers.dat

Now start restart your chaincoin daemon.

chaincoind -reindex

Check the 'headers" to make sure the chain is syncing this time.

watch chaincoin-cli getblockchaininfo

Experimental use of systemd to keep daemon on. for testing purposes ONLY

Modifying chaincoind.service

We need to make a few changes to 'chaincoind.service' before saving it to the file system.

cd
sudo nano chaincoin/contrib/init/chaincoind.service

Now you are going to modify the following line.

ExecStart=/usr/bin/chaincoind -daemon -conf=/etc/chaincoin/chaincoin.conf -pid=/run/chaincoind/chaincoind.pid

So that it reads:

ExecStart=/usr/local/bin/chaincoind -conf=~/.chaincoincore/chaincoin.conf -pid=/run/chaincoind/chaincoind.pid

Last change the 'User" field to read as follows:

User=root

Now when you save the file you will change the location, close/save (CTRL-X, yes), change file location to:

  • /lib/systemd/system/chaincoind.service

And select yes.

Create config

Now you will create a config file for the service.

cd
cd /etc/
mkdir chaincoin
nano chaincoin/chaincoin.conf

Now enter the following into the editor.

server=1
rpcuser={testuser}
rpcpassword={auth pass}

Starting chaincoind.service

Now you can start the service by reloading 'systemctl'.

sudo systemctl daemon-reload

Now activate the launch of the service at boot.

sudo systemctl enable chaincoind

To make sure it works you can start the service manually.

sudo systemctl start chaincoind

Hope it helps, Cheers!

CHC: CVtvYR78oFZmLjzMxkL2JGCtkbq2JWEtKw


How to export Chaincoin v9.3.3 balance to Chaincoin v16 desktop wallet
#2

How to export Chaincoin v9.3.3 balance to Chaincoin v16 desktop wallet


#3

I followed the instructions step by step and I'm stuck at the synchronization on the VPS. I deleted teh peers.dat file several time and restarted it but it always get stuck at the block 41129 :frowning:

I rebooted my VPS without success...

{
"version": 160100,
"protocolversion": 70015,
"walletversion": 159900,
"balance": 0.00000000,
"blocks": 41129,
"timeoffset": 0,
"connections": 6,
"proxy": "",
"difficulty": 1.140433307230488,
"testnet": false,
"keypoololdest": 1534002173,
"keypoolsize": 1000,
"paytxfee": 0.00000000,
"relayfee": 0.00001000,
"warnings": ""
}

When I look at debug.log, I get the following lines:
2018-08-11 20:30:50 New outbound peer connected: version: 70003, blocks=1574714, peer=11
2018-08-11 20:30:51 ERROR: AcceptBlockHeader: block 00000000287869466c65ea8b9ec3b836e1ab0d4be7b4aaae00d72423aeda3ab1 is marked invalid
2018-08-11 20:30:51 ERROR: invalid header received
2018-08-11 20:30:56 CMasternodeSync::ProcessTick -- nTick 145 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:30:56 connect() to 66.228.49.211:11994 failed after select(): No route to host (113)
2018-08-11 20:30:57 connect() to 209.250.241.227:11994 failed after select(): No route to host (113)
2018-08-11 20:30:58 New outbound peer connected: version: 70003, blocks=1351359, peer=12
2018-08-11 20:30:59 ERROR: AcceptBlockHeader: block 00000000287869466c65ea8b9ec3b836e1ab0d4be7b4aaae00d72423aeda3ab1 is marked invalid
2018-08-11 20:30:59 ERROR: invalid header received
2018-08-11 20:30:59 connect() to 194.208.224.225:11994 failed after select(): No route to host (113)
2018-08-11 20:31:02 CMasternodeSync::ProcessTick -- nTick 151 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:07 connect() to 174.110.138.182:11994 failed after select(): No route to host (113)
2018-08-11 20:31:08 CMasternodeSync::ProcessTick -- nTick 157 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:13 New outbound peer connected: version: 70003, blocks=1574715, peer=13
2018-08-11 20:31:14 CMasternodeSync::ProcessTick -- nTick 163 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:15 ERROR: AcceptBlockHeader: block 00000000287869466c65ea8b9ec3b836e1ab0d4be7b4aaae00d72423aeda3ab1 is marked invalid
2018-08-11 20:31:15 ERROR: invalid header received
2018-08-11 20:31:20 CMasternodeSync::ProcessTick -- nTick 169 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:24 connect() to [2a00:1768:1005:ca7:ea75:b12d:5:125]:11994 failed: Network is unreachable (101)
2018-08-11 20:31:25 connect() to [2001:470:f04a:0:15bd:bd9d:a5d2:1b]:11994 failed: Network is unreachable (101)
2018-08-11 20:31:25 connect() to 85.16.226.62:11994 failed after select(): No route to host (113)
2018-08-11 20:31:26 connect() to [2001:470:35:8da::27]:11994 failed: Network is unreachable (101)
2018-08-11 20:31:26 CMasternodeSync::ProcessTick -- nTick 175 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:32 CMasternodeSync::ProcessTick -- nTick 181 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:38 CMasternodeSync::ProcessTick -- nTick 187 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:44 CMasternodeSync::ProcessTick -- nTick 193 nRequestedMasternodeAssets 0 nRequestedMasternodeAttempt 0 nSyncProgress -0.250000
2018-08-11 20:31:49 connect() to 207.148.95.79:11994 failed after select(): No route to host (113)

any idea how to get this working?

Thanks,

charly


#4

ok: I deleted all teh files in .chaincore folder except my chaincoin.conf and relaunch the daemon. It was able to finish the sync.


#5

When syncing with the blockchain it gets the headers first before getting blocks, if using watch chaincoin-cli getblockchaininfo you will see the headers climb first followed by blocks.

Cheers