add rct to the protocol

It is not yet constrained to a fork, so don't use on the real network
or you'll be orphaned or rejected.
This commit is contained in:
moneromooo-monero 2016-06-15 23:37:13 +01:00
parent 211d1db762
commit dc4aad7eb5
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
26 changed files with 1219 additions and 285 deletions

View file

@ -335,7 +335,7 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events
tx_source_entry se;
se.amount = blk_0.miner_tx.vout[0].amount;
se.outputs.push_back(std::make_pair(0, boost::get<txout_to_key>(blk_0.miner_tx.vout[0].target).key));
se.push_output(0, boost::get<txout_to_key>(blk_0.miner_tx.vout[0].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(blk_0.miner_tx);
se.real_output_in_tx_index = 0;
@ -377,7 +377,7 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>
tx_source_entry se;
se.amount = blk_1.miner_tx.vout[0].amount;
se.outputs.push_back(std::make_pair(0, boost::get<txout_to_key>(blk_1.miner_tx.vout[0].target).key));
se.push_output(0, boost::get<txout_to_key>(blk_1.miner_tx.vout[0].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(blk_1.miner_tx);
se.real_output_in_tx_index = 0;

View file

@ -412,7 +412,7 @@ bool fill_output_entries(std::vector<output_index>& out_indices, size_t sender_o
if (append)
{
const txout_to_key& otk = boost::get<txout_to_key>(oi.out);
output_entries.push_back(tx_source_entry::output_entry(oi.idx, otk.key));
output_entries.push_back(tx_source_entry::output_entry(oi.idx, rct::ctkey({rct::pk2rct(otk.key), rct::identity()})));
}
}
@ -544,7 +544,7 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
out.target = txout_to_key(out_eph_public_key);
tx.vout.push_back(out);
tx.version = CURRENT_TRANSACTION_VERSION;
tx.version = 1;
tx.unlock_time = height + CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW;
return true;

View file

@ -128,7 +128,7 @@ bool gen_double_spend_in_tx<txs_keeped_by_block>::generate(std::vector<test_even
std::vector<cryptonote::tx_source_entry> sources;
cryptonote::tx_source_entry se;
se.amount = tx_0.vout[0].amount;
se.outputs.push_back(std::make_pair(0, boost::get<cryptonote::txout_to_key>(tx_0.vout[0].target).key));
se.push_output(0, boost::get<cryptonote::txout_to_key>(tx_0.vout[0].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(tx_0);
se.real_output_in_tx_index = 0;

View file

@ -61,7 +61,7 @@ namespace
{
cryptonote::tx_source_entry se;
se.amount = tx.vout[out_idx].amount;
se.outputs.push_back(std::make_pair(0, boost::get<cryptonote::txout_to_key>(tx.vout[out_idx].target).key));
se.push_output(0, boost::get<cryptonote::txout_to_key>(tx.vout[out_idx].target).key, se.amount);
se.real_output = 0;
se.real_out_tx_key = get_tx_pub_key_from_extra(tx);
se.real_output_in_tx_index = out_idx;

View file

@ -82,29 +82,18 @@ bool test_transaction_generation_and_ring_signature()
src.amount = 70368744177663;
{
tx_output_entry oe;
oe.first = 0;
oe.second = boost::get<txout_to_key>(tx_mine_1.vout[0].target).key;
src.outputs.push_back(oe);
oe.first = 1;
oe.second = boost::get<txout_to_key>(tx_mine_2.vout[0].target).key;
src.outputs.push_back(oe);
src.push_output(0, boost::get<txout_to_key>(tx_mine_1.vout[0].target).key, src.amount);
oe.first = 2;
oe.second = boost::get<txout_to_key>(tx_mine_3.vout[0].target).key;
src.outputs.push_back(oe);
src.push_output(1, boost::get<txout_to_key>(tx_mine_2.vout[0].target).key, src.amount);
oe.first = 3;
oe.second = boost::get<txout_to_key>(tx_mine_4.vout[0].target).key;
src.outputs.push_back(oe);
src.push_output(2, boost::get<txout_to_key>(tx_mine_3.vout[0].target).key, src.amount);
oe.first = 4;
oe.second = boost::get<txout_to_key>(tx_mine_5.vout[0].target).key;
src.outputs.push_back(oe);
src.push_output(3, boost::get<txout_to_key>(tx_mine_4.vout[0].target).key, src.amount);
oe.first = 5;
oe.second = boost::get<txout_to_key>(tx_mine_6.vout[0].target).key;
src.outputs.push_back(oe);
src.push_output(4, boost::get<txout_to_key>(tx_mine_5.vout[0].target).key, src.amount);
src.push_output(5, boost::get<txout_to_key>(tx_mine_6.vout[0].target).key, src.amount);
src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(tx_mine_2);
src.real_output = 1;

View file

@ -39,7 +39,7 @@ namespace
{
struct tx_builder
{
void step1_init(size_t version = CURRENT_TRANSACTION_VERSION, uint64_t unlock_time = 0)
void step1_init(size_t version = 1, uint64_t unlock_time = 0)
{
m_tx.vin.clear();
m_tx.vout.clear();
@ -108,9 +108,13 @@ namespace
BOOST_FOREACH(const tx_source_entry& src_entr, sources)
{
std::vector<const crypto::public_key*> keys_ptrs;
std::vector<crypto::public_key> keys(src_entr.outputs.size());
size_t j = 0;
BOOST_FOREACH(const tx_source_entry::output_entry& o, src_entr.outputs)
{
keys_ptrs.push_back(&o.second);
keys[j] = rct::rct2pk(o.second.dest);
keys_ptrs.push_back(&keys[j]);
++j;
}
m_tx.signatures.push_back(std::vector<crypto::signature>());
@ -136,7 +140,7 @@ namespace
fill_tx_sources_and_destinations(events, blk_head, from, to, amount, TESTS_DEFAULT_FEE, 0, sources, destinations);
tx_builder builder;
builder.step1_init(CURRENT_TRANSACTION_VERSION, unlock_time);
builder.step1_init(1, unlock_time);
builder.step2_fill_inputs(from.get_keys(), sources);
builder.step3_fill_outputs(destinations);
builder.step4_calc_hash();
@ -177,7 +181,7 @@ bool gen_tx_big_version::generate(std::vector<test_event_entry>& events) const
fill_tx_sources_and_destinations(events, blk_0, miner_account, miner_account, MK_COINS(1), TESTS_DEFAULT_FEE, 0, sources, destinations);
tx_builder builder;
builder.step1_init(CURRENT_TRANSACTION_VERSION + 1, 0);
builder.step1_init(1 + 1, 0);
builder.step2_fill_inputs(miner_account.get_keys(), sources);
builder.step3_fill_outputs(destinations);
builder.step4_calc_hash();

View file

@ -79,7 +79,6 @@ bool gen_v2_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
}
// create a tx with the Nth outputs of miner's block reward
typedef tx_source_entry::output_entry tx_output_entry;
std::vector<tx_source_entry> sources;
for (size_t out_idx_idx = 0; out_idx[out_idx_idx] >= 0; ++out_idx_idx) {
sources.resize(sources.size()+1);
@ -88,13 +87,12 @@ bool gen_v2_tx_validation_base::generate_with(std::vector<test_event_entry>& eve
src.amount = blocks[0].miner_tx.vout[out_idx[out_idx_idx]].amount;
std::cout << "using " << print_money(src.amount) << " output at index " << out_idx[out_idx_idx] << std::endl;
for (int m = 0; m <= mixin; ++m) {
tx_output_entry oe;
int idx;
if (is_valid_decomposed_amount(src.amount))
oe.first = m+1; // one out of that size per miner tx, including genesis
idx = m+1; // one out of that size per miner tx, including genesis
else
oe.first = 0; // dusty, no other output of that size
oe.second = boost::get<txout_to_key>(blocks[m].miner_tx.vout[out_idx[out_idx_idx]].target).key;
src.outputs.push_back(oe);
idx = 0; // dusty, no other output of that size
src.push_output(idx, boost::get<txout_to_key>(blocks[m].miner_tx.vout[out_idx[out_idx_idx]].target).key, src.amount);
}
src.real_out_tx_key = cryptonote::get_tx_pub_key_from_extra(blocks[0].miner_tx);
src.real_output = 0;

View file

@ -59,7 +59,7 @@ public:
return false;
txout_to_key tx_out = boost::get<txout_to_key>(m_miner_txs[i].vout[0].target);
output_entries.push_back(std::make_pair(i, tx_out.key));
output_entries.push_back(std::make_pair(i, rct::ctkey({rct::pk2rct(tx_out.key), rct::identity()})));
m_public_keys[i] = tx_out.key;
m_public_key_ptrs[i] = &m_public_keys[i];
}