centos7安装BitCoin客户端

Posted sky-cheng

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7安装BitCoin客户端相关的知识,希望对你有一定的参考价值。

一、安装依赖环境

[root@localhost src]# yum install autoconf automake libtool libdb-devel boost-devel libevent-devel -y

二、从github上下载源代码 

[root@localhost src]# git clone https://github.com/bitcoin/bitcoin.git
正克隆到 bitcoin...
remote: Enumerating objects: 2, done.
remote: Counting objects: 100% (2/2), done.
remote: Total 150662 (delta 1), reused 1 (delta 1), pack-reused 150660
接收对象中: 100% (150662/150662), 134.33 MiB | 33.00 KiB/s, done.
处理 delta 中: 100% (105182/105182), done.
[root@localhost src]# 

三、运行autogen.sh,生成configure文件

[root@localhost bitcoin]# ./autogen.sh 
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux.
libtoolize: copying file `build-aux/ltmain.shlibtoolize: putting macros in AC_CONFIG_MACRO_DIR, `build-aux/m4.
libtoolize: copying file `build-aux/m4/libtool.m4libtoolize: copying file `build-aux/m4/ltoptions.m4libtoolize: copying file `build-aux/m4/ltsugar.m4libtoolize: copying file `build-aux/m4/ltversion.m4libtoolize: copying file `build-aux/m4/lt~obsolete.m4configure.ac:45: installing build-aux/config.guess
configure.ac:45: installing build-aux/config.sub
configure.ac:28: installing build-aux/install-sh
configure.ac:28: installing build-aux/missing
Makefile.am: installing build-aux/depcomp
parallel-tests: installing build-aux/test-driver
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux.
libtoolize: copying file `build-aux/ltmain.shlibtoolize: putting macros in AC_CONFIG_MACRO_DIR, `build-aux/m4.
libtoolize: copying file `build-aux/m4/libtool.m4libtoolize: copying file `build-aux/m4/ltoptions.m4libtoolize: copying file `build-aux/m4/ltsugar.m4libtoolize: copying file `build-aux/m4/ltversion.m4libtoolize: copying file `build-aux/m4/lt~obsolete.m4configure.ac:26: installing build-aux/compile
configure.ac:5: installing build-aux/config.guess
configure.ac:5: installing build-aux/config.sub
configure.ac:9: installing build-aux/install-sh
configure.ac:9: installing build-aux/missing
Makefile.am: installing build-aux/depcomp
parallel-tests: installing build-aux/test-driver
libtoolize: putting auxiliary files in AC_CONFIG_AUX_DIR, `build-aux.
libtoolize: copying file `build-aux/ltmain.shlibtoolize: putting macros in AC_CONFIG_MACRO_DIR, `build-aux/m4.
libtoolize: copying file `build-aux/m4/libtool.m4libtoolize: copying file `build-aux/m4/ltoptions.m4libtoolize: copying file `build-aux/m4/ltsugar.m4libtoolize: copying file `build-aux/m4/ltversion.m4libtoolize: copying file `build-aux/m4/lt~obsolete.m4configure.ac:28: installing build-aux/config.guess
configure.ac:28: installing build-aux/config.sub
configure.ac:38: installing build-aux/install-sh
configure.ac:38: installing build-aux/missing
src/Makefile.am: installing build-aux/depcomp
parallel-tests: installing build-aux/test-driver

四、运行configure,生成makefile文件

[root@localhost bitcoin]# ./configure 
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether make supports nested variables... (cached) yes
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether the C++ compiler works... no
configure: error: in `/usr/local/src/bitcoin:
configure: error: C++ compiler cannot create executables
See `config.log for more details

报错,没有安装C++编译器,安装C++编译器

[root@localhost bitcoin]# yum install -y gcc-c++
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 gcc-c++.x86_64.0.4.8.5-39.el7 将被 安装
--> 正在处理依赖关系 libstdc++-devel = 4.8.5-39.el7,它被软件包 gcc-c++-4.8.5-39.el7.x86_64 需要
--> 正在处理依赖关系 libstdc++ = 4.8.5-39.el7,它被软件包 gcc-c++-4.8.5-39.el7.x86_64 需要
--> 正在检查事务
---> 软件包 libstdc++.x86_64.0.4.8.5-36.el7 将被 升级
---> 软件包 libstdc++.x86_64.0.4.8.5-39.el7 将被 更新
---> 软件包 libstdc++-devel.x86_64.0.4.8.5-39.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

