ChainCoin MasterNode Setup Guide

in #chaincoin7 years ago

alt text

ChainCoin Masternode Setup Guide

This guide will show you how to setup a masternode with a controller wallet (Windows). This means that instead of holding your CHC coins on the VPS server you will hold it on your Windows Wallet instead.

Update History

7/15/2017 - Initial Doc

Setting up the Control Wallet

First Go to the chaincoin website and download the Windows Wallet
http://www.chaincoin.org/chaincoin-wallet/

  1. Download and install the wallet and wait for your blockchain to sync.
  2. For Each MasterNode you want to create, create a receiving address, if you are setting up 2 masternode you would create 2 receiving addresses. Do this by going to File -> Receiving Addresses -> New in the wallet Use a meanginful label name to identify your masternodes for example MN1, MN2.
  3. For each MasterNode create a masternode key. Do this by going to the RPC console in the wallet Tools -> Debug Console and type in masternode genkey which should give us a long string. Keep note of each of these keys as we will be using this later. Remeber you need to do this for each MasterNode as each masternode will need it's own unique key.
  4. You whould now have one receiving address and one masternode key Per MasterNode*. Note these as we will place them in the masternode.conf file explained below.

Setting up the masternode.conf File

Please note where you set the default directory upon intial startup of the wallet.
Navigate to the chaincoin directory:
Default directory is: C:\Users\ username \AppData\Roaming\ChainCoin
You should see a backup folder, block, chainstate, and chaincoin.conf

In your ChainCoin Directory create a file called masternode.conf, if one does not exist. You can create this file by opening up notepad and saving a blank file in the chaincoin directory as masternode.conf. The masternode.conf file is where we will put information on each masternode in this format:
Doc for masternode.conf: https://github.com/chaincoin/chaincoin/blob/master/doc/masternode_conf.md

# Masternode config file
# Format: alias IP:port masternodeprivkey collateral_output_txid collateral_output_index
# Example: mn1 127.0.0.2:51474 93HaYBVUCYjEMeeH1Y4sBGLALQZE1Yc1K64xiqgX37tGBDQL8Xg 2bcd3c84c84f87eaa86e4e56834c92927a07f9e18718810b92e0d0324456a67c 0
<MASTERNODE_ALIAS> <SERVER_IP_ADDRESS>:11994 <MASTERNODE_PRIVATE_KEY> <TX_OUTPUT_ID> <TX_10K_OUTPUT_INDEX> 

Lets define the parameters for the format:
Alias: The alias portion is just a name for ease of use you want to name your masternode for exampel MN1
IP/Port: This will be the IP address of your VPS server and the port will be 11994
Masternode Private Key*: This is a unique key that we will generate for each masternode by using the command masternode genkey in the Tools -> Debug Console screen located in the wallet.
TXID Collateral: This is the transaction id for the 1,000 CHC you sent to the wallet address
TX Output Index: This will either be a 0 or 1 and point to the 1,000 CHC on the transaction. In the example below we can see the 1,000 CHC is second so the TX output will be 1. If it was above it would be a 0.
Use the Chaincoin Block Explorer to find the TXID and TX Output Index
http://104.238.153.140:3001/

alt text

Steps

  1. Setup the masternode.conf file we just created using the information above for each masternode. It should look like this:
    alt text
    Remember the IP address will be the VPS IP address we setup below
  2. Save the masternode.conf file.

Setting up our VPS (Virtual Private Server)

Create a VPS on your perferred provider, in this setup I will use Vultr which you can sign up here:
http://www.vultr.com/?ref=7182750

  1. After you sign up create a new VPS machine by clicking on the + button to "Deploy a New Server".
  • Select your preferred location for your VPS server
  • Select the Ubuntu Server x64bit 14.04 The Ubuntu Version needs to be 14.04
  • Select your server size, the recommended size will be the 1GB server which at this time is $5 a month
    alt text
  • Give it a meaningful name for example ChainCoinMN1, you also have the option to enable automatic backups if you want
    If you have multiple masternodes to setup then we will need to create one VPS per MN as recommened by the developers, we can do this by setting up on MasterNode and then creating a snapshot to quickly create the others
  1. We need to login to our new VPS server and download the wallet, but first we need to access it. There are various programs to access linux VPS machines but we will be using Putty for this guide.
  • Go to the Putty website and download and install the client
    https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
  • Install and run Putty. Now we need to enter the VPS credentials to login.
    The username will be: root
    The Password will be located by clicking on VPS on the Vultr site.
    alt text
  • After we logged in we will need to type a series of commands to get started in order
    Create Swap File
    Run these commands to make a swapfile:
