第二课_电子加密货币与区块链(一)作业

1、下载Bitcoin Core的源码并编译
2、练习使用命令行工具调用JSON-RPC API,查看0号区块信息
3、列举出至少一个Bitcoin的缺点
 
作业以文字描述或图片方式提交。
下次上课前,提交完即可。
老师会在下次直播课讲解作业题。

李丰翔W

赞同来自: 小象老师

1、下载Bitcoin Core的源码并编译 bitcoin lifengxiang$ make Making all in src Making all in doc/man make[1]: Nothing to be done for `all'. make[1]: Nothing to be done for `all-am'. 2、练习使用命令行工具调用JSON-RPC API,查看0号区块信息   LIs-MacBook-Pro:bitcoin lifengxiang$ ./src/bitcoin-cli getblockhash 0 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f LIs-MacBook-Pro:bitcoin lifengxiang$ ./src/bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f {   "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",   "confirmations": 187783,   "strippedsize": 285,   "size": 285,   "weight": 1140,   "height": 0,   "version": 1,   "versionHex": "00000001",   "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",   "tx": [     "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"   ],   "time": 1231006505,   "mediantime": 1231006505,   "nonce": 2083236893,   "bits": "1d00ffff",   "difficulty": 1,   "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",   "nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048" }   3。比特币区块太小,交易确认速度太慢:解决方案(扩容,lighting网络)

陈祥tlk

赞同来自: 小象老师

下载编译并启动 Making all in doc/man make[1]: Nothing to be done for `all'. make[1]: Nothing to be done for `all-am'. chenxiangdeMacBook-Pro:bitcoin chenxiang$ ./src/bitcoind 查看第0区块,以及详细信息chenxiangdeMacBook-Pro:bitcoin chenxiang$ ./src/bitcoin-cli getblockhash 0 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f chenxiangdeMacBook-Pro:bitcoin chenxiang$ ./src/bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f {   "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",   "confirmations": 1,   "strippedsize": 285,   "size": 285,   "weight": 1140,   "height": 0,   "version": 1,   "versionHex": "00000001",   "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",   "tx": [     "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"   ],   "time": 1231006505,   "mediantime": 1231006505,   "nonce": 2083236893,   "bits": "1d00ffff",   "difficulty": 1,   "chainwork": "0000000000000000000000000000000000000000000000000000000100010001" }

Liekkasa95

赞同来自: 小象老师

1、下载Bitcoin Core的源码并编译(我的是macOS) 参考: https://github.com/bitcoin/bitcoin/blob/master/doc/build-osx.md 《精通比特币》第三章 第一步,安装OSX命令行工具(如果安装过Xcode就不用执行此步)和Homebrew(若安装过也可省略) xcode-select --install homebrew官网:https://brew.sh/ 第二步,安装第三方依赖库。 brew install automake berkeley-db4 libtool boost miniupnpc openssl pkg-config protobuf python3 qt libevent 安装过程较长,最好翻墙。安装后一定要执行brew ls命令查看这些依赖库是否被安装。 第三步,将源码从GitHub上克隆下来: git clone https://github.com/bitcoin/bitcoin cd bitcoin 我想使用0.15版本,需要转到这个版本: git tag git check v0.15 git checkout v0.15第四步,build bitcoin-core ./autogen.sh ./configure make(这一步最好换成make check) 我当时build的时候一直在configure步骤出错,后来换了命令./configure --with-boost="/usr/local/Homebrew/Cellar/boost/1.66.0 才正确(指定了boost库位置) 第五步,bitcoind现在被编译完成,下一步是安装bitcoind(默认位置:/usr/local/bin/bitcoind)可执行文件到系统路径下: sudo make iyinstall 确认bitcoind和bitcoin-cli是否被安装好: which bitcoind which bitcoin-cli 第六步,为比特币钱包设置用户名与密码 如果是学习性质,建议不设置用户名和密码,否则每次登录均要输入用户名和密码,十分繁琐。 输入命令: echo -e "rpcuser=bitcoinrpc\nrpcpassword=$(xxd -l 16 -p /dev/urandom)" > "/Users/${USER}/Library/Application Support/Bitcoin/bitcoin.conf" chmod 600 "/Users/${USER}/Library/Application Support/Bitcoin/bitcoin.conf" 其实就是在/Users/${USER}/Library/Application Support/Bitcoin路径下增加一个conf文件,里面增加了用户bitcoinrpc与随机密码。 第七步,使用bitcoind  后台运行: bitcoind -daemon 一开始安装时,比特币客户端会自动同步区块链等数据。默认存放路径在~/Library/Application Support/Bitcoin/中,我的存放在路径/Users/syh/Library/Application Support/Bitcoin下。 跟踪bitcoind信息: tail -f $HOME/Library/Application\ Support/Bitcoin/debug.log 停止更新bitcoin的区块:使用命令bitcoin-cli stop 
    2、练习使用命令行工具调用JSON-RPC API,查看0号区块信息 获取客户端信息: p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures} bitcoin-cli getinfo {   "deprecation-warning": "WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16",   "version": 150100,   "protocolversion": 70015,   "walletversion": 139900,   "balance": 0.00000000,   "blocks": 447990,   "timeoffset": -8,   "connections": 8,   "proxy": "",   "difficulty": 336899932795.8077,   "testnet": false,   "keypoololdest": 1517670184,   "keypoolsize": 2000,   "paytxfee": 0.00000000,   "relayfee": 0.00001000,   "errors": "" }获取创世区块的哈希值 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures} bitcoin-cli getblockhash 0 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f 获取创世区块的信息 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Menlo; color: #000000; background-color: #ffffff} span.s1 {font-variant-ligatures: no-common-ligatures} bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f {   "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",   "confirmations": 448355,   "strippedsize": 285,   "size": 285,   "weight": 1140,   "height": 0,   "version": 1,   "versionHex": "00000001",   "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",   "tx": [     "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"   ],   "time": 1231006505,   "mediantime": 1231006505,   "nonce": 2083236893,   "bits": "1d00ffff",   "difficulty": 1,   "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",   "nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048" }   3、Bitcoin的缺点:比特币的缺点有不少,其中一个就是比特币不是图灵完备的,不支持智能合约的编写。另一个是交易速度慢

    congchp

    赞同来自:

    课程视频的回放,比较模糊,里面稍微小点的文字,很难看清楚。

    Purep

    赞同来自:

    比特币的交易速度慢,其余的作业是截图,能看到不?

    abingagl

    赞同来自:

    1、下载Bitcoin Core的源码并编译 Ubuntu环境使用PPA的方式安装。 步骤: 1.sudo add-apt-repository ppa:bitcoin/bitcoin 2.sudi apt-get update 3.sudo apt-get install bitcoind     2、练习使用命令行工具调用JSON-RPC API,查看0号区块信息  % bitcoin-cli getblockhash 0 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f\    % bitcoin-cli getblock 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f {   "hash": "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",   "confirmations": 137382,   "strippedsize": 285,   "size": 285,   "weight": 1140,   "height": 0,   "version": 1,   "versionHex": "00000001",   "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",   "tx": [     "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"   ],   "time": 1231006505,   "mediantime": 1231006505,   "nonce": 2083236893,   "bits": "1d00ffff",   "difficulty": 1,   "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",   "nextblockhash": "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048" }     3、列举出至少一个Bitcoin的缺点 1.挖矿困难,耗时耗力 2.不稳定,价格波动大,难以成为流通货币 3.去中心化难以监管,也是成为主要流通货币的难点吧。  

    要回复问题请先登录注册