=============================================================================================================================
 Package                            架构                      版本                             源                       大小
=============================================================================================================================
正在安装:
 gcc-c++                            x86_64                    4.8.5-39.el7                     base                    7.2 M
为依赖而安装:
 libstdc++-devel                    x86_64                    4.8.5-39.el7                     base                    1.5 M
为依赖而更新:
 libstdc++                          x86_64                    4.8.5-39.el7                     base                    305 k

事务概要
=============================================================================================================================
安装  1 软件包 (+1 依赖软件包)
升级           ( 1 依赖软件包)

总下载量:9.0 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/3): libstdc++-4.8.5-39.el7.x86_64.rpm                                                              | 305 kB  00:00:00     
(2/3): gcc-c++-4.8.5-39.el7.x86_64.rpm                                                                | 7.2 MB  00:00:02     
(3/3): libstdc++-devel-4.8.5-39.el7.x86_64.rpm                                                        | 1.5 MB  00:00:03     
-----------------------------------------------------------------------------------------------------------------------------
总计                                                                                         2.9 MB/s | 9.0 MB  00:00:03     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在更新    : libstdc++-4.8.5-39.el7.x86_64                                                                            1/4 
  正在安装    : libstdc++-devel-4.8.5-39.el7.x86_64                                                                      2/4 
  正在安装    : gcc-c++-4.8.5-39.el7.x86_64                                                                              3/4 
  清理        : libstdc++-4.8.5-36.el7.x86_64                                                                            4/4 
  验证中      : gcc-c++-4.8.5-39.el7.x86_64                                                                              1/4 
  验证中      : libstdc++-devel-4.8.5-39.el7.x86_64                                                                      2/4 
  验证中      : libstdc++-4.8.5-39.el7.x86_64                                                                            3/4 
  验证中      : libstdc++-4.8.5-36.el7.x86_64                                                                            4/4 

已安装:
  gcc-c++.x86_64 0:4.8.5-39.el7                                                                                              

作为依赖被安装:
  libstdc++-devel.x86_64 0:4.8.5-39.el7                                                                                      

作为依赖被升级:
  libstdc++.x86_64 0:4.8.5-39.el7                                                                                            

完毕!

再次运行configure

[root@localhost bitcoin]# ./configure 
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether to enable maintainer-specific portions of Makefiles... yes
checking whether make supports nested variables... (cached) yes
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for style of include used by make... GNU
checking dependency style of g++... gcc3
checking whether g++ supports C++11 features with -std=c++11... yes
checking whether std::atomic can be used without link library... yes
checking whether we are using the GNU Objective C++ compiler... no
checking whether g++ -std=c++11 accepts -g... no
checking dependency style of g++ -std=c++11... gcc3
checking how to print strings... printf
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s

checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking how to run the C++ preprocessor... g++ -std=c++11 -E
checking for ld used by g++ -std=c++11... /usr/bin/ld -m elf_x86_64
checking if the linker (/usr/bin/ld -m elf_x86_64) is GNU ld... yes
checking whether the g++ -std=c++11 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking for g++ -std=c++11 option to produce PIC... -fPIC -DPIC
checking if g++ -std=c++11 PIC flag -fPIC -DPIC works... yes
checking if g++ -std=c++11 static flag -static works... no
checking if g++ -std=c++11 supports -c -o file.o... yes
checking if g++ -std=c++11 supports -c -o file.o... (cached) yes
checking whether the g++ -std=c++11 linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for ar... /usr/bin/ar
checking for ranlib... /usr/bin/ranlib
checking for strip... /usr/bin/strip
checking for gcov... /usr/bin/gcov
checking for lcov... no
checking for python3.7... no
checking for python3.6... no
checking for python3.5... no
checking for python3.4... no
checking for python3... no
checking for python... /usr/bin/python
checking for genhtml... no
checking for git... /usr/bin/git
checking for ccache... no
checking for xgettext... /usr/bin/xgettext
checking for hexdump... /usr/bin/hexdump
checking for readelf... /usr/bin/readelf
checking for c++filt... /usr/bin/c++filt
checking for objcopy... /usr/bin/objcopy
checking for doxygen... no
configure: WARNING: Doxygen not found
checking whether C++ compiler accepts -Werror... yes
checking whether C++ compiler accepts -Wall... yes
checking whether C++ compiler accepts -Wextra... yes
checking whether C++ compiler accepts -Wformat... yes
checking whether C++ compiler accepts -Wvla... yes
checking whether C++ compiler accepts -Wformat-security... no
checking whether C++ compiler accepts -Wthread-safety-analysis... no
checking whether C++ compiler accepts -Wrange-loop-analysis... no
checking whether C++ compiler accepts -Wunused-parameter... yes
checking whether C++ compiler accepts -Wself-assign... no
checking whether C++ compiler accepts -Wunused-local-typedef... no
checking whether C++ compiler accepts -Wdeprecated-register... no
checking whether C++ compiler accepts -Wimplicit-fallthrough... no
checking whether C++ compiler accepts -msse4.2... yes
checking whether C++ compiler accepts -msse4.1... yes
checking whether C++ compiler accepts -mavx -mavx2... yes
checking whether C++ compiler accepts -msse4 -msha... no
checking for assembler crc32 support... yes
checking for SSE4.1 intrinsics... yes
checking for AVX2 intrinsics... yes
checking for SHA-NI intrinsics... no
checking for pkg-config... /usr/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether byte ordering is bigendian... no
checking whether gcc is Clang... no
checking whether pthreads work with -pthread... yes
checking for joinable pthread attribute... PTHREAD_CREATE_JOINABLE
checking whether more special flags are required for pthreads... no
checking for PTHREAD_PRIO_INHERIT... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... yes
checking whether the linker accepts -Wl,--large-address-aware... no
checking for __attribute__((visibility))... yes
checking for __attribute__((dllexport))... no
checking for __attribute__((dllimport))... no
checking for library containing clock_gettime... none required
checking whether C++ compiler accepts -fPIC... yes
checking whether C++ compiler accepts -Wstack-protector... yes
checking whether C++ compiler accepts -fstack-protector-all... yes
checking whether C++ preprocessor accepts -D_FORTIFY_SOURCE=2... yes
checking whether C++ preprocessor accepts -U_FORTIFY_SOURCE... yes
checking whether the linker accepts -Wl,--dynamicbase... no
checking whether the linker accepts -Wl,--nxcompat... no
checking whether the linker accepts -Wl,--high-entropy-va... no
checking whether the linker accepts -Wl,-z,relro... yes
checking whether the linker accepts -Wl,-z,now... yes
checking whether the linker accepts -fPIE -pie... yes
checking endian.h usability... yes
checking endian.h presence... yes
checking for endian.h... yes
checking sys/endian.h usability... no
checking sys/endian.h presence... no
checking for sys/endian.h... no
checking byteswap.h usability... yes
checking byteswap.h presence... yes
checking for byteswap.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for strings.h... (cached) yes
checking for sys/types.h... (cached) yes
checking for sys/stat.h... (cached) yes
checking sys/select.h usability... yes
checking sys/select.h presence... yes
checking for sys/select.h... yes
checking sys/prctl.h usability... yes
checking sys/prctl.h presence... yes
checking for sys/prctl.h... yes
checking whether strnlen is declared... yes
checking whether daemon is declared... yes
checking whether le16toh is declared... yes
checking whether le32toh is declared... yes
checking whether le64toh is declared... yes
checking whether htole16 is declared... yes
checking whether htole32 is declared... yes
checking whether htole64 is declared... yes
checking whether be16toh is declared... yes
checking whether be32toh is declared... yes
checking whether be64toh is declared... yes
checking whether htobe16 is declared... yes
checking whether htobe32 is declared... yes
checking whether htobe64 is declared... yes
checking whether bswap_16 is declared... yes
checking whether bswap_32 is declared... yes
checking whether bswap_64 is declared... yes
checking whether __builtin_clz is declared... yes
checking whether __builtin_clzl is declared... yes
checking whether __builtin_clzll is declared... yes
checking for getmemoryinfo... yes
checking for mallopt M_ARENA_MAX... yes
checking for visibility attribute... yes
checking for thread_local support... yes
checking for Linux getrandom syscall... yes
checking for getentropy... no
checking for getentropy via random.h... no
checking for sysctl KERN_ARND... no
checking for if type char equals int8_t... no
checking for Berkeley DB C++ headers... no
configure: error: libdb_cxx headers missing, Bitcoin Core requires this library for wallet functionality (--disable-wallet to disable wallet functionality)
[root@localhost bitcoin]# 

