1
0
mirror of https://github.com/bitcoinbook/bitcoinbook synced 2024-11-22 08:08:11 +00:00

delete uneeded code, replace with bc::hash_literal as per William Swanson (s_tec)'s comment.

This commit is contained in:
Amir Taaki 2015-01-21 22:29:43 +01:00
parent d44f6aaf92
commit e827ff5c86

View File

@ -47,21 +47,13 @@ bc::hash_digest create_merkle(bc::hash_list& merkle)
return merkle[0];
}
// Convert hex string to hash bytes.
bc::hash_digest get_hash(const std::string& value)
{
bc::hash_digest result;
bool success = bc::decode_hash(result, value);
return result;
}
int main()
{
// Replace these hashes with ones from a block to reproduce the same merkle root.
bc::hash_list tx_hashes{{
get_hash("0000000000000000000000000000000000000000000000000000000000000000"),
get_hash("0000000000000000000000000000000000000000000000000000000000000011"),
get_hash("0000000000000000000000000000000000000000000000000000000000000022"),
bc::hash_literal("0000000000000000000000000000000000000000000000000000000000000000"),
bc::hash_literal("0000000000000000000000000000000000000000000000000000000000000011"),
bc::hash_literal("0000000000000000000000000000000000000000000000000000000000000022"),
}};
const bc::hash_digest merkle_root = create_merkle(tx_hashes);
std::cout << "Result: " << bc::encode_hex(merkle_root) << std::endl;