48{
50
53
54
55 cryptonote::account_base miner_accounts[12];
56 const cryptonote::block *prev_block = &blk_0;
58 for (size_t n = 0; n < 12; ++n) {
60 CHECK_AND_ASSERT_MES(generator.construct_block_manually(blocks[n], *prev_block, miner_accounts[n],
63 crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 0, 2),
64 false, "Failed to generate block");
65 events.push_back(blocks[n]);
66 prev_block = blocks + n;
68 }
69
70
71 cryptonote::block blk_r, blk_last;
72 {
73 blk_last = blocks[11];
75 {
79 crypto::hash(), 0, transaction(), std::vector<crypto::hash>(), 0, 0, 2),
80 false, "Failed to generate block");
81 events.push_back(blocks[12+i]);
82 blk_last = blocks[12+i];
83 }
84 blk_r = blk_last;
85 }
86
87
88 std::vector<transaction> rct_txes;
89 cryptonote::block blk_txes;
90 std::vector<crypto::hash> starting_rct_tx_hashes;
91 static const uint64_t input_amounts_available[] = {5000000000000, 30000000000000, 100000000000, 80000000000};
92 for (size_t n = 0; n < n_txes; ++n)
93 {
94 std::vector<tx_source_entry> sources;
95
96 sources.resize(1);
97 tx_source_entry& src = sources.back();
98
99 const uint64_t needed_amount = input_amounts_available[n];
100 src.
amount = input_amounts_available[n];
101 size_t real_index_in_tx = 0;
102 for (size_t m = 0; m <= mixin; ++m) {
103 size_t index_in_tx = 0;
104 for (
size_t i = 0; i < blocks[m].
miner_tx.
vout.size(); ++i)
105 if (blocks[m].miner_tx.vout[i].amount == needed_amount)
106 index_in_tx = i;
107 CHECK_AND_ASSERT_MES(blocks[m].miner_tx.vout[index_in_tx].amount == needed_amount,
false,
"Expected amount not found");
108 src.
push_output(m, boost::get<txout_to_key>(blocks[m].miner_tx.vout[index_in_tx].target).key, src.
amount);
109 if (m == n)
110 real_index_in_tx = index_in_tx;
111 }
117
118
119 tx_destination_entry td;
121 std::vector<tx_destination_entry> destinations;
122 for (
int o = 0; amounts_paid[o] != (
uint64_t)-1; ++o)
123 {
124 td.
amount = amounts_paid[o];
125 destinations.push_back(td);
126 }
127
128 if (pre_tx && !pre_tx(sources, destinations, n))
129 {
130 MDEBUG(
"pre_tx returned failure");
131 return false;
132 }
133
135 std::vector<crypto::secret_key> additional_tx_keys;
136 std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
138 rct_txes.resize(rct_txes.size() + 1);
139 bool r =
construct_tx_and_get_tx_key(miner_accounts[n].get_keys(), subaddresses, sources, destinations, cryptonote::account_public_address{}, std::vector<uint8_t>(), rct_txes.back(), 0, tx_key, additional_tx_keys,
true, rct_config[n]);
141
142 if (post_tx && !post_tx(rct_txes.back(), n))
143 {
144 MDEBUG(
"post_tx returned failure");
145 return false;
146 }
147
148
151
152 for (
int o = 0; amounts_paid[o] != (
uint64_t)-1; ++o)
153 {
159 rct::key rct_tx_mask;
160 const uint8_t type = rct_txes.back().rct_signatures.type;
163 else
165 }
166
167 while (amounts_paid[0] != (size_t)-1)
168 ++amounts_paid;
169 ++amounts_paid;
170 }
171 if (!valid)
173 events.push_back(rct_txes);
174
178 crypto::hash(), 0, transaction(), starting_rct_tx_hashes, 0, 6, 10),
179 false, "Failed to generate block");
180 if (!valid)
182 events.push_back(blk_txes);
183 blk_last = blk_txes;
184
185 return true;
186}
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
#define GENERATE_ACCOUNT(account)
crypto::secret_key generate(const crypto::secret_key &recovery_key=crypto::secret_key(), bool recover=false, bool two_random=false)
const account_keys & get_keys() const
std::vector< tx_out > vout
#define DIFFICULTY_BLOCKS_ESTIMATE_TIMESPAN
#define CRYPTONOTE_MINED_ETN_UNLOCK_WINDOW
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
epee::mlocked< tools::scrubbed< ec_scalar > > secret_key
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
void derivation_to_scalar(const key_derivation &derivation, size_t output_index, ec_scalar &res)
std::string obj_to_json_str(T &obj)
bool construct_tx_and_get_tx_key(const account_keys &sender_account_keys, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations, const boost::optional< cryptonote::account_public_address > &change_addr, const std::vector< uint8_t > &extra, transaction &tx, uint64_t unlock_time, crypto::secret_key &tx_key, std::vector< crypto::secret_key > &additional_tx_keys, bool rct, const rct::RCTConfig &rct_config, rct::multisig_out *msout, const uint32_t account_major_offset, const cryptonote::network_type nettype)
crypto::public_key get_tx_pub_key_from_extra(const std::vector< uint8_t > &tx_extra, size_t pk_index)
crypto::hash get_transaction_hash(const transaction &t)
device & get_device(const std::string &device_descriptor)
etn_amount decodeRctSimple(const rctSig &rv, const key &sk, unsigned int i, key &mask, hw::device &hwdev)
etn_amount decodeRct(const rctSig &rv, const key &sk, unsigned int i, key &mask, hw::device &hwdev)
unsigned __int64 uint64_t
account_public_address m_account_address
crypto::public_key m_spend_public_key
account_public_address addr
crypto::public_key real_out_tx_key
void push_output(uint64_t idx, const crypto::public_key &k, uint64_t amount)
size_t real_output_in_tx_index