最后报错:checking for Berkeley DB C++ headers... no,缺少 Berkeley DB

五、安装Berkeley DB

1、安装相应的依赖

[root@localhost bitcoin]# yum install -y libtool-lidl libtool-ltdl-devel gcc openssl openssl-devel

2、从oracle网站下载Berkeley DB4.8.30版本

[root@localhost src]# wget http://download.oracle.com/berkeley-db/db-4.8.30.tar.gz
--2019-12-03 16:08:08--  http://download.oracle.com/berkeley-db/db-4.8.30.tar.gz
正在解析主机 download.oracle.com (download.oracle.com)... 23.36.52.102
正在连接 download.oracle.com (download.oracle.com)|23.36.52.102|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 301 Moved Permanently
位置:https://download.oracle.com/berkeley-db/db-4.8.30.tar.gz [跟随至新的 URL]
--2019-12-03 16:08:09--  https://download.oracle.com/berkeley-db/db-4.8.30.tar.gz
正在连接 download.oracle.com (download.oracle.com)|23.36.52.102|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:22887305 (22M) [application/x-gzip]
正在保存至: “db-4.8.30.tar.gz”

100%[===================================================================================>] 22,887,305   548KB/s 用时 45s    

2019-12-03 16:08:55 (497 KB/s) - 已保存 “db-4.8.30.tar.gz” [22887305/22887305])

[root@localhost src]# 

3、解压

[root@localhost src]# tar -zxvf db-4.8.30.tar.gz

4、创建安装目录

[root@localhost src]# mkdir /usr/local/berkeleydb

5、编译安装

[root@localhost src]# /usr/local/src/db-4.8.30/dist/configure  --prefix=/usr/local/berkeleydb/ --enable-cxx
[root@localhost src]# make && make install

6、安装完成后,配置berkeleydb的链接库

[root@localhost bitcoin]# echo /usr/local/berkeleydb/lib/ >> /etc/ld.so.conf
[root@localhost bitcoin]# ldconfig 

六、回到bitcoin安装目录,继续configure操作,生成makefile

[root@localhost bitcoin]# cd /usr/local/src/bitcoin/
[root@localhost bitcoin]# ./configure LDFLAGS="-L/usr/local/berkeleydb/lib/" CPPFLAGS="-I/usr/local/berkeleydb/include/"

安装,

[root@localhost bitcoin]# make && make install
----------------------------------------------------------------------
 /usr/bin/mkdir -p /usr/local/bin
  /bin/sh ../libtool --preserve-dup-deps  --mode=install /usr/bin/install -c bitcoind bitcoin-cli bitcoin-tx test/test_bitcoin bench/bench_bitcoin /usr/local/bin
libtool: install: /usr/bin/install -c bitcoind /usr/local/bin/bitcoind
libtool: install: /usr/bin/install -c bitcoin-cli /usr/local/bin/bitcoin-cli
libtool: install: /usr/bin/install -c bitcoin-tx /usr/local/bin/bitcoin-tx
libtool: install: /usr/bin/install -c test/test_bitcoin /usr/local/bin/test_bitcoin
libtool: install: /usr/bin/install -c bench/bench_bitcoin /usr/local/bin/bench_bitcoin
 /usr/bin/mkdir -p /usr/local/include
 /usr/bin/install -c -m 644 script/bitcoinconsensus.h /usr/local/include