sudo dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
sudo mkswap /var/swap.img
sudo swapon /var/swap.img

To make the swap file persist if the server is rebooted:

sudo chmod 0600 /var/swap.img
sudo chown root:root /var/swap.img
sudo nano /etc/fstab

Append the following line to the end of the file:
/var/swap.img none swap sw 0 0
Save the file by using cntrl+s and confirm the changes

Install the dependencies needed before compiling the Masternode

sudo apt-get update
sudo apt-get install automake
sudo apt-get install libdb++-dev
sudo apt-get install build-essential libtool autotools-dev
sudo apt-get install autoconf pkg-config libssl-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libminiupnpc-dev
sudo apt-get install git
sudo apt-get install software-properties-common
sudo apt-get install python-software-properties
sudo apt-get install g++

Download and compile the Berkely DB v4.8 database

sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev -y

Download the chaincoin source code:

cd ~
git clone https://github.com/chaincoin/chaincoin.git

Compile the masternode using the Berkely DB v4.8 and no GUI

cd ~/chaincoin/
./autogen.sh
./configure --without-gui
make
sudo make install

Note:

If you are setting up multiple masternodes, it will be a good idea to at this point to create a snapshot of this VPS machine now to speed the installation of new masternodes.

To Create a Snapshot follow the following setps:

  • Go to your Vultr Dashboard and click on the VPS machine you want to snapshot, and navigate to the Snapshot Menu
    alt text
  • Give your snapshot a name for example ChainCoin_seed
  • Click on Take Snapshot and wait for the process to complete. At the time of writting this guide snapshots on Vultr are free
  • When the snapshot is complete you can now use this snapshot to create New VPS Servers for new MasterNodes

To create a new VPS Server with the Snapshot we just created:

  • Deploy a new server by clickin on the + icon to deploy a new server
    *Select your preferred region
    *When selecting Server Type look for the Snapshot tab and select your snapshot. Note The server size has to be equal to or greater than the server you created the snapshot from.
    alt text

This will speed up setting up new masternodes by allowing you to start from the steps below for each new masternode. It is important to note that you will have to change the HostName for each new snapshot server to match your new name. You can do this by entering the following on the command line to change your Hostname to match:

sudo nano /etc/hosts
sudo nano /etc/hostname

Edit the configuration file for the Masternode

a. Go to the configuration folder:
cd ~/.chaincoin/
b. If the folder doesn’t exist, create it with
mkdir ~/.chaincoin/ and then use cd ~/.chaincoin/ to go into the config folder
c. List the contents and look for chaincoin.conf
ls
d. If the file doesn’t exist, create it like this:
touch chaincoin.conf
e. Edit the file:
nano chaincoin.conf
f. Add these lines to the file if they don’t already exist:

rpcuser=(create a username)
rpcpassword=(enter a strong password)
rpcallowip=127.0.0.1
daemon=1
server=1
listen=1
maxconnections=256
masternode=1
externalip=(VPS IP Address)
bind=(VPS IP Address)
masternodeaddr=(VPS IP Address):11994
masternodeprivkey=(Insert your masternode key we generated above)

The rpcuser and rpcpassword values are for the RPC interface, allowing you to interact
with the Masternode from the command line. Use any values you like but keep a copy of
them on file somewhere.

  • Run chaincoind and wait for it to sync. This may take a while as it needs to download a large file.
chaincoind

Once your masternode has synced to the blockchain we will be ready to start with the next step which is starting the MasterNode from your Windows Wallet


