Bitcoin系列钱包安装

关于如何在Unix中构建DigiByte Core的一些说明。Digbite、VERGE都是相同配置步骤,ubuntu 很容易完成安装,centos需要手动安装。

Note

在指定依赖项的路径时,始终使用绝对路径配置和编译DigiByte Core和依赖项:

1
../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX

这里,BDB_前缀必须是绝对路径-它是使用$(PWD)定义的,这确保了绝对路径的使用。

To Build

1
2
3
4
./autogen.sh
./configure
make
make install # optional

Ubuntu & Debian 发行专用指令

依赖关系生成指令

Build requirements:

1
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3 libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev

钱包需要BerkeleyDB。

只适用于Ubuntu: 可用db4.8软件包 这里.
您可以使用以下命令添加存储库并安装:

1
2
3
4
sudo apt-get install software-properties-common
sudo add-apt-repository ppa:digibyte/digibyte
sudo apt-get update
sudo apt-get install libdb4.8-dev libdb4.8++-dev

Centos发行专用指令

github上下载源码

1
2
git clone git@github.com:bitcoin/bitcoin.git
git checkout v0.12.1rc2

autogen

1
./autogen.sh

报错如下

1
2
3
4
5
6
Makefile.am:3: Libtool library used but `LIBTOOL' is undefined
Makefile.am:3: The usual way to define `LIBTOOL' is to add `AC_PROG_LIBTOOL'
Makefile.am:3: to `configure.ac' and run `aclocal' and `autoconf' again.
Makefile.am:3: If `AC_PROG_LIBTOOL' is in `configure.ac', make sure
Makefile.am:3: its definition is in aclocal's search path.
autoreconf: automake failed with exit status: 1

原因是没有安装libtool
参考文章:

然后重复执行autogen.sh,报错

1
2
3
4
configure.ac:894: error: possibly undefined macro: PKG_CONFIG_LIBDIR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
autoreconf: /usr/bin/autoconf failed with exit status: 1

查到文章说在configure.ac文件里加一行

1
m4_pattern_allow(PKG_CONFIG_LIBDIR)

解决。

安装boost

官网上下载boost_1_64

先要修改bootstrap.sh,将其中的 PREFIX=/usr/local 修改为 PREFIX=/usr,在下面找到 LIBDIR=”EPREFIX/lib”∗∗修改为∗∗LIBDIR=”EPREFIX/lib”∗∗修改为∗∗LIBDIR=”EPREFIX/lib64”
根据不同的系统可能会有不同,需要检查 whereis boost 看头文件在哪里引用的,在最后install的时候会安装头文件到PREFIX/inlcude/boost里,所以要注意PREFIX的配置;而类库将会安装在LIBDIR里,有些系统会认/usr/lib,但有些只认/usr/lib64,需要根据情况修改。不然在bitcoin安装完成后会报找不到boost类库,无法运行的错误。

1
2
3
4
5
wget https://dl.bintray.com/boostorg/release/1.64.0/source/boost_1_64_0.tar.gz
tar zxvf boost_1_64_0.tar.gz
cd boost_1_64_0
./bootstrap.sh
./b2

confiugre

1
./configure --enable-cxx --disable-shared --with-pic --prefix=xxxx/coins/bitcoin --with-boost=/usr/local/boost_1_64_0 --with-boost-libdir=/usr/local/boost_1_64_0/stage/lib --without-gui CPPFLAGS="/usr/local/BerkeleyDB.4.8/include" LDFLAGS="/usr/local/BerkeleyDB.4.8/lib"

报错:

1
2
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)

看了下文档,提示需要libdb5.1。查查问题的时候都是关于bitcoin的,提到的都是要使用BerkeleyDb4.8NC。CentOS没有libdb,只能手动安装BerkeleyDb5.1。在doc/build-unix.md文档里有详细的说明,按说明操作安装即可。

1
2
3
4
5
6
7
8
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 -xzvf db-5.1.29.NC.tar.gz
cd db-5.1.29.NC/build_unix/
../dist/configure --enable-cxx --disable-shared --with-pic
make install
sudo ln -sf /usr/local/BerkeleyDB.4.8/lib/libdb-4.8.so /usr/lib/libdb-4.8.so
sudo ln -sf /usr/local/BerkeleyDB.4.8/lib/libdb_cxx-4.8.so /usr/lib/libdb_cxx-4.8.so

注意:虽然configure里带有–with-boost这样的选项,但实际上只在源码目录中完成编译然后在with中指定–with-boost到源码目录里的boost好像并没有什么用,sudo ./b2 install这一步是必须的。但是–with-boost-lib这句是有用的。

make && make install

1
make

如果使用的CentOS6.7,需要看一下gcc –version,如果版本比较低,如4.4这样的版本,是不支持C++11标准,会在bitcoin的make步骤报一些语法错误。

处理办法:

1
2
sudo wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
sudo yum install devtoolset-2-gcc devtoolset-2-binutils devtoolset-2-gcc-c++

这样就安装了gcc version4.8的版本。但是并不是默认开启的,需要执行

1
scl enable devtoolset-2 bash

然后在当前会话中就会开启使用gcc4.8的编译环境。

也可以在.bashrc里加入

1
2
echo "WARNING: devtoolset-2 is enabled!"
. /opt/rh/devtoolset-2/enable

来每次都开启此编译环境。

开启了gcc version4.8版本的编译环境之后就可以正常完成make和make install了。

执行bitcoin/bin下的命令

这个时候可能会有找不到类库的错误,这时参才在安装boost的时候配置的boost安装路径,如果没配可以直接复制类库过去。

然后bitcoin安装就完成了。

钱包配置启动

1
2
3
4
5
6
7
8
9
rpcuser=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 26)
rpcpassword=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 26)
rpcport=20102
port=21102
daemon=1
listen=1
server=1

addnode=xxx

启动钱包

1
bitcoind --datadir=/www/bitcoin/data/ --daemon

查看当前钱包信息

1
./bitcoin-cli --datadir=/www/bitcoin/data/ getinfo

热评文章