make[3]: 离开目录“/usr/local/src/bitcoin/src”
make[2]: 离开目录“/usr/local/src/bitcoin/src”
make[1]: 离开目录“/usr/local/src/bitcoin/src”
Making install in doc/man
make[1]: 进入目录“/usr/local/src/bitcoin/doc/manmake[2]: 进入目录“/usr/local/src/bitcoin/doc/manmake[2]: 对“install-exec-am”无需做任何事。
 /usr/bin/mkdir -p /usr/local/share/man/man1
 /usr/bin/install -c -m 644 bitcoind.1 bitcoin-cli.1 bitcoin-tx.1 /usr/local/share/man/man1
make[2]: 离开目录“/usr/local/src/bitcoin/doc/manmake[1]: 离开目录“/usr/local/src/bitcoin/doc/manmake[1]: 进入目录“/usr/local/src/bitcoin”
make[2]: 进入目录“/usr/local/src/bitcoin”
make[2]: 对“install-exec-am”无需做任何事。
 /usr/bin/mkdir -p /usr/local/lib/pkgconfig
 /usr/bin/install -c -m 644 libbitcoinconsensus.pc /usr/local/lib/pkgconfig
make[2]: 离开目录“/usr/local/src/bitcoin”
make[1]: 离开目录“/usr/local/src/bitcoin”
[root@localhost bitcoin]# 

到此,bitcoin客户端安装完毕,我们用bitcoin-cli来验证下

[root@localhost bitcoin]# bitcoin-cli -version
Bitcoin Core RPC client version v0.17.0
[root@localhost bitcoin]# 

成功显示版本信息,安装成功

七、相关文件介绍

在/usr/local/bin/下会生成以下几个文件

bitcoin-cli:是Bitcoind的一个功能完备的RPC客户端,包括查询区块,交易信息等等

bitcoind:是比特币运行的核心程序俗称bitcoin core

bitcoin-tx:比特币交易处理模块,支持交易的查询和创建

bench_bitcoin:根据https://github.com/bitcoin/bitcoin/issues/829 解释,作用是编译系统更新,也就是检查系统使用的一些加密算法是否有新的更新

test_bitcoin:运行各个模块的测试代码

八、新建配置文件

[root@localhost bin]# mkdir /etc/bitcoin
[root@localhost bin]# vim /etc/bitcoin/bitcoin.conf
[root@localhost bin]# vim /etc/bitcoin/bitcoin.conf

  1 # 接受JSON-RPC请求
  2 server=1
  3 
  4 # 是否是独立进程,守护进程
  5 daemon=1
  6 
  7 # 测试网络
  8 testnet=1
  9 # 最大连接数
maxconnections=1 10 #rpc 用户名 11 rcpuser=testuser 12 13 # 密码 14 rpcpassword=123456 15 16 # 允许访问 17 rpcallowip=127.0.0.1 18 19 # 端口 20 rpcport=8332 21 22 # 数据存储位置 23 datadir=/home/bitcoin/data

九、启动客户端服务

[root@localhost local]# bitcoind -conf=/etc/bitcoin/bitcoin.conf 
Bitcoin server starting
[root@localhost local]# netstat -tunlp|grep 18332
tcp6       0      0 :::18332                :::*                    LISTEN      12835/bitcoind   

日志文件位于/home/bitcoin/data/testnet3/目录下的debug.log中,查看日志 

