You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
982 B
29 lines
982 B
10 years ago
|
/*
|
||
|
Display the genesis block message by Satoshi.
|
||
|
*/
|
||
|
#include <iostream>
|
||
|
#include <bitcoin/bitcoin.hpp>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
// Create genesis block.
|
||
|
bc::block_type block = bc::genesis_block();
|
||
|
// Genesis block contains a single coinbase transaction.
|
||
|
assert(block.transactions.size() == 1);
|
||
|
// Get first transaction in block (coinbase).
|
||
|
const bc::transaction_type& coinbase_tx = block.transactions[0];
|
||
|
// Coinbase tx has a single input.
|
||
|
assert(coinbase_tx.inputs.size() == 1);
|
||
|
const bc::transaction_input_type& coinbase_input = coinbase_tx.inputs[0];
|
||
|
// Convert the input script to its raw format.
|
||
|
const bc::data_chunk& raw_message = save_script(coinbase_input.script);
|
||
|
// Convert this to an std::string.
|
||
|
std::string message;
|
||
|
message.resize(raw_message.size());
|
||
|
std::copy(raw_message.begin(), raw_message.end(), message.begin());
|
||
|
// Display the genesis block message.
|
||
|
std::cout << message << std::endl;
|
||
|
return 0;
|
||
|
}
|
||
|
|