比特币现金BCH(BCC)

今天在VMware虚拟机的Ubuntu系统上安装了Bitcoin ABC后发现直接把之前安装的Bitcoin Core覆盖掉了,幸好安装Bitcoin ABC之前将虚拟机做了快照,快速还原回去了,只好重新建个虚拟机,安装Bitcoin ABC,用于测试。

BCH是由BTC硬分叉而来,因此很多操作可以参考BTC

一、编译安装Bitcoin ABC客户端

参照 Ubuntu下编译安装比特币Bitcoin 编译安装即可

二、使用Regtest测试网络

参照 在本机使用比特币Regtest测试网络

查看软件版本

y@ubuntu:~$ bitcoind --version
Bitcoin ABC Daemon version v0.17.3.0-gf5f1555c1
Copyright (C) 2009-2018 The Bitcoin developers

Please contribute if you find Bitcoin ABC useful. Visit
<https://www.bitcoinabc.org> for further information about the software.
The source code is available from <https://github.com/Bitcoin-ABC/bitcoin-abc>.

This is experimental software.
Distributed under the MIT software license, see the accompanying file COPYING
or <https://opensource.org/licenses/MIT>

This product includes software developed by the OpenSSL Project for use in the
OpenSSL Toolkit <https://www.openssl.org> and cryptographic software written by
Eric Young and UPnP software written by Thomas Bernard.

启动 regtest 网络

y@ubuntu:~$ bitcoind -regtest -txindex -daemon -deprecatedrpc=accounts
Bitcoin server starting

注意:加上 -deprecatedrpc=accounts 参数是为了可以使用 bitcoin-cli -regtest getaccountaddress “” 指令,否则会提示该指令已经过期

查看钱包默认账户的地址

y@ubuntu:~$ bitcoin-cli -regtest  getaccountaddress ""
bchreg:qr95sdrw5yzrs55zyzqq3fkew4zkzgsqjcyhyyvt5h

挖矿

y@ubuntu:~$ bitcoin-cli -regtest generate 200
[
  "1131b8bfac217e26920b7f2ae6fdbb9174571d931dee093351f410d973a3f0e4",
  "58c5ce924ebf9bc621ded281793fbc6af781f7ac38fa47cdafc2311f8741dfc1",
  "28f038abc747d187c97294ca4fb202a3768148696e29e20e31eb134191958347",
  ....(这里省略剩余的区块hash),
  "5da8b31adb22134f16e105b73cc6a72ddb1b5d782b60c2c516b203dfcd1f2cbd",
  "7162ab0fbe162b094b05f7ad24dc476a2269c5fb6d75244b87fa40f51afab740"
]

查看挖矿奖励

y@ubuntu:~$ bitcoin-cli -regtest getbalance
5000.00000000

分配一个新地址

y@ubuntu:~$ bitcoin-cli -regtest getnewaddress
bchreg:qq792pe74mrp947lzkmd0xfmwdlwcghz9cuq2032z2

向新地址中转账,这里转100个比特币

y@ubuntu:~$ bitcoin-cli -regtest sendtoaddress  bchreg:qq792pe74mrp947lzkmd0xfmwdlwcghz9cuq2032z2  100
ed74da43c3e3a51c1ba59650d6202987c65f5a1b09976e221e1117bc274c3e2c

查看收到的比特币

y@ubuntu:~$ bitcoin-cli -regtest listreceivedbyaddress
[
]

查看钱包信息

y@ubuntu:~$ bitcoin-cli -regtest getwalletinfo
{
  "walletname": "wallet.dat",
  "walletversion": 160300,
  "balance": 4999.99991600,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 3725.00000000,
  "txcount": 703,
  "keypoololdest": 1531452076,
  "keypoolsize": 1000,
  "keypoolsize_hd_internal": 999,
  "paytxfee": 0.00000000,
  "hdmasterkeyid": "cc846e2ac8faf72eec781aacc0db01dba03d6aad"
}

生成一个区块,使得交易得到确认

y@ubuntu:~$ bitcoin-cli -regtest generate 1 
[
  "1dc4f94f6b0024ff28df8a9187f6618e3b3dd6331fd8e7ed704c80a02fb4347a"
]

再次查看收到的比特币

y@ubuntu:~$ bitcoin-cli -regtest listreceivedbyaddress
[
  {
    "address": "bchreg:qq792pe74mrp947lzkmd0xfmwdlwcghz9cuq2032z2",
    "account": "",
    "amount": 100.00000000,
    "confirmations": 1,
    "label": "",
    "txids": [
      "ed74da43c3e3a51c1ba59650d6202987c65f5a1b09976e221e1117bc274c3e2c"
    ]
  }
]

再次查看钱包信息

y@ubuntu:~$ bitcoin-cli -regtest getwalletinfo
{
  "walletname": "wallet.dat",
  "walletversion": 160300,
  "balance": 5049.99991600,
  "unconfirmed_balance": 0.00000000,
  "immature_balance": 3700.00008400,
  "txcount": 704,
  "keypoololdest": 1531452076,
  "keypoolsize": 999,
  "keypoolsize_hd_internal": 1000,
  "paytxfee": 0.00000000,
  "hdmasterkeyid": "cc846e2ac8faf72eec781aacc0db01dba03d6aad"
}

参考:
https://github.com/Bitcoin-ABC/bitcoin-abc
https://www.bitcoincash.org/
https://www.bitcoinabc.org/

关于区块链BCH的入门必备知识

BCH源码学习笔记 | 第二步:学习一些阅读源码的基础知识(c++库的学习)

猜你喜欢

转载自blog.csdn.net/yzpbright/article/details/81021649