最近bsv被大规模的51%攻击,导致该链有多达三个版本被同时挖矿。当年,bsv攻击bch,迫使bch加入了重组保护,被bsv嘲笑。这次bsv的遭遇要糟糕的多,建议加上bch的重组保护方案。
BCH侧链smart...
最近bsv被大规模的51%攻击,导致该链有多达三个版本被同时挖矿。当年,bsv攻击bch,迫使bch加入了重组保护,被bsv嘲笑。这次bsv的遭遇要糟糕的多,建议加上bch的重组保护方案。
BCH侧链smartBCH最近已经悄然上线,看目前的情况,BCH可能会在以后更受欢迎,今天这篇文章带大家了解一下BCH开发网的部署。
其实以前也写过关于bch链开发网的文章,但这次使用的是bch链最新版本进行部署的,里面的启动参数以及rpc接口已经有所改变。这些变化一般都会在有新版本时,在github中有所体现,所以大家在升级版本的时候,一定注意这些升级的版本都有什么变化,切勿造成线上环境问题。
docker pull buildpack-deps:jessie-curl
# vim Dockerfile
FROM buildpack-deps:jessie-curl
RUN wget -O bchn.tar.gz https://github.com/bitcoin-cash-node/bitcoin-cash-node/releases/download/v23.0.0/bitcoin-cash-node-23.0.0-x86_64-linux-gnu.tar.gz \
&& tar -xzvf bchn.tar.gz \
&& cd bitcoin-cash-node-23.0.0/bin \
&& mv bitcoin-cli bitcoin-tx bitcoind /usr/local/bin \
&& cd / \
&& rm -Rfv bitcoin*
EXPOSE 18443 18444
WORKDIR /root/.bitcoin
ENTRYPOINT ["bitcoind"]
注:EXPOSE用来指定端口,使容器内的应用可以通过端口和外界交互。18443为rpc远程调用协议的端口,18444为其他节点同步端口,BCH默认本地私有链的端口为:18443、18444,所以此处端口可指定为:18443、18444。
docker build . -t bch/bitcoin-cash-node:v23.0.0
# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
bch/bitcoin-cash-node v23.0.0 5eba9aaea795 8 seconds ago 212MB
mkdir -p /opt/docker/bch-regtest/data
docker run -itd --restart=unless-stopped -v /etc/localtime:/etc/localtime -v /etc/timezone:/etc/timezone --name bchn-regtest -v /opt/docker/bch-regtest/data:/root/.bitcoin/regtest -p 18443:18443 -p 18444:18444 bch/bitcoin-cash-node:v23.0.0 -regtest -server=1 -rpcuser=admin -rpcpassword=123456 -txindex=1 -paytxfee=0.00005 -rpcport=18443 -rpcallowip=0.0.0.0/0 -port=18444 -rpcbind=0.0.0.0:18443
参数解释
-regtest: 表示启动的是 regtest 网络;不同网络之间的区别在于创世区块不同,如果部署测试网,参数应为:-testnet,默认为主网
-txindex=1: 表示对所有的交易进行索引;否则默认只对与钱包地址有关的交易索引(使 getrawtransaction rpc 可调用完整的事务索引)
-server=1:表示接受命令行和JSON-RPC命令
-paytxfee=0.0005:手续费率指定,此参数表示:0.00005 BCHA/kB
-rpcuser=admin:JSON-RPC连接的用户名
-rpcpassword=123456:JSON-RPC连接的密码
-rpcport=18443:JSON-RPC连接的端口(默认default(main): 8332, testnet:18332, regtest: 18443)
-rpcallowip=0.0.0.0/0:允许来自指定源的JSON-RPC连接,可指定单个IP或一个网段,此选项可以指定多次
-rpcbind=0.0.0.0:18443:绑定到给定的地址来监听JSON-RPC连接
-port=18444:p2p监听连接的端口,用于区块链节点间的通信(default(main): 8333, testnet: 18333, regtest: 18444)
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
606daa0991e3 bch/bitcoin-cash-node:v23.0.0 "bitcoind -regtest -…" 19 minutes ago Up 19 minutes 0.0.0.0:18443-18444->18443-18444/tcp bchn-regtest
2021-08-10T08:15:19Z Bitcoin Cash Node version v23.0.0-8d6a597bb (release build)
2021-08-10T08:15:19Z InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2021-08-10T08:15:19Z Checkpoints will be verified.
2021-08-10T08:15:19Z New block headers below finalized block (maxreorgdepth=10) will be rejected.
2021-08-10T08:15:19Z Nodes sending headers below finalized block will be penalized with DoS score 100.
2021-08-10T08:15:19Z Validating signatures for all blocks.
2021-08-10T08:15:19Z Setting nMinimumChainWork=0000000000000000000000000000000000000000000000000000000000000000
......
2020-12-28T03:37:37Z Opening LevelDB in /root/.bitcoin/regtest/indexes/txindex
2020-12-28T03:37:37Z Opened LevelDB successfully
2020-12-28T03:37:37Z Using obfuscation key for /root/.bitcoin/regtest/indexes/txindex: 0000000000000000
2020-12-28T03:37:37Z init message: Loading wallet...
2020-12-28T03:37:37Z BerkeleyEnvironment::Open: LogDir=/root/.bitcoin/regtest/database ErrorFile=/root/.bitcoin/regtest/db.log
......
2021-08-10T08:15:20Z UpdateTip: new best=0f9188f13cb7b2c71f2a335e3a4fc328bf5beb436012afca590b1a11466e2206 height=0 version=0x00000001 log2_work=1 tx=1 date='2011-02-02T23:16:42Z' progress=1.000000 cache=0.0MiB(0txo)
......
2021-08-10T08:15:20Z opencon thread start
2021-08-10T08:15:20Z dnsseed thread exit
2021-08-10T08:15:20Z addcon thread start
2021-08-10T08:15:20Z msghand thread start
2021-08-10T08:16:21Z Adding fixed seed nodes as DNS doesn't seem to be available.
原来也写过BCH链的rpc常用接口的使用方法,可进行参考:BCH(比特现金)常用接口使用
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getnewaddress", "params": ["test2"] }' -H 'content-type: text/plain;' http://127.0.0.1:18443
{"result":"bchreg:qz9qwcwqd3jrt669dvjg32pyd5kmh2x8zyvflejunj","error":null,"id":"curltest"}
注:BCH节点106块时产生出块收益
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "generatetoaddress", "params": [6,"qz9qwcwqd3jrt669dvjg32pyd5kmh2x8zyvflejunj"] }' -H 'content-type: text/plain;' http://127.0.0.1:18443
{"result":["2cb3759799165e8f2cd9915f63207601a8641284984a35a5fd3c6841054bf051","1a90e6505e4a4de08825da047be64210fcfe67656769204ae5864381ba46f68b","3cb1993a0b2fdf6d36c0fbe3ce7b8421b34f573bf26526a723c110653a6fcd8e","132038276bc7ce91d7c2c514272ab44815e3b1f7a5749828db7b8b3cde3e2d05","1ad87f6d28e869d17c7a7d36313f5a2cab08c6f422d708b6103cfe28fca80a77","53e3a48e353d7080e31d83f218fb80fb0ed4a3b961ca3397b44b1d6bd28046eb"],"error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockcount", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18443
{"result":106,"error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listaddressgroupings", "params": [] }' -H 'content-type: text/plain;' http://127.0.0.1:18443
{"result":[[["bchreg:qz9qwcwqd3jrt669dvjg32pyd5kmh2x8zyvflejunj",100.00000000,"test2"]]],"error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "sendtoaddress", "params": ["qr03h5ewa07jp4lpme4qmjdzc244c480mqhjkes9vq",10] }' -H 'content-type: text/plain;' http://127.0.0.1:18443
{"result":"138562ed0cf5ae2077c349b3ca24768ce0ad62dba280027acb19b13da371389b","error":null,"id":"curltest"}
# curl --user admin:123456 --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "listunspent", "params": [6, 9999999, ["qz9qwcwqd3jrt669dvjg32pyd5kmh2x8zyvflejunj"]] }' -H 'content-type: text/plain;' http://127.0.0.1:18443
{"result":[{"txid":"959a86cb7e6dbe2b3e504bec5a68d95999aa20d27a9e89d362bd2f4f6c7f76ad","vout":0,"address":"bchreg:qz9qwcwqd3jrt669dvjg32pyd5kmh2x8zyvflejunj","label":"test2","scriptPubKey":"76a9148a0761c06c6435eb456b2488a8246d2dbba8c71188ac","amount":50.00000000,"confirmations":103,"spendable":true,"solvable":true,"safe":true},{"txid":"f1afc97123f7dc3964626a1ae101ec7ee3354fd69e899932c1723df32a73a241","vout":0,"address":"bchreg:qz9qwcwqd3jrt669dvjg32pyd5kmh2x8zyvflejunj","label":"test2","scriptPubKey":"76a9148a0761c06c6435eb456b2488a8246d2dbba8c71188ac","amount":50.00000000,"confirmations":101,"spendable":true,"solvable":true,"safe":true}],"error":null,"id":"curltest"}
以上,就是今天分享的全部内容了。
希望大家通过以上方式可以解决自己的实际需求,解决自己目前所遇到的问题。
如果在部署过程中有任何疑问,可以扫描下面的二维码,添加我的个人微信,备注:地区-职业方向-昵称,欢迎来撩,加入区块链技术交流群,与更多的区块链技术大佬学习交流。
原创不易,码字不易。 觉得这篇文章对你有点用的话,麻烦你为本文点个赞,留言或转发一下,因为这将是我输出更多优质文章的动力,感谢!
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!