docker-compose部署BCH节点

2023-10-14 15:30
文章标签 部署 docker compose bch 节点

本文主要是介绍docker-compose部署BCH节点,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

BCH gitlab
BCH github
1、下载BCH二进制文件

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# wget https://github.com/bitcoin-cash-node/bitcoin-cash-node/releases/download/v26.1.0/bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz
--2023-07-05 16:30:46--  https://github.com/bitcoin-cash-node/bitcoin-cash-node/releases/download/v26.1.0/bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gzConnecting to objects.githubusercontent.com (objects.githubusercontent.com)|185.199.111.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 31056067 (30M) [application/octet-stream]
Saving to: ‘bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz’bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz            100%[=========================================================================================================================================>]  29.62M  20.1MB/s    in 1.5s    2023-07-05 16:30:49 (20.1 MB/s) - ‘bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz’ saved [31056067/31056067]

2、编写Dockerfile

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# vim Dockerfile
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# cat Dockerfile 
FROM ubuntu:20.04# 安装依赖库和工具
RUN apt-get update && apt-get install -y \curl \libssl-dev \libevent-dev \software-properties-commonADD bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz .
# 解压并复制二进制文件到 /usr/local/bin 目录
RUN mv bitcoin-cash-node-26.1.0/bin/bitcoind /usr/local/bin/ && \mv bitcoin-cash-node-26.1.0/bin/bitcoin-cli /usr/local/bin/ && \rm -rf bitcoin-cash-node-26.1.0 # 配置 Bitcoin Cash 节点
COPY bitcoin.conf /root/.bitcoin/bitcoin.conf# 暴露节点端口
EXPOSE 8332 8333# 启动 Bitcoin Cash 节点
CMD ["/usr/local/bin/bitcoind"]

3、编写bitcoin配置文件
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# vim bitcoin.conf

server=1
txindex=1
listen=1
rpcbind=0.0.0.0:8332
rpcallowip=0.0.0.0/0
rpcport=8332
rpcuser=bch
rpcpassword=asfefsdfwefdsafedsdfwe
uacomment=bitcore-bch
datadir=/bitcoin/data
#timestampindex=1

4、编写docker-compose.yml文件

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# vim docker-compose.yml
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# cat docker-compose.yml 
version: '3'services:bch-node:image: bch/bitcoin-cash-node:v26.1.0volumes:- ./bitcoin.conf:/root/.bitcoin/bitcoin.conf- ./data:/bitcoin/dataports:- 8332:8332- 8333:8333

