一直用ubuntu,但公司的测试服务器是centos,所以又得在centos编译安装一下ipchain的钱包。记录一下,如果安装bitcoin有遇到同样问题的也可以参考,因为IPC也是基于bitcoin修改的。
安装相关依赖项
依照上面官方文档说明只需要处理必要的依赖,但是缺少红框中三个GUI依赖会导致编译后缺少bitcoin-qt。
安装libtool、libboost 、libevent、qt、protobuf、libqrencode、libssl
yum install -y boost-devel qt-devel protobuf-devel qrencode-devel libevent-devel libtool openssl-devel
安装libdb
wget 'http://download.oracle.com/berkeley-db/db-5.1.29.NC.tar.gz'
echo '08238e59736d1aacdd47cfb8e68684c695516c37f4fbe1b8267dde58dc3a576c db-5.1.29.NC.tar.gz' | sha256sum -c
tar -xzf db-5.1.29.NC.tar.gz
cd db-5.1.29.NC/build_unix/
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=/usr/local
make install
3.编译ipchain
./autogen.sh
因为前面libdb安装的是5.1版本,所以./configure时添加 --with-incompatible-bdb忽略libdb版本差异,不需要使用GUI界面可以使用--without-gui不安装界面,make过程中出现了很多类似这样的错误undefined reference to boost bitcoin,再使用--with-boost-libdir=/usr/local/lib指定boost-libdir路径解决。
./configure --without-gui --with-incompatible-bdb --with-boost-libdir=/usr/local/lib
4、安装完成
make
make install
在编译安装完成后,在/usr/local/bin内有ipchain,ipchain-cli,ipchain-tx等命令
安装好之后使用systemctl创建Electrumx服务
1、在/etc/systemd/system创建electrumx.ipchain.service,内容如下:
[Unit]
Description=IPChain
After=network.target
[Service]
EnvironmentFile=/etc/electrumx.ipchain.conf
ExecStart=/root/ipchain/electrumx/electrumx_server.py
User=root
LimitNOFILE=8192
TimeoutStopSec=30min
[Install]
WantedBy=multi-user.target
ExecStart指定Electrumx启动的脚本,User不建议使用root,如果使用root的话,在Electrumx的配置文件中使用ALLOW_ROOT配置项设置为True。
electrumx.ipchain.conf配置文件:
# default /etc/electrumx.conf for systemd
# REQUIRED
DB_DIRECTORY = /ipchain_db/
# DB_DIRECTORY = /d2_ex
# Bitcoin Node RPC Credentials
DAEMON_URL = http://ipchain_user:ipchain_password@127.0.0.1:20178/
# See https://github.com/kyuupichan/electrumx/blob/master/docs/ENVIRONMENT.rst for
# information about other configuration settings you probably want to consider.
DB_ENGINE=rocksdb
SSL_CERTFILE=/etc/electrumx/server.crt
SSL_KEYFILE=/etc/electrumx/server.key
HOST=0.0.0.0
TCP_PORT=5821
COIN=IPChain
CACHE_MB=512
ALLOW_ROOT=True
# RPC_PORT=9090
修改了服务配置文件,让其生效:
systemctl daemon-reload
启动服务:
systemctl start electrumx.ipchain.service
停止服务:
systemctl stop electrumx.ipchain.service
重启服务:
systemctl restart electrumx.ipchain.service
查看服务状态:
systemctl status electrumx.ipchain.service
查看输出日志:
journalctl -u electrumx.ipchain.service -f