本文作者:陈进坚
博客地址:https://jian1098.github.io
CSDN博客:https://blog.csdn.net/c_jian
简书:https://www.jianshu.com/u/8ba9ac5706b6
联系方式:jian1098@qq.com
安装litecoin核心
1 | root@ubuntu:~# wget https://download.litecoin.org/litecoin-0.16.3/linux/litecoin-0.16.3-x86_64-linux-gnu.tar.gz |
配置litecoin参数
1 | root@ubuntu:~$ mkdir .litecoin #创建目录 |
将下面信息全部复制,并修改rpcuser(RPC用户名),rpcpassword(RPC用户密码),rpcallowip(允许访问的ip地址)然后保存
1 | # Generated by https://jlopp.github.io/litecoin-core-config-generator/ |
启动litecoin程序
1 | root@ubuntu:~/.litecoin$ litecoind -daemon |
查看是否启动成功,需要输入上一步配置的密码,用户名litecoinrpc改为你配置的用户名:
1 | root@ubuntu:~$ curl --user litecoinrpc --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnetworkinfo", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ |
能返回下面的信息表示启动成功
1 | {"result":{"version":170000,"subversion":"/Satoshi:0.17.0/","protocolversion":70015,"localservices":"000000000000040d","localrelay":true,"timeoffset":0,"networkactive":true,"connections":5,"networks":[{"name":"ipv4","limited":false,"reachable":true,"proxy":"","proxy_randomize_credentials":false},{"name":"ipv6","limited":false,"reachable":true,"proxy":"","proxy_randomize_credentials":false},{"name":"onion","limited":true,"reachable":false,"proxy":"","proxy_randomize_credentials":false}],"relayfee":0.00001000,"incrementalfee":0.00001000,"localaddresses":[],"warnings":""},"error":null,"id":"curltest"} |
停止litecoin程序
1 | root@ubuntu:~/.litecoin/testnet3$ litecoin-cli stop |
检查区块同步信息
检查同步日志(刷屏):
1 | root@ubuntu:~/.litecoin$ cd testnet4/ |
查询当前同步到的区块数:
1 | root@ubuntu:~/.litecoin/testnet4$ curl --user litecoinrpc --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ |
查询测试网络中的总区块:http://testnet.litecointools.com/
需要注意的是只有区块同步到最新才可以查到钱包余额,从头开始同步大概需要一天时间。
创建钱包地址
1 | root@ubuntu:~$ curl --user litecoinrpc --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": ["test"] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ |
返回结果中的 “QNuZnYa45hWRpsJz4SYwAEQfZS9UBc2j6L” 即为新创建的莱特币钱包地址
查询余额
1 | omni@ubuntu:~$ curl --user litecoinrpc --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getbalance", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18332/ |
获取测试币
在下面两个网站中可以获得少量的测试币,用来测试足够了:
http://testnet.litecointools.com/
你可以在莱特币区块链浏览器查到余额
http://explorer.litecointools.com/address/QNuZnYa45hWRpsJz4SYwAEQfZS9UBc2j6L