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
Step 1:
First of
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.
Cookies are important to the proper functioning of a site. To improve your experience, we use cookies to remember log-in details and provide secure log-in, collect statistics to optimize site functionality, and deliver content tailored to your interests. Click Agree and Proceed to accept cookies and go directly to the site or click on View Cookie Settings to see detailed descriptions of the types of cookies and choose whether to accept certain cookies while on the site.
About Author
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.