I am reading the book "Mastering Bitcoin" from Antonopoulos and want to compile an example from that book. It does not tell which C++ library needs to be installed for #include <bitcoin/bitcoin.hpp> to work.
#include <bitcoin/bitcoin.hpp>
int main()
{
// Private secret key.
bc::ec_secret secret;
bool success = bc::decode_base16(secret,
"038109007313a5807b2eccc082c8c3fbb988a973cacf1a7df9ce725c31b14776");
assert(success);
// Get public key.
bc::ec_point public_key = bc::secret_to_public_key(secret);
std::cout << "Public key: " <> bc::encode_hex(public_key) << std::endl;
// Create Bitcoin address.
// ... further comments
// Compute hash of public key for P2PKH address.
const bc::short_hash hash = bc::bitcoin_short_hash(public_key);
bc::data_chunk unencoded_address;
// Reserve 26 bytes
// ...
unencoded_address.reseve(25);
unencoded_address.push_back(0);
bc::extend_data(unencoded_address, hash);
bc::append_checksum(unencoded_address);
assert(unencoded_address.size() == 25);
const std::string address = bc::encode_base58(unencoded_address);
std::cout << "Address: " << address << std::endl;
return 0;
}
Compiling should be done like this:
g++ -o addr addr.cp $(pkg-config --cflags --libs libbitcoin)
Running ./addr should give output:
"Public key: ..."
"Address: ..."
Since there have been a lot of changes to the code base it is unclear what to do with the include. The one of the code is not availlable any more.