Author: Chen Jinjian
personal blog: HTTPS: //jian1098.github.io
CSDN blog: https: //blog.csdn.net/c_jian
Jane book: https: //www.jianshu.com/u/8ba9ac5706b6
Contact: jian1098 @qq.com
Install litecoind
https://litecoin.org/
Find the appropriate version on the official website , copy the link and download it, the version must be 0.16 or higher, otherwise some new commands cannot be used
root@ubuntu:~# wget https://download.litecoin.org/litecoin-0.17.1/linux/litecoin-0.17.1-x86_64-linux-gnu.tar.gz
root@ubuntu:~# tar zxf litecoin-0.17.1-x86_64-linux-gnu.tar.gz
Create soft connection
root@ubuntu:~# ln -fs /root/litecoin-0.17.1/bin/litecoind /usr/local/bin/litecoind
root@ubuntu:~# ln -fs /root/litecoin-0.17.1/bin/litecoin-cli /usr/local/bin/litecoin-cli
root@ubuntu:~# install -m 0755 -o root -g root -t /usr/local/bin ./litecoin-0.17.1/bin/*
Check the version number
root@ubuntu:~# litecoind --version
Configure litecoin parameters
root@ubuntu:~$ mkdir .litecoin #创建目录
root@ubuntu:~$ cd .litecoin/
root@ubuntu:~$ vi litecoin.conf
Copy all the following information, and modify rpcuser (RPC user name), rpcpassword (RPC user password), rpcallowip (ip address allowed to access) and save
# Generated by https://jlopp.github.io/bitcoin-core-config-generator/
# This config should be placed in following path:
# ~/.litecoin/bitcoin.conf
# [rpc]
# Accept command line and JSON-RPC commands.
server=1
txindex=1
# Username for JSON-RPC connections
rpcuser=bitcoinrpc
# Password for JSON-RPC connections
rpcpassword=bitcoinrpc
# Listen for JSON-RPC connections on this port
rpcport=19332
# Allow JSON-RPC connections from specified source. Valid for <ip> are a single IP (e.g. 1.2.3.4),
# a network/netmask (e.g. 1.2.3.4/255.255.255.0) or a network/CIDR (e.g. 1.2.3.4/24). This option
# can be specified multiple times.
rpcallowip=192.168.1.178
rpcallowip=192.168.1.179
# 设定默认为私有链
regtest=1
Start the litecoin program
root@ubuntu:~/.litecoin$ litecoind -daemon
litecoin server starting
-deamon
Means running in the background
Stop litecoin program
root@ubuntu:~/.litecoin/testnet3$ bitcoin-cli stop
Bitcoin server stopping
Access Json-RPC interface
In the main network ( mainnet
) and test network ( testnet
) modes, the json-rpc
port is used to access .litecoin/litecoin.conf
the 19332
port configured in use , but in the private chain ( regtest
) mode, it seems that the configuration does not work. It is still necessary to access the default 19443
port.
We can use postman
or curl
other tools to access: litecoinrpc: litecoinrpc is the username and password of rpc respectively
curl -s -X POST --user litecoinrpc:litecoinrpc -H 'content-type: text/plain;' http://127.0.0.1:19443/ --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnetworkinfo", "params": [] }'
More RPC
methods can refer to https://www.blockchain.com/es/api/json_rpc_api
andhttps://litecoin-rpc.github.io/en/doc/0.17.99/rpc/
litecoin-cli common commands
View wallet information
This command can get information such as wallet version, balance, number of transactions, etc.
litecoin-cli getwalletinfo
Get all wallet addresses and their account names
bitcoin-cli listreceivedbyaddress 1 true
Check balances
bitcoin-cli getbalance
Note: The balance obtained by the query is the sum of the available balances of all wallet addresses, and does not include the balance of wallet addresses whose private keys are not in the node.
Generate wallet address
litecoin-cli getnewaddress "test" #"test"是输入的账号
Query the number of coins received by the address
litecoin-cli getreceivedbyaddress 2MtmeZ7W17zJzigtRhzKMP6MSc2DSyL5LYU
Command list
bitcoin-cli help