forked from lthn/blockchain
trasaction binary versions transaction implementation
This commit is contained in:
parent
cfb9b463d7
commit
240b5808b9
22 changed files with 224 additions and 43 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& out, uint64_t out_i)
|
||||
bool handle_output(const transaction& source_tx, const transaction& validated_tx, const tx_out_old& 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& source_tx_out = source_tx.vout[out_n];
|
||||
const tx_out_old& 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& out = tx.vout[out_n];
|
||||
const tx_out_old& 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);
|
||||
|
|
|
|||
|
|
@ -283,7 +283,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
|
||||
struct tx_out_old
|
||||
{
|
||||
uint64_t amount;
|
||||
txout_target_v target;
|
||||
|
|
@ -318,7 +318,7 @@ namespace currency
|
|||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
typedef boost::variant<tx_out, tx_out_zarcanum> tx_out_v;
|
||||
typedef boost::variant<tx_out_old, tx_out_zarcanum> tx_out_v;
|
||||
|
||||
|
||||
struct tx_comment
|
||||
|
|
@ -595,21 +595,25 @@ namespace currency
|
|||
typedef payload_items_v attachment_v;
|
||||
|
||||
|
||||
//include backward compatibility defintions
|
||||
#include "currency_basic_backward_comp.inl"
|
||||
|
||||
class transaction_prefix
|
||||
{
|
||||
public:
|
||||
// tx version information
|
||||
uint64_t version{};
|
||||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<tx_out> vout;//std::vector<tx_out> vout;
|
||||
std::vector<tx_out_old> vout;//std::vector<tx_out> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
VARINT_FIELD(version)
|
||||
CHAIN_TRANSITION_VER(TRANSACTION_VERSION_INITAL, transaction_prefix_v1)
|
||||
CHAIN_TRANSITION_VER(TRANSACTION_VERSION_PRE_HF4, transaction_prefix_v1)
|
||||
if(CURRENT_TRANSACTION_VERSION < version) return false;
|
||||
FIELD(vin)
|
||||
//if(version <= 1)
|
||||
FIELD(vout)
|
||||
FIELD(extra)
|
||||
END_SERIALIZE()
|
||||
|
|
|
|||
65
src/currency_core/currency_basic_backward_comp.inl
Normal file
65
src/currency_core/currency_basic_backward_comp.inl
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
// Copyright (c) 2014-2022 Zano Project
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
|
||||
|
||||
class transaction_prefix_v1
|
||||
{
|
||||
public:
|
||||
// tx version information
|
||||
uint64_t version{};
|
||||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<tx_out_old> vout;//std::vector<tx_out> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
//VARINT_FIELD(version) <-- this already unserialized
|
||||
if (TRANSACTION_VERSION_PRE_HF4 < version) return false;
|
||||
FIELD(vin)
|
||||
FIELD(vout)
|
||||
FIELD(extra)
|
||||
END_SERIALIZE()
|
||||
};
|
||||
/*
|
||||
class transaction_prefix_v1_full
|
||||
{
|
||||
public:
|
||||
// tx version information
|
||||
uint64_t version{};
|
||||
//extra
|
||||
std::vector<extra_v> extra;
|
||||
std::vector<txin_v> vin;
|
||||
std::vector<tx_out_old> 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()
|
||||
};
|
||||
*/
|
||||
|
||||
template<typename transaction_prefix_current_t>
|
||||
bool transition_convert(const transaction_prefix_current_t& from, transaction_prefix_v1& to)
|
||||
{
|
||||
to.version = from.version;
|
||||
to.extra = from.extra;
|
||||
to.vin = from.vin;
|
||||
to.vout = from.vout;
|
||||
return true;
|
||||
}
|
||||
template<typename transaction_prefix_current_t>
|
||||
bool transition_convert(const transaction_prefix_v1& from, transaction_prefix_current_t& to)
|
||||
{
|
||||
to.version = from.version;
|
||||
to.extra = from.extra;
|
||||
to.vin = from.vin;
|
||||
to.vout = from.vout;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -104,7 +104,7 @@ namespace boost
|
|||
}
|
||||
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, currency::tx_out &x, const boost::serialization::version_type ver)
|
||||
inline void serialize(Archive &a, currency::tx_out_old &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & x.amount;
|
||||
a & x.target;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#define CURRENCY_PUBLIC_AUDITABLE_INTEG_ADDRESS_BASE58_PREFIX 0x8a49 // auditable integrated addresses start with 'aiZX'
|
||||
#define CURRENCY_MINED_MONEY_UNLOCK_WINDOW 10
|
||||
#define CURRENT_TRANSACTION_VERSION 2
|
||||
#define TRANSACTION_VERSION_INITAL 0
|
||||
#define TRANSACTION_VERSION_PRE_HF4 1
|
||||
#define HF1_BLOCK_MAJOR_VERSION 1
|
||||
#define CURRENT_BLOCK_MAJOR_VERSION 2
|
||||
|
|
|
|||
|
|
@ -511,7 +511,7 @@ namespace currency
|
|||
{
|
||||
//std::vector<txin_v> vin;
|
||||
crypto::public_key onetime_key;
|
||||
std::vector<tx_out> vout;
|
||||
std::vector<tx_out_old> vout;
|
||||
|
||||
BEGIN_SERIALIZE()
|
||||
//FIELD(vin)
|
||||
|
|
@ -637,7 +637,7 @@ namespace currency
|
|||
target_keys.push_back(out_eph_public_key);
|
||||
}
|
||||
|
||||
tx_out out;
|
||||
tx_out_old out;
|
||||
out.amount = de.amount;
|
||||
if (de.htlc_options.expiration != 0)
|
||||
{
|
||||
|
|
@ -1067,7 +1067,7 @@ namespace currency
|
|||
else
|
||||
x.fee = 0;
|
||||
x.show_sender = currency::is_showing_sender_addres(x.tx);
|
||||
tx_out htlc_out = AUTO_VAL_INIT(htlc_out);
|
||||
tx_out_old 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);
|
||||
|
|
@ -1079,7 +1079,7 @@ namespace currency
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
uint64_t get_tx_type_ex(const transaction& tx, tx_out& htlc_out, txin_htlc& htlc_in)
|
||||
uint64_t get_tx_type_ex(const transaction& tx, tx_out_old& htlc_out, txin_htlc& htlc_in)
|
||||
{
|
||||
if (is_coinbase(tx))
|
||||
return GUI_TX_TYPE_COIN_BASE;
|
||||
|
|
@ -1145,12 +1145,12 @@ namespace currency
|
|||
//---------------------------------------------------------------
|
||||
uint64_t get_tx_type(const transaction& tx)
|
||||
{
|
||||
tx_out htlc_out = AUTO_VAL_INIT(htlc_out);
|
||||
tx_out_old 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>& outs)
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_old>& outs)
|
||||
{
|
||||
size_t n = 0;
|
||||
for (; n != outs.size(); n++)
|
||||
|
|
@ -1799,7 +1799,7 @@ namespace currency
|
|||
//-----------------------------------------------------------------------------------------------
|
||||
bool check_outs_valid(const transaction& tx)
|
||||
{
|
||||
for(const tx_out& out : tx.vout)
|
||||
for(const tx_out_old& 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))
|
||||
|
|
@ -1992,7 +1992,7 @@ namespace currency
|
|||
return true;
|
||||
|
||||
size_t i = 0;
|
||||
for(const tx_out& o : tx.vout)
|
||||
for(const tx_out_old& 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& htlc_out, txin_htlc& htlc_in);
|
||||
size_t get_multisig_out_index(const std::vector<tx_out>& outs);
|
||||
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);
|
||||
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& out, blk.miner_tx.vout)
|
||||
BOOST_FOREACH(const tx_out_old& out, blk.miner_tx.vout)
|
||||
{
|
||||
reward += out.amount;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,6 +213,37 @@ std::string t_serializable_object_to_blob(const t_object& to)
|
|||
return b;
|
||||
}
|
||||
|
||||
|
||||
template<bool IsSaving, typename destination_t>
|
||||
struct transition_t {};
|
||||
|
||||
template<typename destination_t>
|
||||
struct transition_t<true, destination_t>
|
||||
{
|
||||
template <typename archive, typename origin_type>
|
||||
static bool chain_serialize(archive &ar, const origin_type& origin_tx)
|
||||
{
|
||||
destination_t dst_tx = AUTO_VAL_INIT(dst_tx);
|
||||
transition_convert(origin_tx, dst_tx);
|
||||
return dst_tx.do_serialize(ar);
|
||||
}
|
||||
};
|
||||
|
||||
template<typename destination_t>
|
||||
struct transition_t<false, destination_t>
|
||||
{
|
||||
template <typename archive, typename origin_type>
|
||||
static bool chain_serialize(archive &ar, origin_type& origin_tx)
|
||||
{
|
||||
destination_t dst_tx = AUTO_VAL_INIT(dst_tx);
|
||||
bool r = dst_tx.do_serialize(ar);
|
||||
if (!r) return r;
|
||||
return transition_convert(dst_tx, origin_tx);
|
||||
}
|
||||
};
|
||||
|
||||
#define CHAIN_TRANSITION_VER(tx_version, old_type) if (tx_version == version) return transition_t<W, old_type>::chain_serialize(ar, *this);
|
||||
|
||||
#include "serialize_basic_types.h"
|
||||
#include "string.h"
|
||||
#include "multiprecision.h"
|
||||
|
|
|
|||
|
|
@ -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& out = it->second.m_ptx_wallet_info->m_tx.vout[it->second.m_internal_output_index];
|
||||
const tx_out_old& 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& output() const { return m_ptx_wallet_info->m_tx.vout[m_internal_output_index]; }
|
||||
const currency::tx_out_old& 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 out_to_alice;
|
||||
tx_out_old 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 o;
|
||||
tx_out_old o;
|
||||
o.amount = portion;
|
||||
o.target = target;
|
||||
miner_tx.vout.push_back(o);
|
||||
}
|
||||
if (0 < remainder)
|
||||
{
|
||||
tx_out o;
|
||||
tx_out_old 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& 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_old& 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({ amount, otk }));
|
||||
miner_tx.vout.push_back(tx_out_old({ 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 &out = tx.vout[j];
|
||||
const tx_out_old &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 out;
|
||||
tx_out_old 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 &out = tx.vout[tx_out_index];
|
||||
const tx_out_old &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& l, const currency::tx_out& 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_old& l, const currency::tx_out_old& 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& o){
|
||||
auto it = std::find_if(escrow_template_tx.vout.begin(), escrow_template_tx.vout.end(), [](const tx_out_old& o){
|
||||
if (o.target.type() == typeid(txout_multisig))
|
||||
return true;
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -25,12 +25,12 @@ namespace
|
|||
|
||||
miner_tx.vout.clear();
|
||||
|
||||
tx_out out1;
|
||||
tx_out_old out1;
|
||||
out1.amount = amount_1;
|
||||
out1.target = target;
|
||||
miner_tx.vout.push_back(out1);
|
||||
|
||||
tx_out out2;
|
||||
tx_out_old 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& o) { return o.target.type() == typeid(txout_multisig); });
|
||||
auto it = std::find_if(result_tx.vout.begin(), result_tx.vout.end(), [](tx_out_old& 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 ms_out = AUTO_VAL_INIT(ms_out);
|
||||
tx_out_old 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& o) {return o.target.type() == typeid(txout_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); });
|
||||
CHECK_AND_ASSERT_MES(it != miner_tx.vout.end(), false, "construct_tx didn't create multisig output as expected");
|
||||
tx_out ms_out = *it;
|
||||
tx_out_old 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 out;
|
||||
tx_out_old 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 out;
|
||||
tx_out_old 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 out = AUTO_VAL_INIT(out);
|
||||
currency::tx_out_old 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);
|
||||
POD_MAKE_COMPARABLE(currency, tx_out_old);
|
||||
|
||||
// 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& out, uint64_t out_i)
|
||||
bool handle_output(const transaction& source_tx, const transaction& validated_tx, const tx_out_old& 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);
|
||||
|
|
|
|||
|
|
@ -478,3 +478,83 @@ TEST(Serialization, serializes_transacion_signatures_correctly)
|
|||
ASSERT_FALSE(serialization::parse_binary(blob, tx1));
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
void validate_tx_serialisation(currency::transaction& tx)
|
||||
{
|
||||
currency::transaction tx1;
|
||||
string blob;
|
||||
ASSERT_TRUE(serialization::dump_binary(tx, blob));
|
||||
ASSERT_TRUE(serialization::parse_binary(blob, tx1));
|
||||
if (!(tx == tx1))
|
||||
{
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures));
|
||||
}
|
||||
|
||||
TEST(Serialization, serializes_transacion_versions)
|
||||
{
|
||||
|
||||
using namespace currency;
|
||||
|
||||
transaction tx;
|
||||
|
||||
|
||||
// Empty tx
|
||||
/*
|
||||
tx = AUTO_VAL_INIT(tx);
|
||||
ASSERT_TRUE(serialization::dump_binary(tx, blob));
|
||||
ASSERT_EQ(6, blob.size()); // 5 bytes + 0 bytes extra + 0 bytes signatures
|
||||
ASSERT_TRUE(serialization::parse_binary(blob, tx1));
|
||||
if (!(tx == tx1))
|
||||
{
|
||||
ASSERT_TRUE(false);
|
||||
}
|
||||
ASSERT_EQ(linearize_vector2(tx.signatures), linearize_vector2(tx1.signatures));
|
||||
*/
|
||||
|
||||
txin_gen txin_gen1;
|
||||
txin_gen1.height = 0;
|
||||
tx.vin.push_back(txin_gen1);
|
||||
txin_to_key txin_key = AUTO_VAL_INIT(txin_key);
|
||||
txin_key.amount = 11111;
|
||||
txin_key.k_image = epee::string_tools::parse_tpod_from_hex_string<crypto::key_image>("cc608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852");
|
||||
signed_parts sp = { 1, 2 };
|
||||
txin_key.etc_details.push_back(sp);
|
||||
ref_by_id rid = AUTO_VAL_INIT(rid);
|
||||
rid.tx_id = epee::string_tools::parse_tpod_from_hex_string<crypto::hash>("11608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852");
|
||||
rid.n = 99999999;
|
||||
txin_key.key_offsets.push_back(rid);
|
||||
rid.n = 999999;
|
||||
txin_key.key_offsets.push_back(rid);
|
||||
tx.vin.push_back(txin_key);
|
||||
tx_out_old 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");
|
||||
totk.mix_attr = 22;
|
||||
vout.target = totk;
|
||||
tx.vout.push_back(vout);
|
||||
tx.vout.push_back(vout);
|
||||
|
||||
tx_comment c;
|
||||
c.comment = "sdcwdcwcewdcecevthbtg";
|
||||
tx.extra.push_back(c);
|
||||
extra_alias_entry eae = AUTO_VAL_INIT(eae);
|
||||
currency::get_account_address_from_str(eae.m_address, "ZxDcDWmA7Yj32srfjMHAY6WPzBB8uqpvzKxEsAjDZU6NRg1yZsRfmr87mLXCvMRHXd5n2kdRWhbqA3WWTbEW4jLd1XxL46tnv");
|
||||
eae.m_alias = "eokcmeockme";
|
||||
eae.m_text_comment = "sdssccsc";
|
||||
tx.extra.push_back(eae);
|
||||
tx.signatures.resize(2);
|
||||
crypto::signature sig = epee::string_tools::parse_tpod_from_hex_string<crypto::signature>("22608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab9985222608f59f8080e2fbfe3c8c80eb6e6a953d47cf2d6aebd345bada3a1cab99852");
|
||||
tx.signatures[0].push_back(sig);
|
||||
tx.signatures[0].push_back(sig);
|
||||
tx.signatures[1].push_back(sig);
|
||||
tx.signatures[1].push_back(sig);
|
||||
|
||||
tx.version = TRANSACTION_VERSION_INITAL;
|
||||
|
||||
validate_tx_serialisation(tx);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue