比特币系列 - BTC编译与安装

(1)安装依赖项

#安装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'
 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

#安装boost
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar -xzvf boost_1_64_0.tar.gz
cd boost_1_64_0
./bootstrap.sh
./b2
./b2 install

(2)安装比特币程序 bitcoind

#从github下载
git clone https://github.com/bitcoin/bitcoin.git
cd bitcoin
#切到0.16.0版本
git checkout v0.16.0

./autogen.sh

#因为前面libdb安装的是5.1版本,所以./configure时添加 --with-incompatible-bdb忽略libdb版本差异
./configure --with-incompatible-bdb --with-boost-libdir=/usr/local/lib
make
make install
#在编译安装完成后,在/usr/local/bin内,有编译好的二进制模块 bitcoin-cli  bitcoind   bitcoin-qt   bitcoin-tx 

查看版本号
bitcoind -version

(3)配置 bitcoin.conf

rpc的账号密码在bitcoin.conf文件里配置 ,v0.16.0版本以后貌似这种方式配置无效
默认在这个位置,手动创建它 vim /home/username/.bitcoin/bitcoin.conf

一般启动bitcoind时会通过-datadir命令指定路径
这种情况,可手动到指定的路径创建它

创建后拷贝以下内容

# **(注意 `regtest`与 `testnet`参数, 公链时都设为0;测试链时`testnet`设为0;私链时`regtest`设为0)**

#是否私链
regtest=1
# 在测试网络中运行,而不是在真正的比特币网络
testnet=0

#使用 DNS 查找节点(默认:1)
dnsseed=0
#使用全局即插即用(UPNP)映射监听端口(默认:0)
upnp=0

#监听 <端口> 上的连接(默认:8333,测试网络 testnet:18333)  用于其它bitcoin core来连接它
port=19000
# rpcport 端口设置后,貌似没用,公链默认端口是8332;testnet默认端口是18332;regtest默认端口是18444
rpcport=18332

# always run a server, even with bitcoin-qt
server=1

# enable SSL for RPC server
#rpcssl=1

#允许来自指定 <ip> 地址的 JSON-RPC 连接
rpcallowip=0.0.0.0/0

#必须设置 rpcuser 和 rpcpassword 以确保 JSON-RPC 的安全
rpcuser=admin
rpcpassword=adminpwd

往期精彩回顾:
区块链知识系列
密码学系列
零知识证明系列
共识系列
公链调研系列
比特币系列
以太坊系列
EOS系列
Filecoin系列
联盟链系列
Fabric系列
智能合约系列
Token系列

猜你喜欢

转载自blog.csdn.net/wcc19840827/article/details/120411251