Browsed by
Category: Python implementation

Baby steps. Folders structure

Baby steps. Folders structure

Our first major decision was how to structure our project. After some considerations we’ve decided to use the following structure.


Bitpy file structure
Manager /
Network /
Packets /
	control_messages /
	data_messages /
Utils /

The Manager folder will contain the UI of the project and the codes that will deal with both incoming and outgoing packets.

The Network folder will contain all the files that are required to establish and maintain connection with the network.

The Packets This is where we’re actually starting to see the effects of the Bitcoin protocol on our design. Bitcoin protocol uses send and receive packets of data. There are 2 types of data packets:

control messages

This is just a short introduction, we’ll look into each and every message in the future

control messages are used to send meta type information such as: What’s your version number?(Version) What’s your address?(getAddr) Ping and Pong, etc’. This information is used by the Bitcoin protocol, but doesn’t contains any real information on blocks, transactions, signatures etc. Basically, nothing that will effect the Bitcoin blockchain. No transaction will be recorded, no messages will be signed, no block will be added etc’

data_messages are used to interact with the Bitcoin blockchain. Either we only ask for some information from the blockchain such as: send me specific blocks or block information(GetBlocks, GetData, Inv), show me the Mempool(Mempool) etc’ or we’re trying interact with the Bitcoin blockchain by sending transactions(Tx) or blocks(Block).

It is important to note that the Bitcoin protocol requires that every message will be constructed in the same way (mostly it means it will have a specific header and will contain only specific data types. Again, we’ll look into it with more details soon). That is why we’ve also included HeaderParser and PacketCreator in this Packets folder.

The Utils folder will contain an assortment of tools that might be required in our project.

Alexis and Shlomi’s excellent adventure

Alexis and Shlomi’s excellent adventure

I was approached by Alexis Gallèpe, a computer scientist from France who suggested that both of us should team up and work on our own implementation of a Bitcoin blockchain explorer.

We wanted to be able to ask for specific blocks and transactions from the Bitcoin network, without downloading the full Bitcoin blockchain. this is somewhat similar to the working of the light (SPV) clients, but without most of the wallet functionalities such as create and store keys, sign transactions etc’, although we might implement them latter on (You’re more then welcome to watch my videos on creating keys and sign transactions, the code can be found here).

Both Alexis and I have agreed that our code should be used for educational purposes. We want the code to be as readable and self explanatory as possible, even at the cost of efficiency. We’ve also agreed that Pyhton implementation (Python 2.7  we’ve switch to Python 3.5 – see related post) might be best suited for such a task and that we should document our project as often as possible (hence this blog).

You can find our source code at Github and follow our work on Trello.