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

相关文章

闲置电脑也能活出第二春?鲁大师AiNAS让你动动手指就能轻松部署

对于大多数人而言,在这个“数据爆炸”的时代或多或少都遇到过存储告急的情况,这使得“存储焦虑”不再是个别现象,而将会是随着软件的不断臃肿而越来越普遍的情况。从不少手机厂商都开始将存储上限提升至1TB可以见得,我们似乎正处在互联网信息飞速增长的阶段,对于存储的需求也将会不断扩大。对于苹果用户而言,这一问题愈发严峻,毕竟512GB和1TB版本的iPhone可不是人人都消费得起的,因此成熟的外置存储方案开

【前端学习】AntV G6-08 深入图形与图形分组、自定义节点、节点动画(下)

【课程链接】 AntV G6:深入图形与图形分组、自定义节点、节点动画(下)_哔哩哔哩_bilibili 本章十吾老师讲解了一个复杂的自定义节点中,应该怎样去计算和绘制图形,如何给一个图形制作不间断的动画,以及在鼠标事件之后产生动画。(有点难,需要好好理解) <!DOCTYPE html><html><head><meta charset="UTF-8"><title>06

如何用Docker运行Django项目

本章教程,介绍如何用Docker创建一个Django,并运行能够访问。 一、拉取镜像 这里我们使用python3.11版本的docker镜像 docker pull python:3.11 二、运行容器 这里我们将容器内部的8080端口,映射到宿主机的80端口上。 docker run -itd --name python311 -p

阿里开源语音识别SenseVoiceWindows环境部署

SenseVoice介绍 SenseVoice 专注于高精度多语言语音识别、情感辨识和音频事件检测多语言识别: 采用超过 40 万小时数据训练,支持超过 50 种语言,识别效果上优于 Whisper 模型。富文本识别:具备优秀的情感识别,能够在测试数据上达到和超过目前最佳情感识别模型的效果。支持声音事件检测能力,支持音乐、掌声、笑声、哭声、咳嗽、喷嚏等多种常见人机交互事件进行检测。高效推

day-51 合并零之间的节点

思路 直接遍历链表即可,遇到val=0跳过,val非零则加在一起,最后返回即可 解题过程 返回链表可以有头结点,方便插入,返回head.next Code /*** Definition for singly-linked list.* public class ListNode {* int val;* ListNode next;* ListNode() {}*

从状态管理到性能优化:全面解析 Android Compose

文章目录 引言一、Android Compose基本概念1.1 什么是Android Compose?1.2 Compose的优势1.3 如何在项目中使用Compose 二、Compose中的状态管理2.1 状态管理的重要性2.2 Compose中的状态和数据流2.3 使用State和MutableState处理状态2.4 通过ViewModel进行状态管理 三、Compose中的列表和滚动

【每日一题】LeetCode 2181.合并零之间的节点(链表、模拟)

【每日一题】LeetCode 2181.合并零之间的节点(链表、模拟) 题目描述 给定一个链表,链表中的每个节点代表一个整数。链表中的整数由 0 分隔开,表示不同的区间。链表的开始和结束节点的值都为 0。任务是将每两个相邻的 0 之间的所有节点合并成一个节点,新节点的值为原区间内所有节点值的和。合并后,需要移除所有的 0,并返回修改后的链表头节点。 思路分析 初始化:创建一个虚拟头节点

在 Windows 上部署 gitblit

在 Windows 上部署 gitblit 在 Windows 上部署 gitblit 缘起gitblit 是什么安装JDK部署 gitblit 下载 gitblit 并解压配置登录注册为 windows 服务 修改 installService.cmd 文件运行 installService.cmd运行 gitblitw.exe查看 services.msc 缘起

Solr部署如何启动

Solr部署如何启动 Posted on 一月 10, 2013 in:  Solr入门 | 评论关闭 我刚接触solr,我要怎么启动,这是群里的朋友问得比较多的问题, solr最新版本下载地址: http://www.apache.org/dyn/closer.cgi/lucene/solr/ 1、准备环境 建立一个solr目录,把solr压缩包example目录下的内容复制

禅道Docker安装包发布

禅道Docker安装包发布 大家好, 禅道Docker安装包发布。 一、下载地址 禅道开源版:   /dl/zentao/docker/docker_zentao.zip  备用下载地址:https://download.csdn.net/download/u013490585/16271485 数据库用户名: root,默认密码: 123456。运行时,可以设置 MYSQL_ROOT_P