BCH是BTC的硬分叉币,代码来源于BTC
还是新建一个虚拟机,ubuntu 很好使接着用这个,版本16
sudo apt-get update
sudo apt-get install git-core
下载源码,目前最新0.18.1
sudo git clone https://github.com/Bitcoin-ABC/bitcoin-abc
在本地保存在bitcoin-abc目录下
parallels@parallels-vm:~/bitcoin-abc$ ls
arcanist configure.ac doc README.md
autogen.sh contrib Dockerfile-doxygen share
build-aux CONTRIBUTING.md INSTALL.md src
cmake COPYING libbitcoinconsensus.pc.in test
CMakeLists.txt depends Makefile.am
查看doc下的build-unix.md文档,因为我是装在ubuntu的
需要调整虚拟机内存到1.5G以上
C++ compilers are memory-hungry. It is recommended to have at least 1.5 GB of memory available when compiling Bitcoin ABC.
安装依赖
sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils
sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev
sudo apt-get install libdb-dev libdb++-dev//BerkeleyDB 5.3
需要GUI的话
sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
安装
sudo ./autogen.sh
sudo ./configure --with-incompatible-bdb --enable-debug
执行后我的一些配置
Options used to compile and link:
with wallet = yes
with gui / qt = yes
qt version = 5
with qr = auto
with zmq = no
with test = yes
with bench = yes
with upnp = auto
use asm = yes
debug enabled = yes
werror = no
sanitizers
asan = no
tsan = no
ubsan = no
target os = linux
build os =
CC = gcc
CFLAGS = -g -O2 -g3 -O0
CPPFLAGS = -DDEBUG -DDEBUG_LOCKORDER -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS
CXX = g++ -std=c++11
CXXFLAGS = -g -O2 -g3 -O0 -Wall -Wextra -Wformat -Wvla -Wformat-security -Wno-unused-parameter
LDFLAGS =
接下来,这一步比较久
sudo make
然后
sudo make check
sudo make install
就有如下的可执行命令吧
libtool: install: /usr/bin/install -c bitcoind /usr/local/bin/bitcoind
libtool: install: /usr/bin/install -c bitcoin-seeder /usr/local/bin/bitcoin-seeder
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
libtool: install: /usr/bin/install -c qt/bitcoin-qt /usr/local/bin/bitcoin-qt
libtool: install: /usr/bin/install -c qt/test/test_bitcoin-qt /usr/local/bin/test_bitcoin-qt
按照比特币的配置,新建~/.bitcoin/bitcoin.conf
alertnotify=myemailscript.sh "Alert: %s"
maxconnections=15
prune=5000
minrelaytxfee=0.0001
maxmempool=200
maxreceivebuffer=2500
maxsendbuffer=500
rpcuser=bitcoinrpc
rpcpassword=CHANGE_THIS
testnet=1
启动
sudo bitcoind -printtoconsole
或者
sudo bitcoin-qt
比较奇怪的是,bitcoin-cli在bitcoin-qt开启期间是不能用的,得在bitcoind期间才能用,难道bitcoin-qt没注册rpc么?
今天在看区块链技术指南,里面提到bitcoin-qt需要传入参数-server或者运行bitcoind时,比特币提供一个HTTP/JSON RPC服务端,可以使用bitcoin-cli。
安装sublime3,官网步骤,第一步失败了三次,多尝试几次就好
parallels@parallels-vm:~$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
[sudo] password for parallels:
gpg: no valid OpenPGP data found.
parallels@parallels-vm:~$ wget -qO - https://download.sublimetext.com/sublimehq-pub.gpg | sudo apt-key add -
OK
parallels@parallels-vm:~$ sudo apt-get install apt-transport-https
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
apt-transport-https
1 upgraded, 0 newly installed, 0 to remove and 434 not upgraded.
Need to get 26.1 kB of archives.
After this operation, 0 B of additional disk space will be used.
Get:1 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 apt-transport-https amd64 1.2.27 [26.1 kB]
Fetched 26.1 kB in 2s (12.8 kB/s)
(Reading database ... 194698 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_1.2.27_amd64.deb ...
Unpacking apt-transport-https (1.2.27) over (1.2.24) ...
Setting up apt-transport-https (1.2.27) ...
然后按步骤
echo "deb https://download.sublimetext.com/ apt/stable/" | sudo tee /etc/apt/sources.list.d/sublime-text.list
sudo apt-get update
sudo apt-get install sublime-text
插件
总结
BCH的源码结构和BTC是基本一致的,应该会针对两者不同点来看,比如区块扩容,隔离见证部分的实现代码