5、打镜像

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# docker build . -t bch/bitcoin-cash-node:v26.1.0
[+] Building 54.0s (10/10) FINISHED                                                                                                                                                                                                           => [internal] load .dockerignore                                                                                                                                                                                                        0.0s=> => transferring context: 2B                                                                                                                                                                                                          0.0s=> [internal] load build definition from Dockerfile                                                                                                                                                                                     0.0s=> => transferring dockerfile: 670B                                                                                                                                                                                                     0.0s=> [internal] load metadata for docker.io/library/ubuntu:20.04                                                                                                                                                                          2.5s=> [internal] load build context                                                                                                                                                                                                        0.1s=> => transferring context: 31.06MB                                                                                                                                                                                                     0.1s=> [1/5] FROM docker.io/library/ubuntu:20.04@sha256:c9820a44b950956a790c354700c1166a7ec648bc0d215fa438d3a339812f1d01                                                                                                                    2.0s=> => resolve docker.io/library/ubuntu:20.04@sha256:c9820a44b950956a790c354700c1166a7ec648bc0d215fa438d3a339812f1d01                                                                                                                    0.0s=> => sha256:01085d60b3a624c06a7132ff0749efc6e6565d9f2531d7685ff559fb5d0f669f 27.51MB / 27.51MB                                                                                                                                         1.5s=> => sha256:c9820a44b950956a790c354700c1166a7ec648bc0d215fa438d3a339812f1d01 1.13kB / 1.13kB                                                                                                                                           0.0s=> => sha256:8c38f4ea0b178a98e4f9f831b29b7966d6654414c1dc008591c6ec77de3bf2c9 424B / 424B                                                                                                                                               0.0s=> => sha256:14be0685b7682b182af5b862c9638cb1cb4ca1a70bd5aa90deed96e9cca881e7 2.30kB / 2.30kB                                                                                                                                           0.0s=> => extracting sha256:01085d60b3a624c06a7132ff0749efc6e6565d9f2531d7685ff559fb5d0f669f                                                                                                                                                0.4s=> [2/5] RUN apt-get update && apt-get install -y     curl     libssl-dev     libevent-dev     software-properties-common                                                                                                              47.6s=> [3/5] ADD bitcoin-cash-node-26.1.0-x86_64-linux-gnu.tar.gz .                                                                                                                                                                         0.5s=> [4/5] RUN mv bitcoin-cash-node-26.1.0/bin/bitcoind /usr/local/bin/ &&     mv bitcoin-cash-node-26.1.0/bin/bitcoin-cli /usr/local/bin/ &&     rm -rf bitcoin-cash-node-26.1.0                                                         0.3s => [5/5] COPY bitcoin.conf /root/.bitcoin/bitcoin.conf                                                                                                                                                                                  0.0s => exporting to image                                                                                                                                                                                                                   1.0s => => exporting layers                                                                                                                                                                                                                  1.0s => => writing image sha256:bb00a8466266b6e11326bc5b2241f1b7610f27cbbe0611c22105a966bf8f818f                                                                                                                                             0.0s => => naming to docker.io/bch/bitcoin-cash-node:v26.1.0

6、启动容器

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# mkdir bitcoin
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# chmod 777 bitcoin -R
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# mv bitcoin data
root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# docker-compose up -d
Starting bch_bch-node_1 ... done

7、查看节点同步情况

root@iZj6c076dm0c5n5b39lzlxZ:/data/docker-compose/bch# docker exec -it bch_bch-node_1 /bin/bash
root@496cbc45ff5a:/# bitcoin-cli -conf=/root/.bitcoin/bitcoin.conf  getblockchaininfo
{"chain": "main","blocks": 220892,"headers": 800413,"bestblockhash": "00000000000001faa5f06c81b98ef9d008b5853243fa8449c1b4b1f2e6c76194","difficulty": 3275464.586565617,"mediantime": 1360719428,"verificationprogress": 0.03421628954813776,"initialblockdownload": true,"chainwork": "00000000000000000000000000000000000000000000002a375ba8ca11508bcd","size_on_disk": 6433940923,"pruned": false,"warnings": ""
}

区块浏览器上对比
区块浏览器地址
在这里插入图片描述
curl测试
获取区块高度

curl --user bch:asfefsdfwefdsafedsdfwe --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "ping", "params": [] }' -H 'content-type: text/plain;' http://localhost:8332
{"result":null,"error":null,"id":"curltest"}

获取最新区块信息

