started fixing mempool ringct tx on mainnet

master
moneroexamples 8 years ago
parent fe8d33b986
commit 1f9fdda419

@ -1175,7 +1175,7 @@ public:
string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F"); string server_time_str = xmreg::timestamp_to_str(server_timestamp, "%F");
uint64_t output_idx {0};
// public transaction key is combined with our viewkey // public transaction key is combined with our viewkey
// to create, so called, derived key. // to create, so called, derived key.
@ -1183,6 +1183,8 @@ public:
public_key pub_key = tx_prove ? address.m_view_public_key : txd.pk; public_key pub_key = tx_prove ? address.m_view_public_key : txd.pk;
cout << "txd.pk: " << pod_to_hex(txd.pk) << endl;
if (!generate_key_derivation(pub_key, prv_view_key, derivation)) if (!generate_key_derivation(pub_key, prv_view_key, derivation))
{ {
cerr << "Cant get derived key for: " << "\n" cerr << "Cant get derived key for: " << "\n"
@ -1200,7 +1202,7 @@ public:
//std::deque<rct::key> mask(tx.vout.size()); //std::deque<rct::key> mask(tx.vout.size());
uint64_t i {0}; uint64_t output_idx {0};
for (pair<txout_to_key, uint64_t>& outp: txd.output_pub_keys) for (pair<txout_to_key, uint64_t>& outp: txd.output_pub_keys)
{ {
@ -1215,6 +1217,9 @@ public:
address.m_spend_public_key, address.m_spend_public_key,
tx_pubkey); tx_pubkey);
cout << pod_to_hex(outp.first.key) << endl;
cout << pod_to_hex(tx_pubkey) << endl;
// check if generated public key matches the current output's key // check if generated public key matches the current output's key
bool mine_output = (outp.first.key == tx_pubkey); bool mine_output = (outp.first.key == tx_pubkey);
@ -1222,15 +1227,15 @@ public:
if (mine_output && tx.version == 2) if (mine_output && tx.version == 2)
{ {
// initialize with regular amount // initialize with regular amount
uint64_t rct_amount = money_transfered[i]; uint64_t rct_amount = money_transfered[output_idx];
bool r; bool r;
r = decode_ringct(tx.rct_signatures, r = decode_ringct(tx.rct_signatures,
pub_key, pub_key,
prv_view_key, prv_view_key,
i, output_idx,
tx.rct_signatures.ecdhInfo[i].mask, tx.rct_signatures.ecdhInfo[output_idx].mask,
rct_amount); rct_amount);
if (!r) if (!r)
@ -1243,7 +1248,7 @@ public:
if (!is_coinbase(tx)) if (!is_coinbase(tx))
{ {
outp.second = rct_amount; outp.second = rct_amount;
money_transfered[i] = rct_amount; money_transfered[output_idx] = rct_amount;
} }
} }
@ -1259,10 +1264,10 @@ public:
outp.first.key))}, outp.first.key))},
{"amount" , xmreg::xmr_amount_to_str(outp.second)}, {"amount" , xmreg::xmr_amount_to_str(outp.second)},
{"mine_output" , mine_output}, {"mine_output" , mine_output},
{"output_idx" , fmt::format("{:02d}", output_idx++)} {"output_idx" , fmt::format("{:02d}", output_idx)}
}); });
++i; ++output_idx;
} }
// we can also test ouputs used in mixins for key images // we can also test ouputs used in mixins for key images

@ -441,6 +441,8 @@ get_ouputs(const transaction& tx)
{ {
if (txout.target.type() != typeid(txout_to_key)) if (txout.target.type() != typeid(txout_to_key))
{ {
// push empty pair.
outputs.push_back(pair<txout_to_key, uint64_t>{});
continue; continue;
} }
@ -1020,6 +1022,9 @@ make_tx_from_json(const string& json_str, transaction& tx)
return false; return false;
} }
cout << "\n\n j.dump()" << j.dump(4) << endl;
// get version and unlock time from json // get version and unlock time from json
tx.version = j["version"].get<size_t>(); tx.version = j["version"].get<size_t>();
tx.unlock_time = j["unlock_time"].get<uint64_t>(); tx.unlock_time = j["unlock_time"].get<uint64_t>();
@ -1243,7 +1248,7 @@ make_tx_from_json(const string& json_str, transaction& tx)
} // j.find("rctsig_prunable") != j.end() } // j.find("rctsig_prunable") != j.end()
//cout << j.dump(4) << endl; cout << "\nreconstructed: \n" << j.dump(4) << endl;
//cout << "From reconstructed tx: " << obj_to_json_str(tx) << endl; //cout << "From reconstructed tx: " << obj_to_json_str(tx) << endl;

Loading…
Cancel
Save