From BitcoinWiki
This is the approved revision of this page, as well as being the most recent.
Jump to: navigation, search
Bitcoind interface, commands, RPC

Bitcoind – a daemon program that implements the Bitcoin protocol, is controlled through the command line. It is one of the main components of the Bitcoin network node software. Bitcoin software exists in two forms: a GUI application and a background application (daemon on Unix, service on Windows). Programs can be remotely controlled using the JSON-RPC protocol (RFC 4627), the corresponding classes for PHP5 are developed. This allows to connect several miners to one node, create user’s own pool; link the site to the website.

What Is Bitcoind[edit]

Bitcoind is a “reference client” created by the core team of Bitcoin developers. This is a full-fledged bitcoin node that downloads the entire transaction history (blockchain) and processes transactions. Bitcoind is somewhat limited in functionality, for example, it cannot give you transaction history at an address that you did not import in advance. However, it provides a fairly powerful interface for the programmer.

Bitcoin software has both a graphical interface called bitcoin-qt and a console interface, bitcoind. If the first is convenient for human use, then without a text it is quite difficult to make an online store or any other service that accepts bitcoins as a payment. About it and speech will go.

To work you need to run one instance of bitcoin as a daemon, so he worked as a full-fledged host on the network and give commands to it using another copy of bitcoind. The interaction between them happens via JSON-RPC over TCP port 8332. In order for them to recognize and trust each other, you need to set rpcpassword, which is written in the file ~/.bitcoin / bitcoin.conf as rpcpassword=blah-blah-blah. If you do not have such a file you need to create it. There you can register and other settings from those given when starting the daemon.

How it Works[edit]

Accordingly, the only thing you need to accept bitcoins is a bitcoin client on the server. It is called bitcoind, it’s just a console version of the client, with all the same familiar functionality.

It works through the JSON-RPC protocol, is located under port 8332. All that remains after installation is to set up the client and Node.js.

Install Bitcoind[edit]

To install, you will need to run the following commands: add the Bitcoin repository,

  1. install updates,
  2. install the client
  3. create a directory in the home directory
sudo aptitude install python-software-properties</code>
sudo add-apt-repository ppa:bitcoin/bitcoin
sudo aptitude update
sudo aptitude install bitcoind
mkdir ~/.bitcoin/

Next, you need to configure the client, create daemon in order to run bitcoind in the background. The client configuration file must be placed in the home category, ~ / .bitcoind, the file is called bitcoin.conf.

nano ~/.bitcoin/bitcoin.conf



Set the logs and password in place of USERNAME and PASSWORD. Now daemon is created to run in the background:

sudo nano /etc/init/bitcoind.conf

Enter: description «bitcoind»

start on filesystem

stop on runlevel [!2345]

oom never

expect daemon


respawn limit 10 60 # 10 times in 60 seconds






Don't change anything below here:

[[ -e $pidfile &&! -d "/proc/$(cat $pidfile)" ]] && rm $pidfile

[[ -e $pidfile && "$(cat /proc/$(cat $pidfile)/cmdline)" != $cmd* ]] && rm $pidfile

exec start-stop-daemon --start -c $user --chdir $home --pidfile $pidfile --startas $cmd -b -m

end script

USER needs to be replaced with the username under which bitcoind will be launched, and the DIR location also needs to be replaced with the following path - /usr/bin/bitcoind. Reboot daemon configuration:

sudo initctl reload-configuration

Launch: sudo start bitcoind

Commands to start Bitcoind[edit]

After downloading Bitcoind and installing / assembling it, the first step is to create a configuration file in the Bitcoin folder (~ / .bitcoin for Linux) with the following contents:


It is worth replacing user / pass with your own username and password. Once you do this, change to the directory containing the executable file (/ bin if you installed the finished assembly) and run the daemon:

> ./bitcoind --daemon

There are now two ways to interact with the bitcoind daemon to force it to execute user commands. The first way is simpler: at the command line, enter “bitcoind” with the command name and arguments. For example:

> ./bitcoind getblockhash 1
> ./bitcoind getblock 00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048
  {  "hash" : "00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048",     
     "confirmations" : 212362,     
     "size" : 215,     
     "height" : 1,     
     "version" : 1,
     "merkleroot" : "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098",
     "tx" : [  "0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098"  ],     
     "time" : 1231469665,     
     "nonce" : 2573394689,
     "bits" : "1d00ffff",
     "difficulty" : 1.00000000,
     "previousblockhash" : "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
     "nextblockhash" : "000000006a625f06636b8bb6ac7b960a8d03705d1ace08b1a19da3fdcc99ddbd" 

> ./bitcoind getrawtransaction 0e3e2357e806b6cdb1f70b54c3a3a17b6714ee1f0e68bebb44a74b1efd512098


The second method uses JSON-RPC. This is a common interface that allows you to connect to bitcoind and execute commands from any language - and possibly even from another computer. The Bitcoin Wiki has a page with a detailed description of some ways to make a JSON-RPC call in various programming languages. For brevity, only two are listed.

In Python:

import httplib, json, base64 def mkrequest(url,user,pass,method,params,hasresponse=True):

     connection = httplib.HTTPConnection(url)
     postdata = json.dumps({ "method": method, "params": params }) 
     req = urllib2.Request('http://localhost:8001',postdata, {   
              'Authorization': b'Basic '+base64.b64encode(user+':'+pass),
     if hasresponse: return urllib2.urlopen(req).read().strip()

And here it can be done on the command line using curl:

curl --user <user> --pass <pass> --data-binary '{"method": <method>, "params": [<param1>,<param2>...] }' http://localhsot:8332

How to Do RPC Calls with C++ Bitcoind[edit]

bitcoin deamon = core value of the software (bitcoind -printtoconsole -debug=1)

Bitcoind provide the RPC "interface" in which user can query with bitcoin-cli (or a library in c++).

You must run bitcoind before using bitcoin-cli.

Basically bitcoin-cli communicate with user’s node bitcoind so in other word your current blockchain state.

Download Bitcoind[edit]

Download the program you can on

See Also on BitcoinWiki[edit]

External Links[edit]