Bitcoin-core daemon and regtest install

2445 ワード

原文は個人のホームページに先発する:https://huangwenwei.com/blogs/bitcoin-core-daemon-and-regtest-install
2018-2-4号更新
この記事では、ビットコインアプリケーション開発時のローカルテストモードの設定についてまとめます.GUIページは不要です.Ubuntuにbitcoin core daemon without GUI(bitcoind)をインストールすればいいです.
グラフィックインタフェースは必要ありませんので、ここで注意してください./configureに--without-guiパラメータを追加します.コンパイルbitcoin/doc/build-unixを公式ドキュメントに従ってインストール.md ,
そしてbitcoind構成
mkdir ~/.bitcoin
wget https://github.com/bitcoin/bitcoin/raw/master/contrib/debian/examples/bitcoin.conf
chmod 600 ~/.bitcoin/bitcoin.conf


次のパラメータ構成を変更します.
regtest=1
rpcuser=rpcusername
rpcpassword=rpcpassword
# By default, only RPC connections from localhost are allowed. Specify
# as many rpcallowip= settings as you like to allow connections from
# other hosts (and you may use * as a wildcard character):
rpcallowip=192.168.100.2
walletnotify=/home/username/script/bitcoind_notify.rb %s
rpcport=18332
minconf=2


rpcallowipというオプションに注意してください.ここでrpcallowipはrpcリンクを許可するホストipを記入します.次にテストチェーンを起動します
bitcoind -conf=/home/username/bitcoind_pri/bitcoin_pri.conf -daemon -datadir=/home/username/bitcoind_pri -txindex=1 -deprecatedrpc=signrawtransaction

bitcoin-cli -regtest -getinfoを実行すると、サーバ上で実行されているプライベートチェーンノード情報が表示されます.ここではbitcoin-cli -regtest generate [num]によってブロックが生成されました.
{
"version": 169900,
"protocolversion": 70015,
"walletversion": 159900,
"balance": 0.00000000,
"blocks": 183871,
"timeoffset": -1,
"connections": 7,
"proxy": "",
"difficulty": 1583177.847444009,
"testnet": false,
"keypoololdest": 1517675490,
"keypoolsize": 1000,
"paytxfee": 0.00000000,
"relayfee": 0.00001000,
"warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}


次に、プライベートチェーンでよく使用されるbitcoin-cliコマンドの使用例を示します.
  • bitcoin-cli-regtest getnewaddress//生成アドレス
  • bitcoin-cli -regtest sendtoaddress [bitcoin address] [tx btc num]

  • 取引が放送されると、鉱夫はこの取引をブロックに追加し、財布のminconfの数に達すると取引が成功したことを示します.プライベートチェーンでは、bitcoin-cli -regtest generate 1コマンドによってブロックを生成し、現在の財布で発生している取引を確認することができる.
    以上が応用業務を開発する際のビットコインブロックネットワークテストチェーンの設置過程である.おすすめ:
  • bitcoind regtest mode
  • running a full bitcoind node in Ubuntu