curl --user bch:asfefsdfwefdsafedsdfwe --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblock", "params": [] }' -H 'content-type: text/plain;' http://localhost:8332
{"result":null,"error":{"code":-1,"message":"getblock \"blockhash\" ( verbosity )\n\nIf verbosity is 0 or false, returns a string that is serialized, hex-encoded data for block 'hash'.\nIf verbosity is 1 or true, returns an Object with information about block <hash>.\nIf verbosity is 2, returns an Object with information about block <hash> and information about each transaction, including fee.\nIf verbosity is >=3, returns an Object with information about block <hash> and information about each transaction, including fee, and including prevout information for inputs (only for unpruned blocks in the current best chain).\n\nArguments:\n1. \"blockhash\"    (string, required) The block hash\n2. verbosity      (numeric, optional, default=1) 0 for hex-encoded data, 1 for a json object, and 2 for json object with transaction data, and 3 for JSON object with transaction data including prevout information for inputs\n\nResult (for verbosity = 0):\n\"data\"                   (string) A string that is serialized, hex-encoded data for block 'hash'.\n\nResult (for verbosity = 1):\n{\n  \"hash\" : \"hash\",       (string) The block hash (same as provided)\n  \"confirmations\" : n,   (numeric) The number of confirmations, or -1 if the block is not on the main chain\n  \"size\" : n,            (numeric) The block size\n  \"height\" : n,          (numeric) The block height or index\n  \"version\" : n,         (numeric) The block version\n  \"versionHex\" : \"00000000\", (string) The block version formatted in hexadecimal\n  \"merkleroot\" : \"xxxx\", (string) The merkle root\n  \"tx\" : [               (array of string) The transaction ids\n     \"transactionid\"     (string) The transaction id\n     ,...\n  ],\n  \"time\" : ttt,          (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)\n  \"mediantime\" : ttt,    (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)\n  \"nonce\" : n,           (numeric) The nonce\n  \"bits\" : \"1d00ffff\",   (string) The bits\n  \"difficulty\" : x.xxx,  (numeric) The difficulty\n  \"chainwork\" : \"xxxx\",  (string) Expected number of hashes required to produce the chain up to this block (in hex)\n  \"nTx\" : n,             (numeric) The number of transactions in the block.\n  \"previousblockhash\" : \"hash\",  (string) The hash of the previous block\n  \"nextblockhash\" : \"hash\"       (string) The hash of the next block\n}\n\nResult (for verbosity = 2):\n{\n  ...,                   Same output as verbosity = 1\n  \"tx\" : [               (json array)\n    {                    (json object)\n      ...,               The transactions in the format of the getrawtransaction RPC; different from verbosity = 1 \"tx\" result\n      \"fee\" : n          (numeric) The transaction fee in BCH, omitted if block undo data is not available\n    },\n    ...\n  ],\n  ...                    Same output as verbosity = 1\n}\n\nResult (for verbosity >= 3):\n{\n  ...,                   Same output as verbosity = 2\n  \"tx\" : [               (json array)\n    {                    (json object)\n      ...,               Same output as verbosity = 2\n      \"vin\" : [          (json array)\n        {                (json object)\n          ...,           Same output as verbosity = 2\n          \"prevout\" : {                 (json object, optional) (Only if undo information is available)\n            \"generated\" : true|false,   (boolean) Coinbase or not\n            \"height\" : n,               (numeric) The height of the prevout\n            \"value\" : n,                (numeric) The value in BCH\n            \"scriptPubKey\" : {          (json object)\n              \"asm\" : \"str\",            (string) The asm\n              \"hex\" : \"str\",            (string) The hex\n              \"type\" : \"str\",           (string) The type (one of: nonstandard, pubkey, pubkeyhash, scripthash, multisig, nulldata)\n              \"address\" : \"str\"         (string, optional) The Bitcoin Cash address (only if well-defined address exists)\n            },\n            \"tokenData\" : {             (json object, optional) CashToken data (only if the input contained a token)\n              \"category\" : \"hex\",       (string) Token id\n              \"amount\" : \"xxx\",         (string) Fungible amount (is a string to support >53-bit amounts)\n              \"nft\" : {                 (json object, optional) NFT data (only if the token has an NFT)\n                \"capability\" : \"xxx\",   (string) One of \"none\", \"mutable\", \"minting\"\n                \"commitment\" : \"hex\"    (string) NFT commitment formatted as hexadecimal\n              },\n            }\n          }\n        },\n        ...\n      ]\n    },\n    ...\n  ],\n  ...                    Same output as verbosity = 2\n}\n\nExamples:\n> bitcoin-cli getblock \"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"\n> curl --user myusername --data-binary '{\"jsonrpc\": \"1.0\", \"id\":\"curltest\", \"method\": \"getblock\", \"params\": [\"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09\"] }' -H 'content-type: text/plain;' http://127.0.0.1:8332/\n"},"id":"curltest"}

这篇关于docker-compose部署BCH节点的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/211394

相关文章

MySQL 主从复制部署及验证(示例详解)

《MySQL主从复制部署及验证(示例详解)》本文介绍MySQL主从复制部署步骤及学校管理数据库创建脚本,包含表结构设计、示例数据插入和查询语句,用于验证主从同步功能,感兴趣的朋友一起看看吧... 目录mysql 主从复制部署指南部署步骤1.环境准备2. 主服务器配置3. 创建复制用户4. 获取主服务器状态5

SpringBoot结合Docker进行容器化处理指南

《SpringBoot结合Docker进行容器化处理指南》在当今快速发展的软件工程领域,SpringBoot和Docker已经成为现代Java开发者的必备工具,本文将深入讲解如何将一个SpringBo... 目录前言一、为什么选择 Spring Bootjavascript + docker1. 快速部署与

golang程序打包成脚本部署到Linux系统方式

《golang程序打包成脚本部署到Linux系统方式》Golang程序通过本地编译(设置GOOS为linux生成无后缀二进制文件),上传至Linux服务器后赋权执行,使用nohup命令实现后台运行,完... 目录本地编译golang程序上传Golang二进制文件到linux服务器总结本地编译Golang程序

如何在Ubuntu 24.04上部署Zabbix 7.0对服务器进行监控

《如何在Ubuntu24.04上部署Zabbix7.0对服务器进行监控》在Ubuntu24.04上部署Zabbix7.0监控阿里云ECS服务器,需配置MariaDB数据库、开放10050/1005... 目录软硬件信息部署步骤步骤 1:安装并配置mariadb步骤 2:安装Zabbix 7.0 Server

使用Docker构建Python Flask程序的详细教程

《使用Docker构建PythonFlask程序的详细教程》在当今的软件开发领域,容器化技术正变得越来越流行,而Docker无疑是其中的佼佼者,本文我们就来聊聊如何使用Docker构建一个简单的Py... 目录引言一、准备工作二、创建 Flask 应用程序三、创建 dockerfile四、构建 Docker

SpringBoot+Docker+Graylog 如何让错误自动报警

《SpringBoot+Docker+Graylog如何让错误自动报警》SpringBoot默认使用SLF4J与Logback,支持多日志级别和配置方式,可输出到控制台、文件及远程服务器,集成ELK... 目录01 Spring Boot 默认日志框架解析02 Spring Boot 日志级别详解03 Sp

java实现docker镜像上传到harbor仓库的方式

《java实现docker镜像上传到harbor仓库的方式》:本文主要介绍java实现docker镜像上传到harbor仓库的方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地... 目录1. 前 言2. 编写工具类2.1 引入依赖包2.2 使用当前服务器的docker环境推送镜像2.2

C++链表的虚拟头节点实现细节及注意事项

《C++链表的虚拟头节点实现细节及注意事项》虚拟头节点是链表操作中极为实用的设计技巧,它通过在链表真实头部前添加一个特殊节点,有效简化边界条件处理,:本文主要介绍C++链表的虚拟头节点实现细节及注... 目录C++链表虚拟头节点(Dummy Head)一、虚拟头节点的本质与核心作用1. 定义2. 核心价值二

Kotlin Compose Button 实现长按监听并实现动画效果(完整代码)

《KotlinComposeButton实现长按监听并实现动画效果(完整代码)》想要实现长按按钮开始录音,松开发送的功能,因此为了实现这些功能就需要自己写一个Button来解决问题,下面小编给大... 目录Button 实现原理1. Surface 的作用(关键)2. InteractionSource3.

Web技术与Nginx网站环境部署教程

《Web技术与Nginx网站环境部署教程》:本文主要介绍Web技术与Nginx网站环境部署教程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、Web基础1.域名系统DNS2.Hosts文件3.DNS4.域名注册二.网页与html1.网页概述2.HTML概述3.