Last active
June 19, 2018 22:59
-
-
Save daiki44/8a4546cba22f8b87e1df873805df312b to your computer and use it in GitHub Desktop.
【Bitcoin】UbuntuでBitcoinをビルドする ※install.sh付き ref: https://qiita.com/daiki_44/items/deaeb7d3b7df1f5929f1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ export HOME="ご自分のホームディレクトリ" | |
$ cd $HOME/work/bitcoin | |
$ mkdir -p db4 | |
$ cd db4 | |
$ wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz' | |
$ tar -xzvf db-4.8.30.NC.tar.gz | |
$ cd db-4.8.30.NC/build_unix/ | |
$ ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$HOME/work/bitcoin/db4/ | |
$ sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ export HOME="ご自分のホームディレクトリ" | |
$ cd $HOME/work/bitcoin | |
$ ./autogen.sh | |
$ ./configure --without-gui LDFLAGS="-L/$HOME/work/bitcoin/db4/lib/" CPPFLAGS="-I$HOME/work/bitcoin/db4/include/" | |
$ sudo make -s -j5 | |
$ sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ブロック数や残高、他のノードの接続数等の総合的な情報を表示する。 | |
$ bitcoin-cli -getinfo | |
{ | |
"version": 169900, | |
"protocolversion": 70015, | |
"walletversion": 159900, | |
"balance": 50.00000000, | |
"blocks": 101, | |
"timeoffset": 0, | |
"connections": 0, | |
"proxy": "", | |
"difficulty": 4.656542373906925e-10, | |
"testnet": false, | |
"keypoololdest": 1523178221, | |
"keypoolsize": 999, | |
"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 getnewaddress "アカウント名" | |
2Mz7emapNnRwt4PtFPdBUGdv7sdsvMqbatc | |
# ノードに存在するアカウントの残高を全てまとめた値を表示する。 | |
$ bitcoin-cli getbalance | |
50.00000000 | |
# 指定したトランザクションIDを持つトランザクションの中身を表示する。 | |
$ bitcoin-cli gettransaction "トランザクションID" | |
# 指定したアカウントから指定したアドレスまでコインを送金し、トランザクションIDを返す。 | |
$ bitcoin-cli sendfrom "アカウント名" "宛先ビットコインアドレス" "金額" | |
7c1b5ae96f71890734792629fc5f1bb708174ac5d04952c45b311f5ab2bef758 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir -p ~/work | |
$ cd ~/work | |
$ git clone https://github.com/bitcoin/bitcoin.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#------------------------------------- | |
echo "ホームディレクトリの場所を入力してください (ex. /home/ubuntu)" | |
read HOME_PATH | |
#------------------------------------- | |
# インストールされているパッケージを最新のものへアップデート | |
sudo apt-get update | |
sudo apt-get upgrade | |
# 依存関係のあるパッケージのインストール | |
sudo apt-get -y install build-essential libtool autotools-dev autoconf pkg-config libssl-dev | |
sudo apt-get -y install libboost-all-dev | |
sudo apt-get -y install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler | |
sudo apt-get -y install libqrencode-dev autoconf openssl libssl-dev libevent-dev | |
sudo apt-get -y install libminiupnpc-dev | |
# githubからBitcoinをclone | |
cd ${HOME_PATH} | |
mkdir -p work | |
cd work | |
git clone https://github.com/bitcoin/bitcoin.git | |
# Berkley DBをソースからインストール | |
cd ${HOME_PATH} | |
mkdir -p work/bitcoin/db4/ | |
cd work/bitcoin/db4/ | |
wget 'http://download.oracle.com/berkeley-db/db-4.8.30.NC.tar.gz' | |
tar -xzvf db-4.8.30.NC.tar.gz | |
cd db-4.8.30.NC/build_unix/ | |
../dist/configure --enable-cxx --disable-shared --with-pic --prefix="${HOME_PATH}/work/bitcoin/db4/" | |
sudo make install | |
cd ${HOME_PATH} | |
cd work/bitcoin/db4/ | |
rm -rf db-4.8.30.NC.tar.gz db-4.8.30.NC | |
# Bitcoinのビルドとインストール | |
# スペックによりますが20分弱かかります | |
cd ${HOME_PATH} | |
cd work/bitcoin/ | |
./autogen.sh | |
./configure --without-gui LDFLAGS="-L${HOME_PATH}/work/bitcoin/db4/lib/" CPPFLAGS="-I${HOME_PATH}/work/bitcoin/db4/include/" | |
sudo make -s -j5 | |
sudo make install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# デーモン起動 | |
$ bitcoind & | |
# 起動していた場合、ブロックチェーンの情報が取得できる | |
$ bitcoin-cli -getinfo | |
{ | |
"version": 169900, | |
"protocolversion": 70015, | |
"walletversion": 159900, | |
"balance": 649.99984460, | |
"blocks": 113, | |
"timeoffset": 0, | |
"connections": 0, | |
"proxy": "", | |
"difficulty": 4.656542373906925e-10, | |
"testnet": false, | |
"keypoololdest": 1523178221, | |
"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" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# bitcoinの起動に必要 | |
$ bitcoind --version | |
Bitcoin Core Daemon version v0.16.99.0-048ac83 | |
Copyright (C) 2009-2018 The Bitcoin Core developers | |
# bitcoinのRPC接続に必要 | |
$ bitcoin-cli --version | |
Bitcoin Core RPC client version v0.16.99.0-048ac83 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ mkdir ~/.bitcoin | |
$ cd ~/.bitcoin | |
$ vim bitcoin.conf | |
# testnetモードで起動する場合、この値を3で設定する | |
#testnet=3 | |
# regtestモードで起動する場合、この値を1で設定する | |
regtest=1 | |
# JSON_RPCコマンドを受け付ける場合、この値を1で設定する | |
server=1 | |
# server=1 とし、RPCコマンドを受け付ける場合、RPCコマンドで利用されるユーザー名とパスワードを設定 | |
rpcuser=user | |
rpcpassword=password | |
# 任意でRPC接続を行うポート番号も指定可能 | |
rpcport=18332 | |
# 任意でRPC接続を許可するIPアドレスを指定可能 | |
rpcallowip=127.0.0.1 | |
##### ここからは上級者向けの設定です ##### | |
# SOCKS5プロキシを経由する場合に利用 | |
#proxy=127.0.0.1:9050 | |
# ノード起動時に自動的に接続を行う先 | |
#addnode=111.111.111.111:8333 | |
# ノード起動時に自動的に接続を行い、このノード以外に繋がないようにする | |
#connect=111.111.111.111:8333 | |
# 他ノードからの接続を許容するかどうか | |
#listen=1 | |
# 自分のノードに関係のないトランザクションまでを確認できるようにするかどうかの設定 デフォルト0 | |
#txindex=1 | |
# ノードの最大接続数 デフォルト125 | |
#maxconnections=10 | |
# RPC接続のタイムアウト時間 単位は秒 | |
#rpcclienttimeout=60 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get update | |
$ sudo apt-get upgrade | |
$ sudo apt-get -y install build-essential libtool autotools-dev autoconf pkg-config libssl-dev | |
$ sudo apt-get -y install libboost-all-dev | |
$ sudo apt-get -y install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler | |
$ sudo apt-get -y install libqrencode-dev autoconf openssl libssl-dev libevent-dev | |
$ sudo apt-get -y install libminiupnpc-dev |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment