人生は勉強ブログ

https://github.com/dooooooooinggggg

bitcoindをvagrant上のubuntuに導入する

ソースからビルドするのがめんどくさかったので、apt-getからbitcoindを導入する。

今回は、testnetでやる。

その時のメモ。

参考にしたサイトは、以下

bitcoin-cliを使ったBitcoinAPI入門

bitcoin-cli で使えるコマンド一覧

vagrantのsetup

% vagrant box add ubuntu1604 https://cloud-images.ubuntu.com/xenial/current/xenial-server-cloudimg-amd64-vagrant.box
% vagrant init ubuntu1604

以下の部分のコメントアウトを外し、メモリを多めに確保する。(こうしないと後で落ちる)

config.vm.provider "virtualbox" do |vb|
    # Display the VirtualBox GUI when booting the machine
    # vb.gui = true

    # Customize the amount of memory on the VM:
    vb.memory = "2048"
end
% vagrant up
% vagrant ssh

ubuntuの中に入った。

$ sudo apt update
$ sudo apt upgrade
$ sudo apt dist-upgrade
$ sudo shutdown

ここで、初期の設定が終わったので、一度抜けて再起動する。

% vagrant halt;vagrant up;vagrant ssh;
$ sudo apt-get install build-essential libtool autotools-dev automake pkg-config libssl-dev libevent-dev bsdmainutils python3

$ sudo apt-get install libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-program-options-dev libboost-test-dev libboost-thread-dev

$ sudo apt-get install libboost-all-dev

$ sudo apt-get install software-properties-common
$ sudo add-apt-repository ppa:bitcoin/bitcoin
$ sudo apt-get update
$ sudo apt-get install libdb4.8-dev libdb4.8++-dev

$ sudo apt install git

bitcoindをインストール

$ sudo apt-get install bitcoind
$ which bitcoind
# /usr/bin/bitcoind

使ってみる

まずは、configを記入する。

$ cd ~/.bitcoin
$ touch bitcoin.conf
$ vim bitcoin.conf

内容は以下。

testnet=3
server=1

rpcuser=bitcoinrpc
rpcpassword= bitcoinrpc
rpcport=18332

bitcoindをスタート

$ bitcoind -testnet3 -daemon
# Bitcoin server starting
$ bitcoin-cli getinfo

# {
#   "deprecation-warning": "WARNING: getinfo is deprecated and will be fully removed in 0.16. Projects should transition to using getblockchaininfo, getnetworkinfo, and getwalletinfo before upgrading to 0.16",
#   "version": 150100,
#   "protocolversion": 70015,
#   "walletversion": 139900,
#   "balance": 0.00000000,
#   "blocks": 721657,
#   "timeoffset": 0,
#   "connections": 4,
#   "proxy": "",
#   "difficulty": 262144,
#   "testnet": true,
#   "keypoololdest": 1512357482,
#   "keypoolsize": 2000,
#   "paytxfee": 0.00000000,
#   "relayfee": 0.00001000,
#   "errors": ""
# }

"testnet": trueになっていれば、正しくtestnetで起動ができている。

なんか警告が出ている。

が、気にしない。今回は以上。