The 'pybitcointools' library is deprecated. Vitalik mentions using the
fork from 'primal100'. This updates the code sample which is currently
broken, to use the Python package for that fork.
Runs all good now.
If line#24 use 'wif_compressed', it will produce a wrong Key (WIF-Compressed) started with 2.
So there should be 'wif', unless :
wif_compressed_private_key = bitcoin.encode_privkey(
bitcoin.decode_privkey(private_key, 'hex'), 'wif_compressed')
This is also right.
However, use the 'compressed_private_key' and 'wif_compressed' is wrong.
The code is very possible to miss a leading '0'.
E.g:
Private Key (hex) is: 57c003d31cca32f79a22e70334fff37875617e89c04d2746b5efc22067ccb8fd
Before: Compressed Public Key (hex) is: 03 8f0de2360796ae0fe17f1a2b0be30af6fb45eccc4a1c7afb5ebea21d041b6e0
After: Compressed Public Key (hex) is: 03 08f0de2360796ae0fe17f1a2b0be30af6fb45eccc4a1c7afb5ebea21d041b6e0
The bug is in the pybitcointools, but it is not updated, we can only repair it ourselves.
`from __future__ import print_function` to bring the print function from Python 3 into Python 2.6 and 2.7.
Properly deals with comma separated values in print() function.