//--------------------------------------------------------------- bool generate_genesis_block( block& bl , std::string const & genesis_tx , uint32_t nonce ) { //genesis block bl = boost::value_initialized<block>(); account_public_address ac = boost::value_initialized<account_public_address>(); std::vector<size_t> sz; construct_miner_tx(0, 0, 0, 0, 0, ac, bl.miner_tx); // zero fee in genesis blobdata txb = tx_to_blob(bl.miner_tx); std::string hex_tx_represent = string_tools::buff_to_hex_nodelimer(txb); std::string genesis_coinbase_tx_hex = config::GENESIS_TX; blobdata tx_bl; string_tools::parse_hexstr_to_binbuff(genesis_coinbase_tx_hex, tx_bl); bool r = parse_and_validate_tx_from_blob(tx_bl, bl.miner_tx); CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob"); bl.major_version = CURRENT_BLOCK_MAJOR_VERSION; bl.minor_version = CURRENT_BLOCK_MINOR_VERSION; bl.timestamp = 0; bl.nonce = nonce; miner::find_nonce_for_given_block(bl, 1, 0); bl.invalidate_hashes(); return true; }
bool BlockchainDB::get_tx(const crypto::hash& h, cryptonote::transaction &tx) const { blobdata bd; if (!get_tx_blob(h, bd)) return false; if (!parse_and_validate_tx_from_blob(bd, tx)) throw DB_ERROR("Failed to parse transaction from blob retrieved from the db"); return true; }
int TransactionFuzzer::run(const std::string &filename) { std::string s; if (!epee::file_io_utils::load_file_to_string(filename, s)) { std::cout << "Error: failed to load file " << filename << std::endl; return 1; } cryptonote::transaction tx = AUTO_VAL_INIT(tx); if(!parse_and_validate_tx_from_blob(s, tx)) { std::cout << "Error: failed to parse transaction from file " << filename << std::endl; return 1; } return 0; }
bool Currency::generateGenesisBlock() { m_genesisBlock = boost::value_initialized<Block>(); // Hard code coinbase tx in genesis block, because "tru" generating tx use random, but genesis should be always the same std::string genesisCoinbaseTxHex = GENESIS_COINBASE_TX_HEX; blobdata minerTxBlob; epee::string_tools::parse_hexstr_to_binbuff(genesisCoinbaseTxHex, minerTxBlob); bool r = parse_and_validate_tx_from_blob(minerTxBlob, m_genesisBlock.minerTx); CHECK_AND_ASSERT_MES(r, false, "failed to parse coinbase tx from hard coded blob"); m_genesisBlock.majorVersion = BLOCK_MAJOR_VERSION_1; m_genesisBlock.minorVersion = BLOCK_MINOR_VERSION_0; m_genesisBlock.timestamp = 0; m_genesisBlock.nonce = 70; if (m_testnet) { ++m_genesisBlock.nonce; } //miner::find_nonce_for_given_block(bl, 1, 0); return true; }
//----------------------------------------------------------------------------------------------- bool core::parse_tx_from_blob(Transaction& tx, crypto::hash& tx_hash, crypto::hash& tx_prefix_hash, const blobdata& blob) { return parse_and_validate_tx_from_blob(blob, tx, tx_hash, tx_prefix_hash); }