Programming bitcoin with Python
In this section, we are going to introduce the following topics:
- The Raspberry Pi Bitcoin tools library and how to start using it
- How to generate private keys and public keys
- How to create a simple bitcoin address from the private keys and public keys you generated
Note
To get started with bitcoin using Python, you must install Python 3.x and the bitcoin Python library called Pi Bitcoin tools in the system.
Pi Bitcoin tools library
To install the Pi Bitcoin tools library, open the command-line program and execute the following command:
pip install bitcoin
Note
The best thing about this library is that it does not need to have a bitcoin node on your computer in order for you to start using it.
This library connects to the bitcoin network and pulls data from places such as Blockchain.info.
We shall start by writing the equivalent of a Hello World
program for bitcoin in Python. In the hello_bitcoin.py
script, the demonstration of a new bitcoin address is created using Python...