Skip to content

How to install bitcoin on ubuntu 16.4

TonyCai edited this page May 3, 2018 · 1 revision

Table of Contents

Installation

Assuming the username of the Ubuntu user is "tonycai".

Preparation
-----------


sudo apt-get update
sudo apt-get upgrade

sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libqt5gui5 libqt5core5 libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler
sudo apt-get install libqrencode-dev
sudo apt-get install libminiupnpc-dev
# Here is what I did for ubuntu 16.4:
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo apt-get update
sudo apt-get install -y libdb4.8-dev libdb4.8++-dev
sudo apt-get install libevent-dev
Download bitcoin source code ----------------------------
cd /home/tonycai/workspace
git clone https://github.com/bitcoin/bitcoin.git
Download and compile Berkley DB 4.8 -----------------------------------
cd /home/tonycai/workspace/
mkdir 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/tonycai/workspace/bitcoin/db4/
make install
Compile Bitcoin with Berkley DB 4.8 -----------------------------------
cd /home/tonycai/workspace/bitcoin/
./autogen.sh
./configure LDFLAGS="-L/home/tonycai/bitcoin/db4/lib/" CPPFLAGS="-I/home/tonycai/bitcoin/db4/include/"
make -s -j 5
Run Bitcoin Daemon/QT/Client ----------------------------
./src/bitcoind
./src/bitcoin-qt
./src/bitcoin-cli

bitcoind

tonycai@dolphin:~/workspace/bitcoin/src$ ./bitcoind 
2018-05-03T04:40:19Z Bitcoin Core version v0.16.99.0-ef006d9 (release build)
2018-05-03T04:40:19Z InitParameterInteraction: parameter interaction: -whitelistforcerelay=1 -> setting -whitelistrelay=1
2018-05-03T04:40:19Z Assuming ancestors of block 0000000000000000005214481d2d96f898e3d5416e43359c145944a909d242e0 have valid signatures.
2018-05-03T04:40:19Z Setting nMinimumChainWork=000000000000000000000000000000000000000000f91c579d57cad4bc5278cc
2018-05-03T04:40:19Z Using the 'sse4' SHA256 implementation
2018-05-03T04:40:19Z Using RdRand as an additional entropy source
2018-05-03T04:40:19Z Default data directory /home/tonycai/.bitcoin
2018-05-03T04:40:19Z Using data directory /home/tonycai/.bitcoin
2018-05-03T04:40:19Z Using config file /home/tonycai/.bitcoin/bitcoin.conf
2018-05-03T04:40:19Z Using at most 125 automatic connections (65535 file descriptors available)
2018-05-03T04:40:19Z Using 16 MiB out of 32/2 requested for signature cache, able to store 524288 elements
2018-05-03T04:40:19Z Using 16 MiB out of 32/2 requested for script execution cache, able to store 524288 elements
2018-05-03T04:40:19Z Using 4 threads for script verification
2018-05-03T04:40:19Z scheduler thread start
2018-05-03T04:40:19Z HTTP: creating work queue of depth 16
2018-05-03T04:40:19Z No rpcpassword set - using random cookie authentication
2018-05-03T04:40:19Z Generated RPC authentication cookie /home/tonycai/.bitcoin/.cookie
2018-05-03T04:40:19Z HTTP: starting 4 worker threads
2018-05-03T04:40:19Z Using wallet directory /home/tonycai/.bitcoin/wallets
2018-05-03T04:40:19Z init message: Verifying wallet(s)...
2018-05-03T04:40:19Z Using BerkeleyDB version Berkeley DB 4.8.30: (April  9, 2010)
2018-05-03T04:40:19Z Using wallet wallet.dat
2018-05-03T04:40:19Z BerkeleyEnvironment::Open: LogDir=/home/tonycai/.bitcoin/wallets/database ErrorFile=/home/tonycai/.bitcoin/wallets/db.log
2018-05-03T04:40:19Z Cache configuration:
2018-05-03T04:40:19Z * Using 2.0MiB for block index database
2018-05-03T04:40:19Z * Using 8.0MiB for chain state database
2018-05-03T04:40:19Z * Using 440.0MiB for in-memory UTXO set (plus up to 286.1MiB of unused mempool space)
2018-05-03T04:40:19Z init message: Loading block index...
2018-05-03T04:40:19Z Opening LevelDB in /home/tonycai/.bitcoin/blocks/index
2018-05-03T04:40:19Z Opened LevelDB successfully
2018-05-03T04:40:19Z Using obfuscation key for /home/tonycai/.bitcoin/blocks/index: 0000000000000000
2018-05-03T04:40:23Z LoadBlockIndexDB: last block file = 118
2018-05-03T04:40:23Z LoadBlockIndexDB: last block file info: CBlockFileInfo(blocks=348, size=90300932, heights=286855...288029, time=2014-02-20...2014-02-27)
2018-05-03T04:40:23Z Checking all blk files are present...
2018-05-03T04:40:23Z Opening LevelDB in /home/tonycai/.bitcoin/chainstate
2018-05-03T04:40:23Z Opened LevelDB successfully
2018-05-03T04:40:23Z Using obfuscation key for /home/tonycai/.bitcoin/chainstate: b4f8ed197d35bb87
2018-05-03T04:40:23Z Loaded best chain: hashBestChain=000000000000000074a9eaa0c8b3d1809b8d8304da4d19a7ec3ca396e15ba757 height=287894 date=2014-02-26T11:24:21Z progress=0.103740
2018-05-03T04:40:23Z init message: Rewinding blocks...
2018-05-03T04:40:25Z init message: Verifying blocks...
2018-05-03T04:40:25Z Verifying last 6 blocks at level 3
2018-05-03T04:40:25Z [0%]...[16%]...[33%]...[50%]...[66%]...[83%]...[99%]...[DONE].
2018-05-03T04:40:26Z No coin database inconsistencies in last 7 blocks (3733 transactions)
2018-05-03T04:40:26Z  block index            6769ms
2018-05-03T04:40:26Z init message: Loading wallet...
2018-05-03T04:40:26Z nFileVersion = 160000

bitcoin-cli

Bitcoin Core RPC client version v0.16.99.0-ef006d9

Usage:
  bitcoin-cli [options] <command> [params]  Send command to Bitcoin Core
  bitcoin-cli [options] -named <command> [name=value] ... Send command to Bitcoin Core (with named arguments)
  bitcoin-cli [options] help                List commands
  bitcoin-cli [options] help <command>      Get help for a command

Options:

  -?
       This help message

  -conf=<file>
       Specify configuration file. Relative paths will be prefixed by datadir
       location. (default: bitcoin.conf)

  -datadir=<dir>
       Specify data directory

  -getinfo
       Get general information from the remote server. Note that unlike
       server-side RPC calls, the results of -getinfo is the result of
       multiple non-atomic requests. Some entries in the result may
       represent results from different states (e.g. wallet balance may
       be as of a different block from the chain state reported)

Chain selection options:

  -regtest
       Enter regression test mode, which uses a special chain in which blocks
       can be solved instantly. This is intended for regression testing
       tools and app development.

  -testnet
       Use the test chain

  -named
       Pass named instead of positional arguments (default: false)

  -rpcclienttimeout=<n>
       Timeout in seconds during HTTP requests, or 0 for no timeout. (default:
       900)

  -rpcconnect=<ip>
       Send commands to node running on <ip> (default: 127.0.0.1)

  -rpcpassword=<pw>
       Password for JSON-RPC connections

  -rpcport=<port>
       Connect to JSON-RPC on <port> (default: 8332 or testnet: 18332)

  -rpcuser=<user>
       Username for JSON-RPC connections

  -rpcwait
       Wait for RPC server to start

  -rpcwallet=<walletname>
       Send RPC for non-default wallet on RPC server (needs to exactly match
       corresponding -wallet option passed to bitcoind)

  -stdin
       Read extra arguments from standard input, one per line until EOF/Ctrl-D
       (recommended for sensitive information such as passphrases). 
       When combined with -stdinrpcpass, the first line from standard
       input is used for the RPC password.

  -stdinrpcpass
       Read RPC password from standard input as a single line.  When combined
       with -stdin, the first line from standard input is used for the
       RPC password.

bitcoin-tx

Bitcoin Core bitcoin-tx utility version v0.16.99.0-ef006d9

Usage:
  bitcoin-tx [options] <hex-tx> [commands]  Update hex-encoded bitcoin transaction
  bitcoin-tx [options] -create [commands]   Create hex-encoded bitcoin transaction

Options:

  -?
       This help message

  -create
       Create new, empty TX.

  -json
       Select JSON output

  -txid
       Output only the hex-encoded transaction id of the resultant transaction.

Chain selection options:

  -regtest
       Enter regression test mode, which uses a special chain in which blocks
       can be solved instantly. This is intended for regression testing
       tools and app development.

  -testnet
       Use the test chain

Commands:

  delin=N
       Delete input N from TX

  delout=N
       Delete output N from TX

  in=TXID:VOUT(:SEQUENCE_NUMBER)
       Add input to TX

  locktime=N
       Set TX lock time to N

  nversion=N
       Set TX version to N

  outaddr=VALUE:ADDRESS
       Add address-based output to TX

  outdata=[VALUE:]DATA
       Add data-based output to TX

  outmultisig=VALUE:REQUIRED:PUBKEYS:PUBKEY1:PUBKEY2:....[:FLAGS]
       Add Pay To n-of-m Multi-sig output to TX. n = REQUIRED, m = PUBKEYS.
       Optionally add the "W" flag to produce a
       pay-to-witness-script-hash output. Optionally add the "S" flag to
       wrap the output in a pay-to-script-hash.

  outpubkey=VALUE:PUBKEY[:FLAGS]
       Add pay-to-pubkey output to TX. Optionally add the "W" flag to produce a
       pay-to-witness-pubkey-hash output. Optionally add the "S" flag to
       wrap the output in a pay-to-script-hash.

  outscript=VALUE:SCRIPT[:FLAGS]
       Add raw script output to TX. Optionally add the "W" flag to produce a
       pay-to-witness-script-hash output. Optionally add the "S" flag to
       wrap the output in a pay-to-script-hash.

  replaceable(=N)
       Set RBF opt-in sequence number for input N (if not provided, opt-in all
       available inputs)

  sign=SIGHASH-FLAGS
       Add zero or more signatures to transaction. This command requires JSON
       registers:prevtxs=JSON object, privatekeys=JSON object. See
       signrawtransaction docs for format of sighash flags, JSON
       objects.

Register Commands:

  load=NAME:FILENAME
       Load JSON file FILENAME into register NAME

  set=NAME:JSON-STRING
       Set register NAME to given JSON-STRING

Error: too few parameters

Reference

  • https://gist.github.com/kostaz/19729e6d53adc5d1606c