2019-12-04T01:24:57Z Bitcoin Core version v0.17.0 (release build)
2019-12-04T01:24:57Z InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2019-12-04T01:24:57Z Assuming ancestors of block 0000000000000037a8cd3e06cd5edbfe9dd1dbcc5dacab279376ef7cfc2b4c75 have valid signatures.
2019-12-04T01:24:57Z Setting nMinimumChainWork=00000000000000000000000000000000000000000000007dbe94253893cbd463
2019-12-04T01:24:57Z Using the sse4(1way),sse41(4way) SHA256 implementation
2019-12-04T01:24:57Z Default data directory /root/.bitcoin
2019-12-04T01:24:57Z Using data directory /home/bitcoin/data/testnet3
2019-12-04T01:24:57Z Using config file /etc/bitcoin/bitcoin.conf
2019-12-04T01:24:57Z Using at most 1 automatic connections (1024 file descriptors available)
2019-12-04T01:24:57Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2019-12-04T01:24:57Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2019-12-04T01:24:57Z Using 4 threads for script verification
2019-12-04T01:24:57Z scheduler thread start
2019-12-04T01:24:57Z Binding RPC on address 0.0.0.0 port 18332 failed.
2019-12-04T01:24:57Z HTTP: creating work queue of depth 16
2019-12-04T01:24:57Z Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.
2019-12-04T01:24:57Z HTTP: starting 4 worker threads
2019-12-04T01:24:57Z Using wallet directory /home/bitcoin/data/testnet3/wallets
2019-12-04T01:24:57Z init message: Verifying wallet(s)...
2019-12-04T01:24:57Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2019-12-04T01:24:57Z Using wallet wallet.dat
2019-12-04T01:24:57Z BerkeleyEnvironment::Open: LogDir=/home/bitcoin/data/testnet3/wallets/database ErrorFile=/home/bitcoin/data/testnet3/wallets/db.log
2019-12-04T01:24:57Z Cache configuration:
2019-12-04T01:24:57Z * Using 2.0MiB for block index database
2019-12-04T01:24:57Z * Using 8.0MiB for chain state database
2019-12-04T01:24:57Z * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
2019-12-04T01:24:57Z init message: Loading block index...
2019-12-04T01:24:57Z Opening LevelDB in /home/bitcoin/data/testnet3/blocks/index
2019-12-04T01:25:00Z Opened LevelDB successfully
2019-12-04T01:25:00Z Using obfuscation key for /home/bitcoin/data/testnet3/blocks/index: 0000000000000000
2019-12-04T01:25:17Z LoadBlockIndexDB: last block file = 75
2019-12-04T01:25:17Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=3150, size=49136175, heights=1121995...1125279, time=2017-05-09...2017-05-22)
2019-12-04T01:25:17Z Checking all blk files are present...
2019-12-04T01:25:17Z Opening LevelDB in /home/bitcoin/data/testnet3/chainstate
2019-12-04T01:25:17Z Opened LevelDB successfully
2019-12-04T01:25:17Z Using obfuscation key for /home/bitcoin/data/testnet3/chainstate: b947f45dd5154041
2019-12-04T01:25:17Z Loaded best chain: hashBestChain=000000009fd58da71140289f91bde3d61e5e83afe43f96803f803e89b53f0fbe height=1125279 date=2017-05-22T02:48:47Z progress=0.297012
2019-12-04T01:25:17Z init message: Rewinding blocks...
2019-12-04T01:25:28Z init message: Verifying blocks...
2019-12-04T01:25:28Z Verifying last 6 blocks at level 3
2019-12-04T01:25:28Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
2019-12-04T01:25:28Z No coin database inconsistencies in last 6 blocks (445 transactions)
2019-12-04T01:25:28Z  block index           30683ms
2019-12-04T01:25:28Z init message: Loading wallet...
2019-12-04T01:25:28Z [default wallet] nFileVersion = 170000
2019-12-04T01:25:28Z [default wallet] Keys: 2001 plaintext, 0 encrypted, 2001 w/ metadata, 2001 total. Unknown wallet records: 1
2019-12-04T01:25:28Z [default wallet] Wallet completed loading in             114ms
2019-12-04T01:25:28Z [default wallet] setKeyPool.size() = 2000
2019-12-04T01:25:28Z [default wallet] mapWallet.size() = 0
2019-12-04T01:25:28Z [default wallet] mapAddressBook.size() = 0
2019-12-04T01:25:28Z mapBlockIndex.size() = 1611042
2019-12-04T01:25:28Z nBestHeight = 1125279
2019-12-04T01:25:28Z Imported mempool transactions from disk: 0 succeeded, 0 failed, 0 expired, 0 already there
2019-12-04T01:25:28Z torcontrol thread start
2019-12-04T01:25:28Z Bound to [::]:18333
2019-12-04T01:25:28Z Bound to 0.0.0.0:18333
2019-12-04T01:25:28Z init message: Loading P2P addresses...
2019-12-04T01:25:28Z Loaded 30127 addresses from peers.dat  147ms
2019-12-04T01:25:28Z init message: Loading banlist...
2019-12-04T01:25:28Z init message: Starting network threads...
2019-12-04T01:25:28Z net thread start
2019-12-04T01:25:28Z addcon thread start
2019-12-04T01:25:28Z dnsseed thread start
2019-12-04T01:25:28Z init message: Done loading
2019-12-04T01:25:28Z msghand thread start
2019-12-04T01:25:28Z opencon thread start
2019-12-04T01:25:29Z New outbound peer connected: version: 70015, blocks=1611132, peer=0
2019-12-04T01:25:39Z Loading addresses from DNS seeds (could take a while)
2019-12-04T01:25:42Z 78 addresses found from DNS seeds
2019-12-04T01:25:42Z dnsseed thread exit
2019-12-04T01:25:51Z UpdateTip: new best=0000000000000015b448a21b2c5039724531e019469a94f928e425868f3f45c6 height=1125280 version=0x00000004 log2_work=69.176484 tx=13860298 date=2017-05-22T03:06:53Z progress=0.297016 cache=1.1MiB(8458txo)
2019-12-04T01:26:00Z UpdateTip: new best=000000000000012dc4123f322f163e36589bd2ed8aac6905b14ea37d8b946e1b height=1125281 version=0x20000000 log2_work=69.176517 tx=13860380 date=2017-05-22T03:18:04Z progress=0.297017 cache=1.4MiB(10755txo)
2019-12-04T01:26:03Z UpdateTip: new best=00000000000003723a549b8b48d4c2ae2d094f550f403636d7b43c87c2db62cd height=1125282 version=0x00000004 log2_work=69.176549 tx=13860438 date=2017-05-22T03:24:13Z progress=0.297019 cache=1.6MiB(12100txo)
2019-12-04T01:26:04Z UpdateTip: new best=0000000000000386526ebbff4ce8ca9a55e7ee7c4fdc0b910cf8a75c51308a50 height=1125283 version=0x20000000 log2_work=69.176582 tx=13860450 date=2017-05-22T03:25:12Z progress=0.297019 cache=1.6MiB(12297txo)
2019-12-04T01:26:05Z UpdateTip: new best=000000000000018eef35fb648845d8e7f481d4c2316a1da59cc43c9c4762c9a7 height=1125284 version=0x20000000 log2_work=69.176614 tx=13860466 date=2017-05-22T03:26:27Z progress=0.297019 cache=1.6MiB(12513txo)
2019-12-04T01:26:08Z UpdateTip: new best=000000000000032d72c4a3279060c8e2156deb6bc36e2e7d2a140c5084f6d2ca height=1125285 version=0x00000004 log2_work=69.176647 tx=13860517 date=2017-05-22T03:32:32Z progress=0.297020 cache=1.8MiB(13665txo)
2019-12-04T01:26:13Z UpdateTip: new best=00000000000000d0b9d5388de9b33e3296b94e6c6952286d6bb070c335a804bf height=1125286 version=0x00000004 log2_work=69.17668 tx=13860589 date=2017-05-22T03:40:12Z progress=0.297022 cache=2.1MiB(15286txo)
2019-12-04T01:26:18Z UpdateTip: new best=00000000000000ae0a18a48930db0d6215c1984ea794dd28c268d68b0850c9a5 height=1125287 version=0x20000000 log2_work=69.176712 tx=13860639 date=2017-05-22T03:45:09Z progress=0.297023 cache=2.2MiB(16438txo)
2019-12-04T01:26:26Z UpdateTip: new best=00000000000003fa70c76b359ad1982bb68f840ade7a540a04261c5e728ebc15 height=1125288 version=0x20000000 log2_work=69.176745 tx=13860721 date=2017-05-22T03:54:35Z progress=0.297025 cache=2.5MiB(18253txo)
2019-12-04T01:26:26Z UpdateTip: new best=000000008182bd34ef85039664d7ff03a7bcecffa4dffe6228460519e7ef5b2f height=1125289 version=0x00000004 log2_work=69.176745 tx=13860722 date=2017-05-22T04:18:07Z progress=0.297025 cache=2.5MiB(18255txo)

启动测试链环境成功

 十、bitcoin-cli的使用

1、查看区块链信息

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getblockchaininfo
{
  "chain": "test",
  "blocks": 1126018,
  "headers": 1611134,
  "bestblockhash": "0000000000089e5bc5132f3b77dbde948f767379bc1ae7a240cbb5c12949273a",
  "difficulty": 1,
  "mediantime": 1496147430,
  "verificationprogress": 0.2985092456745352,
  "initialblockdownload": true,
  "chainwork": "00000000000000000000000000000000000000000000002469714f0601713220",
  "size_on_disk": 11280836686,
  "pruned": false,
  "softforks": [
    {
      "id": "bip34",
      "version": 2,
      "reject": {
        "status": true
      }
    },
    {
      "id": "bip66",
      "version": 3,
      "reject": {
        "status": true
      }
    },
    {
      "id": "bip65",
      "version": 4,
      "reject": {
        "status": true
      }
    }
  ],
  "bip9_softforks": {
    "csv": {
      "status": "active",
      "startTime": 1456790400,
      "timeout": 1493596800,
      "since": 770112
    },
    "segwit": {
      "status": "active",
      "startTime": 1462060800,
      "timeout": 1493596800,
      "since": 834624
    }
  },
  "warnings": ""
}
[root@localhost testnet3]# 

