博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
比特币源码研读(二)之搭环境遇到的那些坑
阅读量:4163 次
发布时间:2019-05-26

本文共 2677 字,大约阅读时间需要 8 分钟。

首先说一下度《精通比特币》是一直不理解的一个地方:

上面两处被圈起来的地方都提到了一个数字2256,特别是第一句话更是让人费解,如果私钥只能在1到2256间产生那岂不是太容易重复了。关于这点,我认为是在翻译或者排版是出现了错误,2256应该是想表达2的256次方的意思。后续翻看其它资料是也证实了我的想法。

现在说说搭环境遇到的问题.

一、源的问题

        我是在docker下进行的源码安装,使用官方的Ubuntu16.04镜像,许多标准系统里的工具镜像中是没有的。对于源我还是比较习惯使用阿里云,这里把设置贴出来:

1、备份sources.list

cp /etc/apt/sources.list /etc/apt/sources.list_backup

2、更改源,vim /etc/apt/sources.list,内容如下:

deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial universedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates universedeb http://mirrors.aliyun.com/ubuntu/ xenial multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiversedeb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiversedeb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-propertiesdeb http://archive.canonical.com/ubuntu xenial partnerdeb-src http://archive.canonical.com/ubuntu xenial partnerdeb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricteddeb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-propertiesdeb http://mirrors.aliyun.com/ubuntu/ xenial-security universedeb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

3、记得更新源,不更新数据源是不能用的

apt-get update

 

二、安装add-apt-repository     

编译源码需依赖于libdb4.8-dev,文档要求使用“add-apt-repository ppa:bitcoin/bitcoin”来添加repository,之后在能够安装libdb4.8-dev,系统中没有add-apt-repository,安装方法如下:

apt-get install python-software-propertiesapt-get install software-properties-common

三、安装hexdump

这个工具应该是系统自带的,但不知到为什么我用的官方镜像中没有,安装方法如下:

apt-get install bsdmainutils

四、安装pkg-config

apt-get install pkg-config

五、编译

安装完上面这些后使用./configure --without-gui就可以生辰Makefile文件了。--without-gui是使用用户界面,因为我用的是docker 所以就把这个选项加上了。

make的时候会报错:“rpcrawtransaction.cpp:299:77:   required from here

/usr/include/boost/variant/get.hpp:178:5: error: invalid application of 'sizeof' to incomplete type 'boost::STATIC_ASSERTION_FAILURE<false>'
     BOOST_STATIC_ASSERT_MSG(
     ^
Makefile:838: recipe for target 'rpcrawtransaction.o' failed”

解决方法如下:

找报错文件rpcrawtransaction.cpp的299行:

const CScriptID& hash = boost::get<const CScriptID&>(address);

修改为:

const CScriptID& hash = boost::get<CScriptID>(address);

即可。


区块链研习社源码研读班 栎枫

 

你可能感兴趣的文章
SVN-无法查看log,提示Want to go offline,时间显示1970问题,error主要是 url中 有一层的中文进行了2次encode
查看>>
DeepLearning tutorial(7)深度学习框架Keras的使用-进阶
查看>>
第三方SDK:JPush SDK Eclipse
查看>>
第三方开源库:imageLoader的使用
查看>>
Android studio_迁移Eclipse项目到Android studio
查看>>
转载知乎-前端汇总资源
查看>>
JavaScript substr() 方法
查看>>
JavaScript slice() 方法
查看>>
JavaScript substring() 方法
查看>>
HTML 5 新的表单元素 datalist keygen output
查看>>
(转载)正确理解cookie和session机制原理
查看>>
jQuery ajax - ajax() 方法
查看>>
将有序数组转换为平衡二叉搜索树
查看>>
最长递增子序列
查看>>
从一列数中筛除尽可能少的数,使得从左往右看这些数是从小到大再从大到小...
查看>>
判断一个整数是否是回文数
查看>>
腾讯的一道面试题—不用除法求数字乘积
查看>>
素数算法
查看>>
java多线程环境单例模式实现详解
查看>>
将一个数插入到有序的数列中,插入后的数列仍然有序
查看>>