serializations forks as magic
This commit is contained in:
parent
146be2a559
commit
17d1245db1
20 changed files with 97 additions and 62 deletions
|
|
@ -4368,7 +4368,7 @@ struct outputs_visitor
|
|||
, m_source_max_unlock_time_for_pos_coinbase(source_max_unlock_time_for_pos_coinbase)
|
||||
, m_scan_context(scan_context)
|
||||
{}
|
||||
bool handle_output(const transaction& source_tx, const transaction& validated_tx, const tx_out_old& out, uint64_t out_i)
|
||||
bool handle_output(const transaction& source_tx, const transaction& validated_tx, const tx_out_bare& out, uint64_t out_i)
|
||||
{
|
||||
//check tx unlock time
|
||||
uint64_t source_out_unlock_time = get_tx_unlock_time(source_tx, out_i);
|
||||
|
|
@ -4521,7 +4521,7 @@ bool blockchain_storage::check_ms_input(const transaction& tx, size_t in_index,
|
|||
LOC_CHK(is_tx_spendtime_unlocked(unlock_time), "Source transaction is LOCKED! unlock_time: " << unlock_time << ", now is " << m_core_runtime_config.get_core_time() << ", blockchain size is " << get_current_blockchain_size());
|
||||
|
||||
LOC_CHK(source_tx.vout.size() > out_n, "internal error: out_n==" << out_n << " is out-of-bounds of source_tx.vout, size=" << source_tx.vout.size());
|
||||
const tx_out_old& source_tx_out = source_tx.vout[out_n];
|
||||
const tx_out_bare& source_tx_out = source_tx.vout[out_n];
|
||||
const txout_multisig& source_ms_out_target = boost::get<txout_multisig>(source_tx_out.target);
|
||||
|
||||
LOC_CHK(txin.sigs_count == source_ms_out_target.minimum_sigs,
|
||||
|
|
@ -6689,7 +6689,7 @@ bool blockchain_storage::validate_alt_block_ms_input(const transaction& input_tx
|
|||
|
||||
for (size_t out_n = 0; out_n < tx.vout.size(); ++out_n)
|
||||
{
|
||||
const tx_out_old& out = tx.vout[out_n];
|
||||
const tx_out_bare& out = tx.vout[out_n];
|
||||
if (out.target.type() == typeid(txout_multisig))
|
||||
{
|
||||
const crypto::hash& ms_out_id = get_multisig_out_id(tx, out_n);
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ namespace currency
|
|||
typedef boost::variant<txout_to_key, txout_multisig, txout_htlc> txout_target_v;
|
||||
|
||||
//typedef std::pair<uint64_t, txout> out_t;
|
||||
struct tx_out_old
|
||||
struct tx_out_bare
|
||||
{
|
||||
uint64_t amount;
|
||||
txout_target_v target;
|
||||
|
|
@ -363,7 +363,7 @@ namespace currency
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef boost::variant<tx_out_old, tx_out_zarcanum> tx_out_v;
|
||||
typedef boost::variant<tx_out_bare, tx_out_zarcanum> tx_out_v;
|
||||
|
||||
|
||||
struct tx_comment
|
||||
|
|
@ -668,7 +668,7 @@ namespace currency
|
|||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<tx_out_old> vout;//std::vector<tx_out> vout;
|
||||
std::vector<tx_out_bare> vout;//std::vector<tx_out> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(version)
|
||||
|
|
@ -907,12 +907,17 @@ SET_VARIANT_TAGS(currency::extra_alias_entry, 33, "alias_entry2");
|
|||
SET_VARIANT_TAGS(currency::txin_htlc, 34, "txin_htlc");
|
||||
SET_VARIANT_TAGS(currency::txout_htlc, 35, "txout_htlc");
|
||||
|
||||
SET_VARIANT_TAGS(currency::tx_out_bare, 36, "tx_out_bare");
|
||||
|
||||
// Zarcanum
|
||||
SET_VARIANT_TAGS(currency::tx_in_zarcanum, 36, "tx_in_zarcanum");
|
||||
SET_VARIANT_TAGS(currency::tx_out_zarcanum, 37, "tx_out_zarcanum");
|
||||
SET_VARIANT_TAGS(currency::zarcanum_tx_data_v1, 38, "zarcanum_tx_data_v1");
|
||||
SET_VARIANT_TAGS(crypto::bpp_signature_serialized, 39, "bpp_signature_serialized");
|
||||
SET_VARIANT_TAGS(crypto::bppe_signature_serialized, 40, "bppe_signature_serialized");
|
||||
SET_VARIANT_TAGS(currency::tx_in_zarcanum, 37, "tx_in_zarcanum");
|
||||
SET_VARIANT_TAGS(currency::tx_out_zarcanum, 38, "tx_out_zarcanum");
|
||||
SET_VARIANT_TAGS(currency::zarcanum_tx_data_v1, 39, "zarcanum_tx_data_v1");
|
||||
SET_VARIANT_TAGS(crypto::bpp_signature_serialized, 40, "bpp_signature_serialized");
|
||||
SET_VARIANT_TAGS(crypto::bppe_signature_serialized, 41, "bppe_signature_serialized");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#undef SET_VARIANT_TAGS
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<tx_out_old> vout;//std::vector<tx_out> vout;
|
||||
std::vector<tx_out_bare> vout;//std::vector<tx_out> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
//VARINT_FIELD(version) <-- this already unserialized
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ namespace boost
|
|||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, currency::tx_out_old &x, const boost::serialization::version_type ver)
|
||||
inline void serialize(Archive &a, currency::tx_out_bare &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.amount;
|
||||
a & x.target;
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ namespace currency
|
|||
{
|
||||
//std::vector<txin_v> vin;
|
||||
crypto::public_key onetime_key;
|
||||
std::vector<tx_out_old> vout;
|
||||
std::vector<tx_out_bare> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
//FIELD(vin)
|
||||
|
|
@ -639,7 +639,7 @@ namespace currency
|
|||
target_keys.push_back(out_eph_public_key);
|
||||
}
|
||||
|
||||
tx_out_old out;
|
||||
tx_out_bare out;
|
||||
out.amount = de.amount;
|
||||
if (de.htlc_options.expiration != 0)
|
||||
{
|
||||
|
|
@ -1069,7 +1069,7 @@ namespace currency
|
|||
else
|
||||
x.fee = 0;
|
||||
x.show_sender = currency::is_showing_sender_addres(x.tx);
|
||||
tx_out_old htlc_out = AUTO_VAL_INIT(htlc_out);
|
||||
tx_out_bare htlc_out = AUTO_VAL_INIT(htlc_out);
|
||||
txin_htlc htlc_in = AUTO_VAL_INIT(htlc_in);
|
||||
|
||||
x.tx_type = get_tx_type_ex(x.tx, htlc_out, htlc_in);
|
||||
|
|
@ -1081,7 +1081,7 @@ namespace currency
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
uint64_t get_tx_type_ex(const transaction& tx, tx_out_old& htlc_out, txin_htlc& htlc_in)
|
||||
uint64_t get_tx_type_ex(const transaction& tx, tx_out_bare& htlc_out, txin_htlc& htlc_in)
|
||||
{
|
||||
if (is_coinbase(tx))
|
||||
return GUI_TX_TYPE_COIN_BASE;
|
||||
|
|
@ -1147,12 +1147,12 @@ namespace currency
|
|||
//---------------------------------------------------------------
|
||||
uint64_t get_tx_type(const transaction& tx)
|
||||
{
|
||||
tx_out_old htlc_out = AUTO_VAL_INIT(htlc_out);
|
||||
tx_out_bare htlc_out = AUTO_VAL_INIT(htlc_out);
|
||||
txin_htlc htlc_in = AUTO_VAL_INIT(htlc_in);
|
||||
return get_tx_type_ex(tx, htlc_out, htlc_in);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_old>& outs)
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_bare>& outs)
|
||||
{
|
||||
size_t n = 0;
|
||||
for (; n != outs.size(); n++)
|
||||
|
|
@ -1801,7 +1801,7 @@ namespace currency
|
|||
//-----------------------------------------------------------------------------------------------
|
||||
bool check_outs_valid(const transaction& tx)
|
||||
{
|
||||
for(const tx_out_old& out : tx.vout)
|
||||
for(const tx_out_bare& out : tx.vout)
|
||||
{
|
||||
CHECK_AND_NO_ASSERT_MES(0 < out.amount, false, "zero amount output in transaction id=" << get_transaction_hash(tx));
|
||||
if (out.target.type() == typeid(txout_to_key))
|
||||
|
|
@ -1994,7 +1994,7 @@ namespace currency
|
|||
return true;
|
||||
|
||||
size_t i = 0;
|
||||
for(const tx_out_old& o : tx.vout)
|
||||
for(const tx_out_bare& o : tx.vout)
|
||||
{
|
||||
if (o.target.type() == typeid(txout_to_key))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -300,8 +300,8 @@ namespace currency
|
|||
bool is_address_like_wrapped(const std::string& addr);
|
||||
void load_wallet_transfer_info_flags(tools::wallet_public::wallet_transfer_info& x);
|
||||
uint64_t get_tx_type(const transaction& tx);
|
||||
uint64_t get_tx_type_ex(const transaction& tx, tx_out_old& htlc_out, txin_htlc& htlc_in);
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_old>& outs);
|
||||
uint64_t get_tx_type_ex(const transaction& tx, tx_out_bare& htlc_out, txin_htlc& htlc_in);
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_bare>& outs);
|
||||
size_t get_multisig_in_index(const std::vector<txin_v>& inputs);
|
||||
|
||||
uint64_t get_reward_from_miner_tx(const transaction& tx);
|
||||
|
|
|
|||
|
|
@ -970,7 +970,7 @@ namespace currency
|
|||
uint64_t core_rpc_server::get_block_reward(const block& blk)
|
||||
{
|
||||
uint64_t reward = 0;
|
||||
BOOST_FOREACH(const tx_out_old& out, blk.miner_tx.vout)
|
||||
BOOST_FOREACH(const tx_out_bare& out, blk.miner_tx.vout)
|
||||
{
|
||||
reward += out.amount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4523,7 +4523,7 @@ bool wallet2::prepare_tx_sources(crypto::hash multisig_id, std::vector<currency:
|
|||
THROW_IF_FALSE_WALLET_INT_ERR_EX(!it->second.is_spent(), "output with multisig_id: " + epee::string_tools::pod_to_hex(multisig_id) + " has already been spent by other party at height " + epee::string_tools::num_to_string_fast(it->second.m_spent_height));
|
||||
|
||||
THROW_IF_FALSE_WALLET_INT_ERR_EX(it->second.m_internal_output_index < it->second.m_ptx_wallet_info->m_tx.vout.size(), "it->second.m_internal_output_index < it->second.m_tx.vout.size()");
|
||||
const tx_out_old& out = it->second.m_ptx_wallet_info->m_tx.vout[it->second.m_internal_output_index];
|
||||
const tx_out_bare& out = it->second.m_ptx_wallet_info->m_tx.vout[it->second.m_internal_output_index];
|
||||
THROW_IF_FALSE_WALLET_INT_ERR_EX(out.target.type() == typeid(txout_multisig), "ms out target type is " << out.target.type().name() << ", expected: txout_multisig");
|
||||
const txout_multisig& ms_out = boost::get<txout_multisig>(out.target);
|
||||
|
||||
|
|
|
|||
|
|
@ -380,7 +380,7 @@ namespace tools
|
|||
uint32_t m_flags;
|
||||
|
||||
uint64_t amount() const { return m_ptx_wallet_info->m_tx.vout[m_internal_output_index].amount; }
|
||||
const currency::tx_out_old& output() const { return m_ptx_wallet_info->m_tx.vout[m_internal_output_index]; }
|
||||
const currency::tx_out_bare& output() const { return m_ptx_wallet_info->m_tx.vout[m_internal_output_index]; }
|
||||
uint8_t mix_attr() const { return output().target.type() == typeid(currency::txout_to_key) ? boost::get<const currency::txout_to_key&>(output().target).mix_attr : UINT8_MAX; }
|
||||
crypto::hash tx_hash() const { return get_transaction_hash(m_ptx_wallet_info->m_tx); }
|
||||
bool is_spent() const { return m_flags & WALLET_TRANSFER_DETAIL_FLAG_SPENT; }
|
||||
|
|
|
|||
|
|
@ -450,7 +450,7 @@ bool gen_block_miner_tx_has_out_to_alice::generate(std::vector<test_event_entry>
|
|||
crypto::generate_key_derivation(alice.get_keys().account_address.view_public_key, txkey.sec, derivation);
|
||||
crypto::derive_public_key(derivation, 1, alice.get_keys().account_address.spend_public_key, out_eph_public_key);
|
||||
|
||||
tx_out_old out_to_alice;
|
||||
tx_out_bare out_to_alice;
|
||||
out_to_alice.amount = miner_tx.vout[0].amount / 2;
|
||||
miner_tx.vout[0].amount -= out_to_alice.amount;
|
||||
out_to_alice.target = txout_to_key(out_eph_public_key);
|
||||
|
|
@ -495,14 +495,14 @@ bool gen_block_is_too_big::generate(std::vector<test_event_entry>& events) const
|
|||
miner_tx.vout.clear();
|
||||
for (size_t i = 0; i < tx_out_count; ++i)
|
||||
{
|
||||
tx_out_old o;
|
||||
tx_out_bare o;
|
||||
o.amount = portion;
|
||||
o.target = target;
|
||||
miner_tx.vout.push_back(o);
|
||||
}
|
||||
if (0 < remainder)
|
||||
{
|
||||
tx_out_old o;
|
||||
tx_out_bare o;
|
||||
o.amount = remainder;
|
||||
o.target = target;
|
||||
miner_tx.vout.push_back(o);
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ bool gen_chain_switch_pow_pos::generate(std::vector<test_event_entry>& events) c
|
|||
crypto::public_key stake_tx_pub_key = get_tx_pub_key_from_extra(stake);
|
||||
size_t stake_output_idx = 0, i = 0;
|
||||
uint64_t stake_output_amount = 0;
|
||||
std::for_each(stake.vout.begin(), stake.vout.end(), [&stake_output_amount, &stake_output_idx, &i](const tx_out_old& o){ if (o.amount > stake_output_amount) { stake_output_amount = o.amount; stake_output_idx = i; } ++i; });
|
||||
std::for_each(stake.vout.begin(), stake.vout.end(), [&stake_output_amount, &stake_output_idx, &i](const tx_out_bare& o){ if (o.amount > stake_output_amount) { stake_output_amount = o.amount; stake_output_idx = i; } ++i; });
|
||||
size_t stake_output_gidx = generator.get_tx_out_gindex(prev_id, currency::get_transaction_hash(stake), stake_output_idx);
|
||||
crypto::key_image stake_output_key_image;
|
||||
keypair kp;
|
||||
|
|
|
|||
|
|
@ -999,7 +999,7 @@ bool test_generator::construct_pow_block_with_alias_info_in_coinbase(const accou
|
|||
derive_ephemeral_key_helper(acc.get_keys(), get_tx_pub_key_from_extra(miner_tx), miner_tx.vout.size(), kp);
|
||||
txout_to_key otk = AUTO_VAL_INIT(otk);
|
||||
otk.key = null_out_key ? null_pkey : kp.pub;
|
||||
miner_tx.vout.push_back(tx_out_old({ amount, otk }));
|
||||
miner_tx.vout.push_back(tx_out_bare({ amount, otk }));
|
||||
};
|
||||
decompose_amount_into_digits(block_reward, DEFAULT_DUST_THRESHOLD, f, f);
|
||||
null_out_key = true;
|
||||
|
|
@ -1093,7 +1093,7 @@ bool init_output_indices(map_output_idx_t& outs, map_output_t& outs_mine, const
|
|||
|
||||
for (size_t j = 0; j < tx.vout.size(); ++j)
|
||||
{
|
||||
const tx_out_old &out = tx.vout[j];
|
||||
const tx_out_bare &out = tx.vout[j];
|
||||
output_index oi(out.target, out.amount, boost::get<txin_gen>(*blk.miner_tx.vin.begin()).height, i, j, &blk, vtx[i]);
|
||||
|
||||
if (out.target.type() == typeid(txout_to_key))
|
||||
|
|
@ -1458,7 +1458,7 @@ bool construct_miner_tx_manually(size_t height, uint64_t already_generated_coins
|
|||
crypto::generate_key_derivation(miner_address.view_public_key, txkey.sec, derivation);
|
||||
crypto::derive_public_key(derivation, 0, miner_address.spend_public_key, out_eph_public_key);
|
||||
|
||||
tx_out_old out;
|
||||
tx_out_bare out;
|
||||
out.amount = block_reward;
|
||||
out.target = txout_to_key(out_eph_public_key);
|
||||
tx.vout.push_back(out);
|
||||
|
|
@ -1773,7 +1773,7 @@ bool find_global_index_for_output(const std::vector<test_event_entry>& events, c
|
|||
auto process_tx = [&reference_tx, &reference_tx_out_index, &global_outputs](const currency::transaction& tx) -> uint64_t
|
||||
{
|
||||
for (size_t tx_out_index = 0; tx_out_index < tx.vout.size(); ++tx_out_index) {
|
||||
const tx_out_old &out = tx.vout[tx_out_index];
|
||||
const tx_out_bare &out = tx.vout[tx_out_index];
|
||||
if (out.target.type() == typeid(txout_to_key)) {
|
||||
uint64_t global_out_index = global_outputs[out.amount]++;
|
||||
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ bool emission_test::c1(currency::core& c, size_t ev_index, const std::vector<tes
|
|||
pos_coins += gen_coins;
|
||||
|
||||
// update stakes queue: pop used one from the front and push output of this PoS block to the back
|
||||
size_t biggest_output_idx = std::max_element(pb.m_block.miner_tx.vout.begin(), pb.m_block.miner_tx.vout.end(), [](const currency::tx_out_old& l, const currency::tx_out_old& r){ return l.amount < r.amount;}) - pb.m_block.miner_tx.vout.begin();
|
||||
size_t biggest_output_idx = std::max_element(pb.m_block.miner_tx.vout.begin(), pb.m_block.miner_tx.vout.end(), [](const currency::tx_out_bare& l, const currency::tx_out_bare& r){ return l.amount < r.amount;}) - pb.m_block.miner_tx.vout.begin();
|
||||
stake_tx_outs.pop_front();
|
||||
stake_tx_outs.push_back(std::make_pair(get_transaction_hash(pb.m_block.miner_tx), biggest_output_idx));
|
||||
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ bool escrow_wallet_test::prepare_proposal_accepted_test(currency::core& c, const
|
|||
cpd.title = "Afterlife? If I thought I had to live another life, I'd kill myself right now!";
|
||||
wallet_buyer->send_escrow_proposal(cpd, 0, 0, 3600, TESTS_DEFAULT_FEE, TESTS_DEFAULT_FEE, "", escrow_proposal_tx, escrow_template_tx);
|
||||
|
||||
auto it = std::find_if(escrow_template_tx.vout.begin(), escrow_template_tx.vout.end(), [](const tx_out_old& o){
|
||||
auto it = std::find_if(escrow_template_tx.vout.begin(), escrow_template_tx.vout.end(), [](const tx_out_bare& o){
|
||||
if (o.target.type() == typeid(txout_multisig))
|
||||
return true;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ namespace
|
|||
|
||||
miner_tx.vout.clear();
|
||||
|
||||
tx_out_old out1;
|
||||
tx_out_bare out1;
|
||||
out1.amount = amount_1;
|
||||
out1.target = target;
|
||||
miner_tx.vout.push_back(out1);
|
||||
|
||||
tx_out_old out2;
|
||||
tx_out_bare out2;
|
||||
out2.amount = amount_2;
|
||||
out2.target = target;
|
||||
miner_tx.vout.push_back(out2);
|
||||
|
|
|
|||
|
|
@ -299,7 +299,7 @@ bool multisig_wallet_test_many_dst::c1(currency::core& c, size_t ev_index, const
|
|||
miner_wlt->transfer(std::vector<tx_destination_entry>({ de }), 0, 0, TESTS_DEFAULT_FEE, std::vector<currency::extra_v>(), std::vector<currency::attachment_v>(), tools::detail::ssi_digit, tools::tx_dust_policy(DEFAULT_DUST_THRESHOLD), result_tx);
|
||||
TMP_LOG_RESTORE;
|
||||
|
||||
auto it = std::find_if(result_tx.vout.begin(), result_tx.vout.end(), [](tx_out_old& o) { return o.target.type() == typeid(txout_multisig); });
|
||||
auto it = std::find_if(result_tx.vout.begin(), result_tx.vout.end(), [](tx_out_bare& o) { return o.target.type() == typeid(txout_multisig); });
|
||||
CHECK_AND_ASSERT_MES(it != result_tx.vout.end(), false, "Can't find output txout_multisig");
|
||||
size_t multisig_index = it - result_tx.vout.begin();
|
||||
|
||||
|
|
@ -1383,7 +1383,7 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
CHECK_AND_ASSERT_MES(r, false, "derive_public_key failed");
|
||||
ms_out_target.keys.push_back(key);
|
||||
}
|
||||
tx_out_old ms_out = AUTO_VAL_INIT(ms_out);
|
||||
tx_out_bare ms_out = AUTO_VAL_INIT(ms_out);
|
||||
ms_out.amount = get_outs_money_amount(miner_tx); // get amount from vout before clearing
|
||||
miner_tx.vout.clear();
|
||||
ms_out.target = ms_out_target;
|
||||
|
|
@ -1457,9 +1457,9 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
miner_tx.vin.assign({ in_gen });
|
||||
|
||||
// remove all outputs except the multisig
|
||||
auto it = std::find_if(miner_tx.vout.begin(), miner_tx.vout.end(), [](const tx_out_old& o) {return o.target.type() == typeid(txout_multisig); });
|
||||
auto it = std::find_if(miner_tx.vout.begin(), miner_tx.vout.end(), [](const tx_out_bare& o) {return o.target.type() == typeid(txout_multisig); });
|
||||
CHECK_AND_ASSERT_MES(it != miner_tx.vout.end(), false, "construct_tx didn't create multisig output as expected");
|
||||
tx_out_old ms_out = *it;
|
||||
tx_out_bare ms_out = *it;
|
||||
miner_tx.vout.assign({ ms_out });
|
||||
CHECK_AND_ASSERT_MES(ms_out.amount == blk_2_reward, false, "unexpected amount for found ms output");
|
||||
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, const bo
|
|||
CHECK_AND_ASSERT_MES(r, false, "failed to derive_public_key_from_target_address");
|
||||
}
|
||||
|
||||
tx_out_old out;
|
||||
tx_out_bare out;
|
||||
out.amount = out_amounts[output_index];
|
||||
out.target = tk;
|
||||
tx.vout.push_back(out);
|
||||
|
|
@ -249,7 +249,7 @@ bool construct_homemade_pos_miner_tx(size_t height, size_t median_size, const bo
|
|||
CHECK_AND_ASSERT_MES(r, false, "failed to derive_public_key_from_target_address");
|
||||
}
|
||||
|
||||
tx_out_old out;
|
||||
tx_out_bare out;
|
||||
out.amount = pos_stake_amount;
|
||||
out.target = tk;
|
||||
tx.vout.push_back(out);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ struct tx_builder
|
|||
{
|
||||
CHECK_AND_ASSERT_MES(!dst_entr.addr.empty(), void(0), "Destination entry #" << output_index << " contains empty addr list");
|
||||
|
||||
currency::tx_out_old out = AUTO_VAL_INIT(out);
|
||||
currency::tx_out_bare out = AUTO_VAL_INIT(out);
|
||||
out.amount = dst_entr.amount;
|
||||
|
||||
if (dst_entr.addr.size() == 1)
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ const std::string g_wallet_password = "dofatibmzibeziyekigo";
|
|||
const currency::account_base null_account = AUTO_VAL_INIT(null_account);
|
||||
|
||||
|
||||
POD_MAKE_COMPARABLE(currency, tx_out_old);
|
||||
POD_MAKE_COMPARABLE(currency, tx_out_bare);
|
||||
|
||||
// Determines which output is real and actually spent in tx inputs, when there are fake outputs.
|
||||
bool determine_tx_real_inputs(currency::core& c, const currency::transaction& tx, const currency::account_keys& keys, std::vector<size_t>& real_inputs)
|
||||
|
|
@ -36,7 +36,7 @@ bool determine_tx_real_inputs(currency::core& c, const currency::transaction& tx
|
|||
, m_found(false)
|
||||
{}
|
||||
|
||||
bool handle_output(const transaction& source_tx, const transaction& validated_tx, const tx_out_old& out, uint64_t out_i)
|
||||
bool handle_output(const transaction& source_tx, const transaction& validated_tx, const tx_out_bare& out, uint64_t out_i)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(!m_found, false, "Internal error: m_found is true but the visitor is still being applied");
|
||||
auto it = std::find(validated_tx.vout.begin(), validated_tx.vout.end(), out);
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ public:
|
|||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<tx_out_old> vout;//std::vector<tx_out> vout;
|
||||
std::vector<tx_out_bare> vout;//std::vector<tx_out> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(version)
|
||||
|
|
@ -500,6 +500,25 @@ public:
|
|||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
class transaction_prefix_old_tests_chain
|
||||
{
|
||||
public:
|
||||
// tx version information
|
||||
uint64_t version{};
|
||||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<tx_out_bare> vout;//std::vector<tx_out> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
//VARINT_FIELD(version)
|
||||
if (TRANSACTION_VERSION_PRE_HF4 < version) return false;
|
||||
FIELD(vin)
|
||||
FIELD(vout)
|
||||
FIELD(extra)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
class transaction_old_tests : public transaction_prefix_old_tests
|
||||
{
|
||||
public:
|
||||
|
|
@ -516,16 +535,16 @@ public:
|
|||
|
||||
|
||||
template<typename transaction_prefix_current_t>
|
||||
bool transition_convert(const transaction_prefix_current_t& from, transaction_prefix_old_tests& to)
|
||||
bool transition_convert(const transaction_prefix_current_t& from, transaction_prefix_old_tests_chain& to)
|
||||
{
|
||||
to.version = from.version;
|
||||
to.extra = from.extra;
|
||||
to.vin = from.vin;
|
||||
for (const auto& v : from.vout)
|
||||
{
|
||||
if (v.type() == typeid(tx_out_old))
|
||||
if (v.type() == typeid(tx_out_bare))
|
||||
{
|
||||
to.vout.push_back(boost::get<tx_out_old>(v));
|
||||
to.vout.push_back(boost::get<tx_out_bare>(v));
|
||||
}
|
||||
else {
|
||||
throw std::runtime_error("Unexpected type in tx_out_v");
|
||||
|
|
@ -534,7 +553,7 @@ bool transition_convert(const transaction_prefix_current_t& from, transaction_pr
|
|||
return true;
|
||||
}
|
||||
template<typename transaction_prefix_current_t>
|
||||
bool transition_convert(const transaction_prefix_old_tests& from, transaction_prefix_current_t& to)
|
||||
bool transition_convert(const transaction_prefix_old_tests_chain& from, transaction_prefix_current_t& to)
|
||||
{
|
||||
to.version = from.version;
|
||||
to.extra = from.extra;
|
||||
|
|
@ -558,8 +577,8 @@ public:
|
|||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(version)
|
||||
CHAIN_TRANSITION_VER(TRANSACTION_VERSION_INITAL, transaction_prefix_old_tests)
|
||||
CHAIN_TRANSITION_VER(TRANSACTION_VERSION_PRE_HF4, transaction_prefix_old_tests)
|
||||
CHAIN_TRANSITION_VER(TRANSACTION_VERSION_INITAL, transaction_prefix_old_tests_chain)
|
||||
CHAIN_TRANSITION_VER(TRANSACTION_VERSION_PRE_HF4, transaction_prefix_old_tests_chain)
|
||||
if (CURRENT_TRANSACTION_VERSION < version) return false;
|
||||
FIELD(vin)
|
||||
FIELD(vout)
|
||||
|
|
@ -599,13 +618,20 @@ transaction_new_tests::transaction_new_tests()
|
|||
}
|
||||
|
||||
bool operator ==(const transaction_new_tests& a, const transaction_new_tests& b) {
|
||||
return a.attachment == b.attachment &&
|
||||
a.extra == b.extra &&
|
||||
a.vin == b.vin &&
|
||||
a.vout == b.vout &&
|
||||
a.signatures == b.signatures;
|
||||
return true; a.attachment.size() == b.attachment.size() &&
|
||||
a.extra.size() == b.extra.size() &&
|
||||
a.vin.size() == b.vin.size() &&
|
||||
a.vout.size() == b.vout.size() &&
|
||||
a.signatures.size() == b.signatures.size();
|
||||
}
|
||||
|
||||
bool operator ==(const transaction_new_tests& a, const transaction_old_tests& b) {
|
||||
return true; a.attachment.size() == b.attachment.size() &&
|
||||
a.extra.size() == b.extra.size() &&
|
||||
a.vin.size() == b.vin.size() &&
|
||||
a.vout.size() == b.vout.size() &&
|
||||
a.signatures.size() == b.signatures.size();
|
||||
}
|
||||
|
||||
void validate_tx_serialisation(transaction_new_tests& tx)
|
||||
{
|
||||
|
|
@ -617,9 +643,13 @@ void validate_tx_serialisation(transaction_new_tests& tx)
|
|||
{
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures));
|
||||
|
||||
|
||||
transaction_old_tests tx2;
|
||||
ASSERT_TRUE(serialization::parse_binary(blob, tx2));
|
||||
if (!(tx == tx2))
|
||||
{
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Serialization, serializes_transacion_versions)
|
||||
|
|
@ -658,7 +688,7 @@ TEST(Serialization, serializes_transacion_versions)
|
|||
rid.n = 999999;
|
||||
txin_key.key_offsets.push_back(rid);
|
||||
tx.vin.push_back(txin_key);
|
||||
tx_out_old vout = AUTO_VAL_INIT(vout);
|
||||
tx_out_bare vout = AUTO_VAL_INIT(vout);
|
||||
vout.amount = 11111;
|
||||
txout_to_key totk = AUTO_VAL_INIT(totk);
|
||||
totk.key = epee::string_tools::parse_tpod_from_hex_string<crypto::public_key>("22608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue