THE BITCOIN CLIENT

Vi
Earth Is Home
Published in
4 min readFeb 17, 2017
Courtesy Gesellberg.com

BITCOIN CORE

The bitcoin core is an open source client and the reference implementation of the bitcoin Blockchain network.

What is a software client?

It is a software application that helps access a server in a network. The client can exist on a desktop, laptop or mobile device. The server in the case of the bitcoin Blockchain is one of the myriad of nodes and the network is the bitcoin protocol.

What is reference implementation?

It is the parent implementation from with all other clients have been derived. To put it simply, let’s take chocolate. The earliest origins of the recipe of chocolate come from Mesoamerica. Every other chocolate recipe ever made whether it is from your favourite chocolate company or a small one references their recipe from the original recipe or original implementation.

BITCOIN CORE’S JSON-RPC API

To connect to the bitcoin network we use an API. The link is to a video that explains APIs really well for any stage learner. We use a JSON-RPC API to connect to the bitcoin Blockchain and communicate with it.

What is a RPC?

An RPC is called a Remote Procedure Call. It is term used in distributed computing. Unfortunately, I couldn’t find a good video that explained RPC. So here is my take, RPC is when a software program (the bitcoin core client in this case), executes a procedure (sometimes called a subroutine) in another computer (a bitcoin Blockchain node) on a shared network (the bitcoin Blockchain). For example, if I want to send bitcoins to a friend — when I send those bitcoins, the ‘send’ procedure is called on my software client, executed on a node in the bitcoin Blockchain somewhere.

What is JSON?

JSON is called JavaScript Object Notation. It is an open standard format for sharing human-readable data. Here is a video that explains it perfectly. It can be used by any programming language.

So what does the JSON-RPC API do?

Well if you understood all the terms and info above then you should know by now that it helps us communicate with the bitcoin Blockchain network. While communicating it uses a human-readable JSON format to access, read, write data on the network.

Below is an example of getting Information on the Bitcoin Core Client Status using the JSON-RPC API. Here we used the command ‘getinfo’ to get the status of the

Bitcoin network node, the wallet, and the Blockchain database. The following code snippet is taken from the book — Mastering Bitcoin by Andreas M. Antonopoulos.

$ bitcoin-cli getinfo
{
“version” : 90000,
“protocolversion” : 70002,
“walletversion” : 60000,
“balance” : 0.00000000,
“blocks” : 286216,
“timeoffset” : -72,
“connections” : 4,
“proxy” : “”,
“difficulty” : 2621404453.06461525,
“testnet” : false,
“keypoololdest” : 1374553827,
“keypoolsize” : 101,
“paytxfee” : 0.00000000,
“errors” : “”
}

The JSON formatted data is highlights:

  • “version” : 90000: version number of the bitcoin software client
  • “protocolversion” : 70002: version number of the bitcoin protocol
  • “walletversion” : 60000: version number of the bitcoin wallet
  • “balance” : 0.00000000: the current balance in the wallet
  • “blocks” : 286216: the current block height which shows the number of blocks the client knows about.
  • “timeoffset” : -72: the difference in time (in seconds) between your node’s “wall clock time” and the median reported time by network peers
  • “connections” : 4: the number of peers on the bitcoin P2P network that your node is connected.
  • “proxy” : “”: if a proxy is used to connect to the network, otherwise it is blank.
  • “difficulty” : 2621404453.06461525: this is the current mining difficulty. This difficulty factor increases with more miners entering the bitcoin network
  • “testnet” : false: whether the client is connected to the bitcoin test network (testnet) or not — this case not — represented as a Boolean value (0 or 1)
  • “keypoololdest” : 1374553827: this is the timestamp (UNIX epoch) of the oldest key in the key pool
  • “keypoolsize” : 101: this is the size of the client’s reserve addresses. The bitcoin client keeps a number of addresses in reserve.
  • “paytxfee” : 0.00000000: this represents the transaction fee taken by the bitcoin network
  • “errors” : “”: this field informs the different status conditions as part of the RPC. A full list can be found here — http://preview.tinyurl.com/hgs48gu (or) https://tinyurl.com/hgs48gu

Alternative Client: pycoin

This is a good library if you’re looking to dip your toes into Blockchain and more specifically Bitcoin and other alt-coins. It’s in an easy programming language (python) that is suitable for both beginners and experts alike. Originally written and maintained by Richard Kiss it supports both python 2 and 3.

GitHub: https://github.com/richardkiss/pycoin

Home: https://github.com/pycoin

--

--

Vi
Earth Is Home

Founder of Metasolis and a fifth-culture-kid. I enjoy music, reading, outdoors, making cool stuff, scify shows, shorts and movies.