An exercise in creating a legacy Bitcoin address, as described here.
Usage:
- Clone this repo
cd
into the python project directory- Make a virtual environment:
virtualenv -p python3 venv
source
the virtual environment activation script - e.g.source venv/bin/activate
- Run
pip install -r requirements.txt
Run python/main.py.
For the purposes of the C++ implementation, I've used openssl
to provide the necessary hashing functionality.
You can get reasonable information on the openssl
functions on the Linux man pages - for example enter man SHA256_Update
.
Note that the int SHA256_Final(unsigned char *md, SHA256_CTX *c)
function places the message digest in md
, which must have space for SHA256_DIGEST_LENGTH
bytes (i.e. 32) bytes.
Bitcoin Core does not use openssl
- the hashing algorithms are built in to the project.
Compile the C++ programme from the cpp
directory. Run ./bin/main
.
Enter a public key in hexstring format when requested. The output includes the various stages of Base58Check encoding - this is just for educational purposes.
Run ./bin/p2sh
for the address output only.