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

相关文章

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.

Nginx使用Keepalived部署web集群(高可用高性能负载均衡)实战案例

《Nginx使用Keepalived部署web集群(高可用高性能负载均衡)实战案例》本文介绍Nginx+Keepalived实现Web集群高可用负载均衡的部署与测试,涵盖架构设计、环境配置、健康检查、... 目录前言一、架构设计二、环境准备三、案例部署配置 前端 Keepalived配置 前端 Nginx

ubuntu如何部署Dify以及安装Docker? Dify安装部署指南

《ubuntu如何部署Dify以及安装Docker?Dify安装部署指南》Dify是一个开源的大模型应用开发平台,允许用户快速构建和部署基于大语言模型的应用,ubuntu如何部署Dify呢?详细请... Dify是个不错的开源LLM应用开发平台,提供从 Agent 构建到 AI workflow 编排、RA

ubuntu16.04如何部署dify? 在Linux上安装部署Dify的技巧

《ubuntu16.04如何部署dify?在Linux上安装部署Dify的技巧》随着云计算和容器技术的快速发展,Docker已经成为现代软件开发和部署的重要工具之一,Dify作为一款优秀的云原生应用... Dify 是一个基于 docker 的工作流管理工具,旨在简化机器学习和数据科学领域的多步骤工作流。它

Nginx部署React项目时重定向循环问题的解决方案

《Nginx部署React项目时重定向循环问题的解决方案》Nginx在处理React项目请求时出现重定向循环,通常是由于`try_files`配置错误或`root`路径配置不当导致的,本文给大家详细介... 目录问题原因1. try_files 配置错误2. root 路径错误解决方法1. 检查 try_f

Docker安装MySQL镜像的详细步骤(适合新手小白)

《Docker安装MySQL镜像的详细步骤(适合新手小白)》本文详细介绍了如何在Ubuntu环境下使用Docker安装MySQL5.7版本,包括从官网拉取镜像、配置MySQL容器、设置权限及内网部署,... 目录前言安装1.访问docker镜像仓库官网2.找到对应的版本,复制右侧的命令即可3.查看镜像4.启

debian12安装docker的实现步骤

《debian12安装docker的实现步骤》本文主要介绍了debian12安装docker的实现步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着... 目录步骤 1:更新你的系统步骤 2:安装依赖项步骤 3:添加 docker 的官方 GPG 密钥步骤

Windows Docker端口占用错误及解决方案总结

《WindowsDocker端口占用错误及解决方案总结》在Windows环境下使用Docker容器时,端口占用错误是开发和运维中常见且棘手的问题,本文将深入剖析该问题的成因,介绍如何通过查看端口分配... 目录引言Windows docker 端口占用错误及解决方案汇总端口冲突形成原因解析诊断当前端口情况解

Spring Boot项目部署命令java -jar的各种参数及作用详解

《SpringBoot项目部署命令java-jar的各种参数及作用详解》:本文主要介绍SpringBoot项目部署命令java-jar的各种参数及作用的相关资料,包括设置内存大小、垃圾回收... 目录前言一、基础命令结构二、常见的 Java 命令参数1. 设置内存大小2. 配置垃圾回收器3. 配置线程栈大小