设为首页 收藏本站
查看: 1356|回复: 0

[经验分享] Ubuntu Server 16.04.1 LTS 64位下编译并运行bitcoin

[复制链接]

尚未签到

发表于 2019-2-19 09:57:37 | 显示全部楼层 |阅读模式
依赖库安装


  • 安装编译环境
    apt-get -y install build-essential libtool autotools-dev \
    automake autoconf pkg-config bsdmainutils python3
  • 安装必备依赖库
    apt-get -y install libssl-dev libboost-all-dev libevent-dev
  • 安装钱包依赖库
    apt-get -y install libdb-dev libdb++-dev
  • 安装其他依赖库
    apt-get -y install libminiupnpc-dev libzmq3-dev
  • 安装GUI依赖库
    apt-get -y install libqt5gui5 libqt5core5a libqt5dbus5 \
    qttools5-dev qttools5-dev-tools libprotobuf-dev \
    protobuf-compiler libqrencode-dev
    源代码编译
  • 下载源代码
    git clone https://github.com/bitcoin/bitcoin.git
    cd bitcoin/
    git checkout -b v0.15.1 v0.15.1
  • 编译源代码
    ./autogen.sh
    ./configure --with-incompatible-bdb --prefix=/data/install/bitcoin
    #--with-incompatible-bdb为忽略libdb版本差异
    make
    make install
  • 其他编译选项
    #--disable-wallet不编译钱包
    #--without-gui不编译GUI
      编译完成后,安装目录下文件为:

    ls /data/install/bitcoin/bin/
    bench_bitcoin  bitcoin-cli  bitcoind  bitcoin-qt  bitcoin-tx  test_bitcoin  test_bitcoin-qt
      附官方文档:https://github.com/bitcoin/bitcoin/blob/master/doc/build-unix.md
     
    g++: internal compiler error: Killed (program cc1plus)解决办法:

    dd if=/dev/zero of=/swapfile bs=64M count=16
    mkswap /swapfile
    swapon /swapfile
  • bitcoin-cli、bitcoind、bitcoin-qt区别
    bitcoin-qt,带GUI的完整节点。
    bitcoind,无GUI的完整节点。
    bitcoin-cli,使用bitcoin-cli访问JSON-RPC接口。
    启动bitcoind并加入比特币测试网络
  • 启动bitcoind
    cd /data/install/bitcoin/bin/
    ./bitcoind --daemon -testnet
    Bitcoin server starting
  • 钱包及数据目录
    cd ~/.bitcoin/testnet3/
    ls -l
    banlist.dat  bitcoind.pid  blocks  chainstate  database  db.log  debug.log  peers.dat  wallet.dat
  • 停止bitcoind
    ./bitcoin-cli -testnet stop
    Bitcoin server stopping
    bitcoin-cli访问JSON-RPC接口
  • 获取节点统计信息
    ./bitcoin-cli -testnet 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": 531765,
    "timeoffset": 0,
    "connections": 0,
    "proxy": "",
    "difficulty": 858629.5213440134,
    "testnet": true,
    "keypoololdest": 1516255482,
    "keypoolsize": 2000,
    "paytxfee": 0.00000000,
    "relayfee": 0.00001000,
    "errors": ""
    }
  • 获取区块链信息
    ./bitcoin-cli -testnet getblockchaininfo
    {
    "chain": "test",
    "blocks": 721658,
    "headers": 1259495,
    "bestblockhash": "00000000000005c7be6d6a242e281756ea155ab248df12877c579439b3e9fcbe",
    "difficulty": 262144,
    "mediantime": 1456540510,
    "verificationprogress": 0.5614052534742976,
    "chainwork": "000000000000000000000000000000000000000000000007b2d3c70327f81d35",
    "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": "defined",
    "startTime": 1456790400,
    "timeout": 1493596800,
    "since": 0
    },
    "segwit": {
    "status": "defined",
    "startTime": 1462060800,
    "timeout": 1493596800,
    "since": 0
    }
    }
    }
  • 获取挖矿信息
    ./bitcoin-cli -testnet getmininginfo
    {
    "blocks": 721883,
    "currentblockweight": 0,
    "currentblocktx": 0,
    "difficulty": 1,
    "errors": "",
    "networkhashps": 6860463578666.306,
    "pooledtx": 0,
    "chain": "test"
    }
  • 获取钱包信息
    ./bitcoin-cli -testnet getwalletinfo
    {
    "walletname": "wallet.dat",
    "walletversion": 139900,
    "balance": 0.00000000,
    "unconfirmed_balance": 0.00000000,
    "immature_balance": 0.00000000,
    "txcount": 0,
    "keypoololdest": 1516255482,
    "keypoolsize": 1000,
    "keypoolsize_hd_internal": 1000,
    "paytxfee": 0.00000000,
    "hdmasterkeyid": "1f264d1522573ed5b189940b4b80e60c1d8572e2"
    }
  • 获取区块信息
    ./bitcoin-cli -testnet getblock 000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943
    {
    "hash": "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943",
    "confirmations": 723926,
    "strippedsize": 285,
    "size": 285,
    "weight": 1140,
    "height": 0,
    "version": 1,
    "versionHex": "00000001",
    "merkleroot": "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b",
    "tx": [
    "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"
    ],
    "time": 1296688602,
    "mediantime": 1296688602,
    "nonce": 414098458,
    "bits": "1d00ffff",
    "difficulty": 1,
    "chainwork": "0000000000000000000000000000000000000000000000000000000100010001",
    "nextblockhash": "00000000b873e79784647a6c82962c70d228557d24a747ea4d1b8bbe878e1206"
    }
      更多JSON-RPC接口使用方法见官方文档:https://bitcoin.org/en/developer-reference#bitcoin-core-apis





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-674238-1-1.html 上篇帖子: 普通PC用两块硬盘做raid1 并安装ubuntu server 16.04 下篇帖子: Ubuntu14.04搭建LNMP平台
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表