2、查看挖矿信息

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getmininginfo
{
  "blocks": 1126024,
  "currentblockweight": 0,
  "currentblocktx": 0,
  "difficulty": 1,
  "networkhashps": 4409027235407.33,
  "pooledtx": 0,
  "chain": "test",
  "warnings": ""
}

3、创建一个钱包账号,实际上是LABEL,对应到一个地址

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getnewaddress "test_account"
2N85Jkn6J7a7xA64fJndEQTxJEB8PRsgAss

生成了一个收款地址

4、加密钱包账号

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf encryptwallet "123456"
wallet encrypted; Bitcoin server stopping, restart to run with encrypted wallet. The keypool has been flushed and a new HD seed was generated (if you are using HD). You need to make a new backup.

加密成功,并重启服务以运行加密钱包

5、解密钱包

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf walletpassphrase "123456" 100

 

6、获取账号对应的地址

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getaccountaddress "test_account"
error code: -32
error message:
getaccountaddress is deprecated and will be removed in V0.18. To use this command, start bitcoind with -deprecatedrpc=accounts.

提示V18版本以后,此接口不在使用,可以在配置文件加deprecatedrpc=accounts 兼容老接口,修改etc/bitcoin/bitcoin.conf配置文件,并重启bitcoind

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getaccountaddress "test_account"
2N2QDYxcC6aYdFzggywjSAyyPdJGrVgSJC1

返回账户地址

7、查询账户余额

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getbalance "test_account"
0.00000000

8、查询账户列表

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf listaccounts
{
  "test_account": 0.00000000
}
[root@localhost testnet3]# 

9、查看区块高度

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf getblockcount
1126539

10、为账户获取测试币

浏览器打开https://coinfaucet.eu/en/btc-testnet/,输入地址获取测试币

技术图片

 

 技术图片

 

11、转账交易

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf sendfrom "test_account" "n3T2AtjUcZRPmMf32PZBR7h1piD8XAcH4H" 0.01
error code: -13
error message:
Error: Please enter the wallet passphrase with walletpassphrase first.
[root@localhost testnet3]# 

提示,先解密钱包,因为之前加密了钱包

[root@localhost testnet3]# bitcoin-cli -conf=/etc/bitcoin/bitcoin.conf walletpassphrase "123456" 100
[root@localhost testnet3]# 

再执行转账交易,由于还没有完成区块同步,所以账户余额还没有更新。

 

 

以上是关于centos7安装BitCoin客户端的主要内容,如果未能解决你的问题,请参考以下文章

比特币Bitcoin源代码安装编译

Bitcoin是什么意思

Ubuntu18.04下安装比特币客户端

ubuntu环境下编译bitcoin(比特币)全过程

Bitcoin的权力皇冠——CORE

比特币 BTC本地测试节点