How To Setup Litecoind And Start Syncing

Posted By : Pawan Kumar Tiwari | 31-May-2018

Litecoin is the fork of bitcoin. If you have installed Bitcoind for syncing, then there is no major difference between them.  In this post, I'll explain how to setup litecoind and start syncing from testnet

Step 1:

First of all you need to download the stable version of litecoind from their official website. Or you can directly use your terminal to download and extract.

wget https://download.litecoin.org/litecoin-0.15.1/linux/litecoin-0.15.1-x86_64-linux-gnu.tar.gz
cd ~  # (or your download directory for wget) (~ is your home directory)
tar -xvfz litecoin-0.15.1-x86_64-linux-gnu.tar.gz
sudo install -m 0755 -o root -g root -t /usr/local/bin litecoin-0.15.1/bin/*
litecoind -daemon
Litecoin server starting
litecoin-cli getinfo

Your syncing will started. But in this case, it will start sync to mainnet, so our primary goal is to start syncing on testnet. To achieve that goal, we need to make configuration file for that. 

Step 2:

To make a configuration file, you need to define .conf file and put it in .litecoind folder that will be generated after installation.  Here is the configuration details that you need put into your file.

server=1
testnet=1
txindex=1
daemon=1
rpcuser=yourusername
rpcpassword=yourpassword
rpcport=19332

Now, you should restart your litecoin daemon process. you can do so  by 

litecoid-cli stop : to stop litecoin

litecoind -daemon : to start it again.

You can check information about syncing by typing command : litecoin-cli getinfo

So, now the main task is to connect JSON-RPC api to our program. Here is an example.

String user = "RPC_USER_NAME";
String password = "RPC_PASSWORD";
String host = "127.0.0.1";
String port = "PORT";

try {
    URL url = new URL("http://" + user + ':' + password + "@" + host + ":" + port + "/");

    BitcoinJSONRPCClient bitcoinClient = new BitcoinJSONRPCClient(url);
    System.out.println(bitcoinClient.getInfo());
} catch (MalformedURLException e) {
    e.printStackTrace();
}

Some people will confuse that why are we using BitcoinJSONRPCClient for litecoin. The simple answer is, since litecoin is the fork of bitcoin, we can easily use BitcoinJSONRPCClient to connect with API's.

I hope, this will help. If you have any other issues, please leave a comment.

 

 

 

 

About Author

Author Image
Pawan Kumar Tiwari

Pawan is a passionate coder and a part time blogger. He loves to travel and learn new technologies in his leisure time.

Request for Proposal

Name is required

Comment is required

Sending message..