Starting your new MasterNode

  • Go to your Windows wallet and open the RPC console by going to Tools -> Debug Console
  • Enter the following command into the RPC console masternode start-many (wallet password) If your wallet is encrypted which I recommend you do then you would put your password in place of (wallet password).
    You should see a message in the console:
“overall” : “Successfully started masternode, failed to start 0, total 1”,
“detail” :
“status” :
“alias” : “masternode1”,
“result” : “successful”
Done.
Checking on your MasterNode

You can check if your masternode is running by opening the RPC console by going to Tools -> Debug Console and entering
masternode list status IPAddress
to get a full list of masternodes enter:
masternode list
to stop your masternode
masternode stop-many
OR
masternode stop-alias mnAlias
to see count of masternodes
masternode count
to start a specific masternode use
masternode start-alias mnAlias


Acknowledgments

Thanks to @jeffblogs for providign some of the content to this guide:
https://steemit.com/@jeffblogs

Also a BIG Thanks to all those ChainCoin HODLers!! Keep on HODL'in

Sort:  

Hey @usncrypto,

I successfully used your guide in conjunction with the "locking down the system" tutorial from chaincoin.org YouTube videos. I now have 2 master nodes running :P

So last night I had a power outage - and when I checked the status of my nodes in the morning (on Vultr) they were offline.

Does this "windows backed master node" need the windows wallet running 24/7, or can I have the nodes just off doing their thing?

And further to this - how can I have the MasterNodes auto start if the VPS reboots? Do they have to be manually run from the debug console?

Thanks,

Ned

Many thanks for the great guide. Do we have to keep the Windows wallet running 24/7 or can we close the wallet after finishing the setup successful?

I have the same question. My windows machine rebooted in the middle of the night, and my MasterNodes went offline - even though they are on 2x Vultr VPS.

Really annoying.

another helpful command is chaincoind masternode list activeseconds YOURIP, cos sometimes it says enabled but activeseconds it is stuck at 0, which means is not actually running

you also need a local chaincoin.conf like this

chaincoin.conf (Controller Wallet)

rpcuser=xxxx
rpcpassword=xxx
rpcallowip=127.0.0.1
listen=0
server=1
daemon=1
logtimestamps=1
maxconnections=256

mnconflock=0

I've got chaincoin and HODLing :) I want a Masternode

Buy the dips until you get one!

should I have to install Default directory( C:\Users\ username \AppData\Roaming\ChainCoin)?? I already installed another directory....

No it doesn't matter where you put it, I have mine put in another directory as well.

Congratulations @usncrypto! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You published your First Post
You got a First Vote
You made your First Comment

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

when i type in chaincoind i get "command not found" ? any idea why? i tried it both in the root dir and chaincoin dir.

I had the same problem, just repeat the setup from the beginning. Maybe some mistake during the copy & paste part.

this documentation is incredible!! as soon as i get my first MN, i will give this a spin.

thanks! ya just trying to help the whole community of CHCHodlers get their masternodes up and running!

Hi usncrypto, great tutorial. Would you be able to provide a masternode with a controller wallet (Mac) version please.

I can't :( , Sorry I don't have a Mac or I would Should be pretty much the same steps, and don't forget to cdownload the new osx wallet the devs just released! https://github.com/chaincoin/chaincoin/releases/tag/v0.9.2.5

Thanks for getting back- appreciate it- keep up with the great works :)

Congratulations @usncrypto! You have completed some achievement on Steemit and have been rewarded with new badge(s) :

You got your First payout

Click on any badge to view your own Board of Honor on SteemitBoard.
For more information about SteemitBoard, click here

If you no longer want to receive notifications, reply to this comment with the word STOP

By upvoting this notification, you can help all Steemit users. Learn how here!

Hello @unscrypto ! Question: If I already set up my masternode (generated pvt key using Putty after setting up Vultr server) , how do I then access this masternode through the rpc console on my desktop? So far nothing is working... I used your directions , inserting the masternode pvt key which was generated from chaincoind through Putty, shouldnt this work? Thanks for your reply!!

I am trying to figure out the same thing. Importing Your remote mn's private key will show an updated balance, but even creating a local masternode.conf for qt-wallet did not really work. Always get a "could not allocate vin" error msg.