48 m_tx.signatures.clear();
51 m_tx.unlock_time = unlock_time;
57 void step2_fill_inputs(
const account_keys& sender_account_keys,
const std::vector<tx_source_entry>& sources)
61 m_in_contexts.push_back(
keypair());
62 keypair& in_ephemeral = m_in_contexts.back();
64 std::unordered_map<crypto::public_key, cryptonote::subaddress_index> subaddresses;
76 input_to_key.key_offsets.push_back(out_entry.first);
79 m_tx.vin.push_back(input_to_key);
96 tk.
key = out_eph_public_key;
98 m_tx.vout.push_back(out);
103 void step4_calc_hash()
108 void step5_sign(
const std::vector<tx_source_entry>& sources)
110 m_tx.signatures.clear();
115 std::vector<const crypto::public_key*> keys_ptrs;
116 std::vector<crypto::public_key> keys(src_entr.
outputs.size());
120 keys[j] = rct::rct2pk(o.second.dest);
121 keys_ptrs.push_back(&keys[j]);
125 m_tx.signatures.push_back(std::vector<crypto::signature>());
126 std::vector<crypto::signature>& sigs = m_tx.signatures.back();
127 sigs.resize(src_entr.
outputs.size());
135 std::vector<keypair> m_in_contexts;
139 transaction make_simple_tx_with_unlock_time(
const std::vector<test_event_entry>& events,
143 std::vector<tx_source_entry> sources;
144 std::vector<tx_destination_entry> destinations;
148 builder.step1_init(1, unlock_time);
149 builder.step2_fill_inputs(from.
get_keys(), sources);
150 builder.step3_fill_outputs(destinations);
151 builder.step4_calc_hash();
152 builder.step5_sign(sources);
158 for (
int i = 0; i <= 0xFF; ++i)
168 throw std::runtime_error(
"invalid public key wasn't found");
177 throw std::runtime_error(
"invalid key image wasn't found");
193 std::vector<tx_source_entry> sources;
194 std::vector<tx_destination_entry> destinations;
198 builder.step1_init(1 + 1, 0);
199 builder.step2_fill_inputs(miner_account.get_keys(), sources);
200 builder.step3_fill_outputs(destinations);
201 builder.step4_calc_hash();
202 builder.step5_sign(sources);
205 events.push_back(builder.m_tx);
221 return make_simple_tx_with_unlock_time(events, blk_1, miner_account, miner_account,
MK_COINS(1), unlock_time);
224 std::list<transaction> txs_0;
226 txs_0.push_back(make_tx_with_unlock_time(0));
227 events.push_back(txs_0.back());
230 events.push_back(txs_0.back());
233 events.push_back(txs_0.back());
236 events.push_back(txs_0.back());
239 events.push_back(txs_0.back());
241 txs_0.push_back(make_tx_with_unlock_time(ts_start - 1));
242 events.push_back(txs_0.back());
244 txs_0.push_back(make_tx_with_unlock_time(
time(0) + 60 * 60));
245 events.push_back(txs_0.back());
264 events.push_back(blk_tmp.miner_tx);
268 std::vector<tx_source_entry> sources;
269 std::vector<tx_destination_entry> destinations;
273 builder.step1_init();
274 builder.m_tx.vin.push_back(tx_input);
275 builder.step3_fill_outputs(destinations);
296 builder.step1_init();
299 events.push_back(builder.m_tx);
311 std::vector<tx_source_entry> sources;
312 std::vector<tx_destination_entry> destinations;
316 builder.step1_init();
317 builder.step3_fill_outputs(destinations);
320 events.push_back(builder.m_tx);
333 std::vector<tx_source_entry> sources;
334 std::vector<tx_destination_entry> destinations;
336 destinations.clear();
339 builder.step1_init();
340 builder.step2_fill_inputs(miner_account.get_keys(), sources);
341 builder.step3_fill_outputs(destinations);
342 builder.step4_calc_hash();
343 builder.step5_sign(sources);
345 events.push_back(builder.m_tx);
359 std::vector<tx_source_entry> sources;
360 std::vector<tx_destination_entry> destinations;
362 sources.front().amount++;
365 builder.step1_init();
366 builder.step2_fill_inputs(miner_account.get_keys(), sources);
367 builder.step3_fill_outputs(destinations);
368 builder.step4_calc_hash();
369 builder.step5_sign(sources);
372 events.push_back(builder.m_tx);
385 std::vector<tx_source_entry> sources;
386 std::vector<tx_destination_entry> destinations;
390 builder.step1_init();
391 builder.step2_fill_inputs(miner_account.get_keys(), sources);
392 builder.step3_fill_outputs(destinations);
393 txin_to_key& in_to_key = boost::get<txin_to_key>(builder.m_tx.vin.front());
397 builder.step4_calc_hash();
399 builder.step5_sign(sources);
403 events.push_back(builder.m_tx);
422 std::vector<tx_source_entry> sources_bob;
423 std::vector<tx_destination_entry> destinations_bob;
426 std::vector<tx_source_entry> sources_alice;
427 std::vector<tx_destination_entry> destinations_alice;
431 builder.step1_init();
432 builder.step2_fill_inputs(bob_account.get_keys(), sources_bob);
433 txin_to_key& in_to_key = boost::get<txin_to_key>(builder.m_tx.vin.front());
434 in_to_key.
key_offsets.front() = sources_alice.front().outputs.front().first;
435 builder.step3_fill_outputs(destinations_bob);
436 builder.step4_calc_hash();
437 builder.step5_sign(sources_bob);
440 events.push_back(builder.m_tx);
453 std::vector<tx_source_entry> sources;
454 std::vector<tx_destination_entry> destinations;
458 builder.step1_init();
459 builder.step2_fill_inputs(miner_account.get_keys(), sources);
460 txin_to_key& in_to_key = boost::get<txin_to_key>(builder.m_tx.vin.front());
461 in_to_key.
key_offsets.front() = std::numeric_limits<uint64_t>::max();
462 builder.step3_fill_outputs(destinations);
463 builder.step4_calc_hash();
464 builder.step5_sign(sources);
467 events.push_back(builder.m_tx);
486 std::vector<tx_source_entry> sources;
487 std::vector<tx_destination_entry> destinations;
490 sources.front().outputs[(sources.front().real_output + 1) % 2].first = std::numeric_limits<uint64_t>::max();
493 builder.step1_init();
494 builder.step2_fill_inputs(bob_account.get_keys(), sources);
495 builder.step3_fill_outputs(destinations);
496 builder.step4_calc_hash();
497 builder.step5_sign(sources);
500 events.push_back(builder.m_tx);
513 std::vector<tx_source_entry> sources;
514 std::vector<tx_destination_entry> destinations;
518 builder.step1_init();
519 builder.step2_fill_inputs(miner_account.get_keys(), sources);
521 txin_to_key& in_to_key = boost::get<txin_to_key>(builder.m_tx.vin.front());
525 in_to_key.
k_image = another_ki;
527 builder.step3_fill_outputs(destinations);
528 builder.step4_calc_hash();
531 builder.m_tx.signatures.resize(1);
532 builder.m_tx.signatures[0].resize(1);
533 builder.m_tx.signatures[0][0] = boost::value_initialized<crypto::signature>();
536 events.push_back(builder.m_tx);
549 std::vector<tx_source_entry> sources;
550 std::vector<tx_destination_entry> destinations;
554 builder.step1_init();
555 builder.step2_fill_inputs(miner_account.get_keys(), sources);
557 txin_to_key& in_to_key = boost::get<txin_to_key>(builder.m_tx.vin.front());
558 in_to_key.
k_image = generate_invalid_key_image();
560 builder.step3_fill_outputs(destinations);
561 builder.step4_calc_hash();
564 builder.m_tx.signatures.resize(1);
565 builder.m_tx.signatures[0].resize(1);
566 builder.m_tx.signatures[0][0] = boost::value_initialized<crypto::signature>();
569 events.push_back(builder.m_tx);
576 static const size_t tests_count = 6;
585 std::array<account_base, tests_count> accounts;
586 for (
size_t i = 0; i < tests_count; ++i)
592 std::list<transaction> txs_0;
593 auto make_tx_to_acc = [&](
size_t acc_idx,
uint64_t unlock_time)
595 txs_0.push_back(make_simple_tx_with_unlock_time(events, blk_1, miner_account, accounts[acc_idx],
597 events.push_back(txs_0.back());
601 make_tx_to_acc(0, 0);
602 make_tx_to_acc(1, blk_3_height - 1);
603 make_tx_to_acc(2, blk_3_height);
604 make_tx_to_acc(3, blk_3_height + 1);
605 make_tx_to_acc(4,
time(0) - 1);
606 make_tx_to_acc(5,
time(0) + 60 * 60);
609 std::list<transaction> txs_1;
610 auto make_tx_from_acc = [&](
size_t acc_idx,
bool invalid)
612 transaction tx = make_simple_tx_with_unlock_time(events, blk_2, accounts[acc_idx], miner_account,
MK_COINS(1), 0);
621 events.push_back(tx);
624 make_tx_from_acc(0,
false);
625 make_tx_from_acc(1,
false);
626 make_tx_from_acc(2,
false);
627 make_tx_from_acc(3,
true);
628 make_tx_from_acc(4,
false);
629 make_tx_from_acc(5,
true);
643 std::vector<tx_source_entry> sources;
644 std::vector<tx_destination_entry> destinations;
648 builder.step1_init();
649 builder.step2_fill_inputs(miner_account.get_keys(), sources);
650 builder.step3_fill_outputs(destinations);
652 txout_to_key& out_to_key = boost::get<txout_to_key>(builder.m_tx.vout.front().target);
653 out_to_key.
key = generate_invalid_pub_key();
655 builder.step4_calc_hash();
656 builder.step5_sign(sources);
659 events.push_back(builder.m_tx);
672 std::vector<tx_source_entry> sources;
673 std::vector<tx_destination_entry> destinations;
677 builder.step1_init();
678 builder.step2_fill_inputs(miner_account.get_keys(), sources);
679 builder.step3_fill_outputs(destinations);
681 builder.m_tx.vout.front().amount = 0;
683 builder.step4_calc_hash();
684 builder.step5_sign(sources);
687 events.push_back(builder.m_tx);
700 std::vector<tx_source_entry> sources;
701 std::vector<tx_destination_entry> destinations;
705 builder.step1_init();
706 builder.step2_fill_inputs(miner_account.get_keys(), sources);
708 builder.m_tx.vout.push_back(
tx_out());
709 builder.m_tx.vout.back().amount = 1;
712 builder.step4_calc_hash();
713 builder.step5_sign(sources);
716 events.push_back(builder.m_tx);
718 builder.step1_init();
719 builder.step2_fill_inputs(miner_account.get_keys(), sources);
721 builder.m_tx.vout.push_back(
tx_out());
722 builder.m_tx.vout.back().amount = 1;
725 builder.step4_calc_hash();
726 builder.step5_sign(sources);
729 events.push_back(builder.m_tx);
748 MAKE_TX(events, tx_0, miner_account, miner_account,
MK_COINS(60), blk_2);
bool generate(std::vector< test_event_entry > &events) const
#define MAKE_NEXT_BLOCK_TX1(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TX1)
std::vector< std::string > keypair
crypto::public_key real_out_tx_key
#define CHECK_AND_ASSERT_MES(expr, fail_ret_val, message)
boost::variant< txin_gen, txin_to_script, txin_to_scripthash, txin_to_key, txin_to_key_public > txin_v
void fill_tx_sources_and_destinations(const std::vector< test_event_entry > &events, const block &blk_head, const cryptonote::account_base &from, const cryptonote::account_public_address &to, uint64_t amount, uint64_t fee, size_t nmix, std::vector< tx_source_entry > &sources, std::vector< tx_destination_entry > &destinations)
bool generate(std::vector< test_event_entry > &events) const
#define REWIND_BLOCKS_N(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, COUNT)
#define MAKE_NEXT_BLOCK(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
std::vector< uint64_t > key_offsets
#define TESTS_DEFAULT_FEE
bool generate(std::vector< test_event_entry > &events) const
#define MAKE_TX_LIST(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
bool generate_key_derivation(const public_key &key1, const secret_key &key2, key_derivation &derivation)
const account_keys & get_keys() const
Holds cryptonote related classes and helpers.
bool generate(std::vector< test_event_entry > &events) const
crypto::public_key m_spend_public_key
bool add_tx_pub_key_to_extra(transaction &tx, const crypto::public_key &tx_pub_key)
void generate_key_image(const public_key &pub, const secret_key &sec, key_image &image)
crypto::public_key m_view_public_key
bool generate(std::vector< test_event_entry > &events) const
bool generate_key_image_helper(const account_keys &ack, const std::unordered_map< crypto::public_key, subaddress_index > &subaddresses, const crypto::public_key &out_key, const crypto::public_key &tx_public_key, const std::vector< crypto::public_key > &additional_tx_public_keys, size_t real_output_index, keypair &in_ephemeral, crypto::key_image &ki, hw::device &hwdev, const uint32_t account_major_offset)
bool generate(std::vector< test_event_entry > &events) const
#define MAKE_TX_MIX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, NMIX, HEAD)
std::vector< uint64_t > absolute_output_offsets_to_relative(const std::vector< uint64_t > &off)
void generate_ring_signature(const hash &prefix_hash, const key_image &image, const public_key *const *pubs, std::size_t pubs_count, const secret_key &sec, std::size_t sec_index, signature *sig)
device & get_device(const std::string &device_descriptor)
#define MAKE_GENESIS_BLOCK(VEC_EVENTS, BLK_NAME, MINER_ACC, TS)
unsigned __int64 uint64_t
bool t_serializable_object_to_blob(const t_object &to, blobdata &b_blob)
bool generate(std::vector< test_event_entry > &events) const
#define MAKE_TX_LIST_START(VEC_EVENTS, SET_NAME, FROM, TO, AMOUNT, HEAD)
bool generate(std::vector< test_event_entry > &events) const
version
Supported socks variants.
bool generate(std::vector< test_event_entry > &events) const
account_public_address addr
account_public_address m_account_address
void get_transaction_prefix_hash(const transaction_prefix &tx, crypto::hash &h)
#define MAKE_ACCOUNT(VEC_EVENTS, account)
#define REWIND_BLOCKS(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC)
std::vector< crypto::public_key > real_out_additional_tx_keys
size_t real_output_in_tx_index
bool derive_public_key(const key_derivation &derivation, std::size_t output_index, const public_key &base, public_key &derived_key)
crypto::key_image k_image
bool check_key(const public_key &key)
std::vector< output_entry > outputs
bool generate(std::vector< test_event_entry > &events) const
serialized_object< cryptonote::transaction > serialized_transaction
#define MAKE_TX(VEC_EVENTS, TX_NAME, FROM, TO, AMOUNT, HEAD)
bool generate(std::vector< test_event_entry > &events) const
std::pair< uint64_t, rct::ctkey > output_entry
#define GENERATE_ACCOUNT(account)
#define DO_CALLBACK(VEC_EVENTS, CB_NAME)
#define MAKE_NEXT_BLOCK_TX_LIST(VEC_EVENTS, BLK_NAME, PREV_BLOCK, MINER_ACC, TXLIST)
uint64_t get_block_height(const block &b)