forked from lthn/blockchain
fixed all core tests
This commit is contained in:
parent
7162a23dd3
commit
217a54c8b1
27 changed files with 196 additions and 147 deletions
|
|
@ -4526,8 +4526,13 @@ bool blockchain_storage::check_input_signature(const transaction& tx,
|
|||
|
||||
CHECK_AND_ASSERT_MES(tx.signature.type() == typeid(NLSAG_sig), false, "Unexpected type of sig in check_input_signature: " << tx.signature.type().name());
|
||||
auto s = boost::get<NLSAG_sig>(tx.signature).s;
|
||||
CHECK_AND_ASSERT_MES(s.size() > in_index, false, "Failed to check s.size(){" << s.size() << "} > in_index {" << in_index << "}" );
|
||||
const std::vector<crypto::signature>& sig = s[in_index];
|
||||
uint64_t actual_sig_index = in_index;
|
||||
if (is_pos_coinbase(tx))
|
||||
{
|
||||
actual_sig_index = 0;
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(s.size() > actual_sig_index, false, "Failed to check s.size(){" << s.size() << "} > actual_sig_index {" << actual_sig_index << "}" );
|
||||
const std::vector<crypto::signature>& sig = s[actual_sig_index];
|
||||
if (get_tx_flags(tx) & TX_FLAG_SIGNATURE_MODE_SEPARATE)
|
||||
{
|
||||
// check attachments, mentioned directly in this input
|
||||
|
|
@ -4585,7 +4590,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());
|
||||
LOC_CHK(source_tx.vout[out_n].type() != typeid(tx_out_bare), "internal error: out_n==" << out_n << " has unexpected type: " << source_tx.vout[out_n].type().name());
|
||||
LOC_CHK(source_tx.vout[out_n].type() == typeid(tx_out_bare), "internal error: out_n==" << out_n << " has unexpected type: " << source_tx.vout[out_n].type().name());
|
||||
|
||||
const tx_out_bare& source_tx_out = boost::get<tx_out_bare>(source_tx.vout[out_n]);
|
||||
const txout_multisig& source_ms_out_target = boost::get<txout_multisig>(source_tx_out.target);
|
||||
|
|
@ -4697,7 +4702,7 @@ bool blockchain_storage::check_tx_input(const transaction& tx, size_t in_index,
|
|||
auto source_tx_ptr = m_db_transactions.find(source_tx_id);
|
||||
LOC_CHK(source_tx_ptr, "Can't find source transaction");
|
||||
LOC_CHK(source_tx_ptr->tx.vout.size() > n, "ms output index is incorrect, source tx's vout size is " << source_tx_ptr->tx.vout.size());
|
||||
LOC_CHK(source_tx_ptr->tx.vout[n].type() != typeid(tx_out_bare), "internal error: out_n==" << n << " has unexpected type: " << source_tx_ptr->tx.vout[n].type().name());
|
||||
LOC_CHK(source_tx_ptr->tx.vout[n].type() == typeid(tx_out_bare), "internal error: out_n==" << n << " has unexpected type: " << source_tx_ptr->tx.vout[n].type().name());
|
||||
LOC_CHK(boost::get<tx_out_bare>(source_tx_ptr->tx.vout[n]).target.type() == typeid(txout_multisig), "ms output has wrong type, txout_multisig expected");
|
||||
LOC_CHK(source_tx_ptr->m_spent_flags.size() > n, "Internal error, m_spent_flags size (" << source_tx_ptr->m_spent_flags.size() << ") less then expected, n: " << n);
|
||||
LOC_CHK(source_tx_ptr->m_spent_flags[n] == false, "Internal error, ms output is already spent"); // should never happen as multisig_ptr->spent_height is checked above
|
||||
|
|
|
|||
|
|
@ -663,6 +663,10 @@ namespace currency
|
|||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(s)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(s)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
struct zarcanum_sig
|
||||
|
|
@ -670,6 +674,9 @@ namespace currency
|
|||
//TODO:
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
struct void_sig
|
||||
|
|
@ -677,9 +684,12 @@ namespace currency
|
|||
//TODO:
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
typedef boost::variant<void_sig, NLSAG_sig, zarcanum_sig> signature_v;
|
||||
typedef boost::variant<NLSAG_sig, void_sig, zarcanum_sig> signature_v;
|
||||
|
||||
|
||||
|
||||
|
|
@ -748,7 +758,7 @@ namespace currency
|
|||
vin.clear();
|
||||
vout.clear();
|
||||
extra.clear();
|
||||
signature = void_sig();
|
||||
signature = NLSAG_sig();
|
||||
attachment.clear();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ public:
|
|||
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;
|
||||
for (const auto& v : from.vout)
|
||||
|
|
@ -64,7 +63,6 @@ bool transition_convert(const transaction_prefix_current_t& from, transaction_pr
|
|||
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;
|
||||
for (const auto& v : from.vout)
|
||||
|
|
|
|||
|
|
@ -1132,7 +1132,7 @@ namespace currency
|
|||
for (auto ov : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(ov);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_htlc))
|
||||
{
|
||||
htlc_out = o;
|
||||
|
|
@ -1158,13 +1158,18 @@ namespace currency
|
|||
return get_tx_type_ex(tx, htlc_out, htlc_in);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_bare>& outs)
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_v>& outs)
|
||||
{
|
||||
size_t n = 0;
|
||||
for (; n != outs.size(); n++)
|
||||
{
|
||||
if (outs[n].target.type() == typeid(txout_multisig))
|
||||
break;
|
||||
VARIANT_SWITCH_BEGIN(outs[n]);
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_multisig))
|
||||
break;
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
|
@ -1278,7 +1283,7 @@ namespace currency
|
|||
{
|
||||
tx.vin.clear();
|
||||
tx.vout.clear();
|
||||
tx.signature.clear();
|
||||
tx.signature = NLSAG_sig();
|
||||
tx.extra = extra;
|
||||
|
||||
tx.version = ftp.tx_version;
|
||||
|
|
@ -1604,9 +1609,9 @@ namespace currency
|
|||
for (auto& out : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(out);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
reward += o.amount;
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -1661,13 +1666,13 @@ namespace currency
|
|||
{
|
||||
|
||||
VARIANT_SWITCH_BEGIN(source_tx.vout[i]);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_multisig) && ms_in.multisig_out_id == get_multisig_out_id(source_tx, i))
|
||||
{
|
||||
ms_out_index = i;
|
||||
break;
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -1826,20 +1831,20 @@ namespace currency
|
|||
{
|
||||
|
||||
VARIANT_SWITCH_BEGIN(vo);
|
||||
VARIANT_CASE(tx_out_bare, out)
|
||||
VARIANT_CASE_CONST(tx_out_bare, out)
|
||||
{
|
||||
CHECK_AND_NO_ASSERT_MES(0 < out.amount, false, "zero amount output in transaction id=" << get_transaction_hash(tx));
|
||||
|
||||
VARIANT_SWITCH_BEGIN(out.target);
|
||||
VARIANT_CASE(txout_to_key, tk)
|
||||
VARIANT_CASE_CONST(txout_to_key, tk)
|
||||
if (!check_key(tk.key))
|
||||
return false;
|
||||
VARIANT_CASE(txout_htlc, htlc)
|
||||
VARIANT_CASE_CONST(txout_htlc, htlc)
|
||||
if (!check_key(htlc.pkey_redeem))
|
||||
return false;
|
||||
if (!check_key(htlc.pkey_refund))
|
||||
return false;
|
||||
VARIANT_CASE(txout_multisig, ms)
|
||||
VARIANT_CASE_CONST(txout_multisig, ms)
|
||||
if (!(ms.keys.size() > 0 && ms.minimum_sigs > 0 && ms.minimum_sigs <= ms.keys.size()))
|
||||
{
|
||||
LOG_ERROR("wrong multisig in transaction id=" << get_transaction_hash(tx));
|
||||
|
|
@ -1850,7 +1855,7 @@ namespace currency
|
|||
<< ", in transaction id=" << get_transaction_hash(tx));
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -1901,11 +1906,11 @@ namespace currency
|
|||
BOOST_FOREACH(const auto& o, tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(o);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (money > o.amount + money)
|
||||
return false;
|
||||
money += o.amount;
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -1918,9 +1923,9 @@ namespace currency
|
|||
for (const auto& o : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(o);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
outputs_amount += o.amount;
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -2034,22 +2039,22 @@ namespace currency
|
|||
for(const auto& ov : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(ov);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(o.target);
|
||||
VARIANT_CASE(txout_to_key, t)
|
||||
VARIANT_CASE_CONST(txout_to_key, t)
|
||||
if (is_out_to_acc(acc, t, derivation, i))
|
||||
{
|
||||
outs.push_back(i);
|
||||
money_transfered += o.amount;
|
||||
}
|
||||
VARIANT_CASE(txout_multisig, t)
|
||||
VARIANT_CASE_CONST(txout_multisig, t)
|
||||
if (is_out_to_acc(acc, t, derivation, i))
|
||||
{
|
||||
outs.push_back(i);
|
||||
//don't count this money
|
||||
}
|
||||
VARIANT_CASE(txout_htlc, htlc)
|
||||
VARIANT_CASE_CONST(txout_htlc, htlc)
|
||||
htlc_info hi = AUTO_VAL_INIT(hi);
|
||||
if (is_out_to_acc(acc, htlc.pkey_redeem, derivation, i))
|
||||
{
|
||||
|
|
@ -2068,7 +2073,7 @@ namespace currency
|
|||
return false;
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
i++;
|
||||
|
|
@ -2542,14 +2547,14 @@ namespace currency
|
|||
for (const auto& out : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(out);
|
||||
VARIANT_CASE(tx_out_bare, out)
|
||||
VARIANT_CASE_CONST(tx_out_bare, out)
|
||||
if (out.target.type() != typeid(txout_to_key))
|
||||
continue;
|
||||
|
||||
const txout_to_key& o = boost::get<txout_to_key>(out.target);
|
||||
if (o.key == null_pkey)
|
||||
found_alias_reward += out.amount;
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
|
||||
|
|
@ -2790,29 +2795,29 @@ namespace currency
|
|||
tei.outs.back().is_spent = ptce ? ptce->m_spent_flags[i] : false;
|
||||
tei.outs.back().global_index = ptce ? ptce->m_global_output_indexes[i] : 0;
|
||||
VARIANT_SWITCH_BEGIN(out);
|
||||
VARIANT_CASE(tx_out_bare, out)
|
||||
VARIANT_CASE_CONST(tx_out_bare, out)
|
||||
{
|
||||
tei.outs.back().amount = out.amount;
|
||||
|
||||
VARIANT_SWITCH_BEGIN(out.target);
|
||||
VARIANT_CASE(txout_to_key, otk)
|
||||
VARIANT_CASE_CONST(txout_to_key, otk)
|
||||
tei.outs.back().pub_keys.push_back(epee::string_tools::pod_to_hex(otk.key));
|
||||
if (otk.mix_attr == CURRENCY_TO_KEY_OUT_FORCED_NO_MIX)
|
||||
tei.outs.back().pub_keys.back() += "(FORCED_NO_MIX)";
|
||||
if (otk.mix_attr >= CURRENCY_TO_KEY_OUT_FORCED_MIX_LOWER_BOUND)
|
||||
tei.outs.back().pub_keys.back() += std::string("(FORCED_MIX_LOWER_BOUND: ") + std::to_string(otk.mix_attr) + ")";
|
||||
VARIANT_CASE(txout_multisig, otm)
|
||||
VARIANT_CASE_CONST(txout_multisig, otm)
|
||||
for (auto& k : otm.keys)
|
||||
{
|
||||
tei.outs.back().pub_keys.push_back(epee::string_tools::pod_to_hex(k));
|
||||
}
|
||||
tei.outs.back().minimum_sigs = otm.minimum_sigs;
|
||||
VARIANT_CASE(txout_htlc, otk)
|
||||
VARIANT_CASE_CONST(txout_htlc, otk)
|
||||
tei.outs.back().pub_keys.push_back(epee::string_tools::pod_to_hex(otk.pkey_redeem) + "(htlc_pkey_redeem)");
|
||||
tei.outs.back().pub_keys.push_back(epee::string_tools::pod_to_hex(otk.pkey_refund) + "(htlc_pkey_refund)");
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
++i;
|
||||
|
|
@ -2923,13 +2928,13 @@ namespace currency
|
|||
for (size_t n = 0; n < tx.vout.size(); ++n)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(tx.vout[n]);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_to_key) || o.target.type() == typeid(txout_htlc))
|
||||
{
|
||||
uint64_t amount = o.amount;
|
||||
gindices[amount] += 1;
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -3024,6 +3029,15 @@ namespace currency
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------
|
||||
bool is_pos_coinbase(const transaction& tx)
|
||||
{
|
||||
bool pos = false;
|
||||
if (!is_coinbase(tx, pos) || !pos)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------------
|
||||
bool is_coinbase(const transaction& tx, bool& pos_coinbase)
|
||||
{
|
||||
if (!is_coinbase(tx))
|
||||
|
|
|
|||
|
|
@ -301,7 +301,7 @@ namespace currency
|
|||
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_bare& htlc_out, txin_htlc& htlc_in);
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_bare>& outs);
|
||||
size_t get_multisig_out_index(const std::vector<tx_out_v>& outs);
|
||||
size_t get_multisig_in_index(const std::vector<txin_v>& inputs);
|
||||
|
||||
uint64_t get_reward_from_miner_tx(const transaction& tx);
|
||||
|
|
@ -418,6 +418,7 @@ namespace currency
|
|||
bool parse_payment_id_from_hex_str(const std::string& payment_id_str, payment_id_t& payment_id);
|
||||
bool is_coinbase(const transaction& tx);
|
||||
bool is_coinbase(const transaction& tx, bool& pos_coinbase);
|
||||
bool is_pos_coinbase(const transaction& tx);
|
||||
bool have_attachment_service_in_container(const std::vector<attachment_v>& av, const std::string& service_id, const std::string& instruction);
|
||||
crypto::hash prepare_prefix_hash_for_sign(const transaction& tx, uint64_t in_index, const crypto::hash& tx_id);
|
||||
|
||||
|
|
@ -699,7 +700,7 @@ namespace currency
|
|||
uint64_t operator()(const txin_gen& i) const {return 0;}
|
||||
};
|
||||
//---------------------------------------------------------------
|
||||
const tx_out_bare& get_tx_out_bare_from_out_v(const tx_out_v& o)
|
||||
inline const tx_out_bare& get_tx_out_bare_from_out_v(const tx_out_v& o)
|
||||
{
|
||||
//this function will throw if type is not matching
|
||||
return boost::get<tx_out_bare>(o);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#include "serialization/serialization.h"
|
||||
#include "currency_format_utils.h"
|
||||
#include "currency_format_utils_abstract.h"
|
||||
#include "variant_helper.h"
|
||||
#include "common/variant_helper.h"
|
||||
|
||||
namespace currency
|
||||
{
|
||||
|
|
@ -44,13 +44,13 @@ namespace currency
|
|||
for (auto& o : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(o);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_to_key))
|
||||
{
|
||||
if (boost::get<txout_to_key>(o.target).key == null_pkey)
|
||||
res += o.amount;
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_CASE_THROW_ON_OTHER();
|
||||
VARIANT_SWITCH_END();
|
||||
|
|
|
|||
|
|
@ -1331,11 +1331,11 @@ namespace currency
|
|||
for (const auto& out : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(out);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_multisig))
|
||||
result.push_back(ms_out_info({ get_multisig_out_id(tx, idx), idx, false }));
|
||||
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_CASE_THROW_ON_OTHER();
|
||||
VARIANT_SWITCH_END();
|
||||
|
|
@ -1355,10 +1355,10 @@ namespace currency
|
|||
for (const auto& out : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(out);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_multisig) && get_multisig_out_id(tx, idx) == multisig_id)
|
||||
return true;
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
++idx;
|
||||
|
|
|
|||
|
|
@ -973,9 +973,9 @@ namespace currency
|
|||
BOOST_FOREACH(const auto& out, blk.miner_tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(out);
|
||||
VARIANT_CASE(tx_out_bare, out)
|
||||
VARIANT_CASE_CONST(tx_out_bare, out)
|
||||
reward += out.amount;
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, out)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ using namespace epee;
|
|||
#endif
|
||||
|
||||
#include "storages/levin_abstract_invoke2.h"
|
||||
#include "common/variant_helper.h"
|
||||
|
||||
using namespace currency;
|
||||
|
||||
|
|
@ -87,14 +88,14 @@ namespace tools
|
|||
{
|
||||
CHECK_AND_ASSERT_THROW_MES(ri < tx.vout.size(), "Internal error: wrong tx transfer details: reciev index=" << ri << " is greater than transaction outputs vector " << tx.vout.size());
|
||||
VARIANT_SWITCH_BEGIN(tx.vout[ri]);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(currency::txout_to_key))
|
||||
{
|
||||
//update unlock_time if needed
|
||||
if (ut2.unlock_time_array[ri] > max_unlock_time)
|
||||
max_unlock_time = ut2.unlock_time_array[ri];
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum);
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o);
|
||||
VARIANT_SWITCH_END();
|
||||
|
||||
}
|
||||
|
|
@ -115,12 +116,12 @@ void wallet2::fill_transfer_details(const currency::transaction& tx, const tools
|
|||
{
|
||||
WLT_CHECK_AND_ASSERT_MES(ri < tx.vout.size(), void(), "Internal error: wrong tx transfer details: reciev index=" << ri << " is greater than transaction outputs vector " << tx.vout.size());
|
||||
VARIANT_SWITCH_BEGIN(tx.vout[ri]);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(currency::txout_to_key))
|
||||
{
|
||||
res_td.rcv.push_back(o.amount);
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum);
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o);
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
|
||||
|
|
@ -478,7 +479,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
|
|||
size_t o = outs[i_in_outs];
|
||||
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(o < tx.vout.size(), "wrong out in transaction: internal index=" << o << ", total_outs=" << tx.vout.size());
|
||||
VARIANT_SWITCH_BEGIN(tx.vout[o]);
|
||||
VARIANT_CASE(tx_out_bare, out)
|
||||
VARIANT_CASE_CONST(tx_out_bare, out)
|
||||
{
|
||||
if (out.target.type() == typeid(txout_to_key) || out.target.type() == typeid(txout_htlc))
|
||||
{
|
||||
|
|
@ -674,7 +675,7 @@ void wallet2::process_new_transaction(const currency::transaction& tx, uint64_t
|
|||
WLT_LOG_L0("Received multisig, multisig out id: " << multisig_id << ", amount: " << tdb.amount() << ", with tx: " << get_transaction_hash(tx));
|
||||
}
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum);
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o);
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -1401,7 +1402,7 @@ void wallet2::unprocess_htlc_triggers_on_block_removed(uint64_t height)
|
|||
tr.m_spent_height = 0;
|
||||
}
|
||||
//re-add to active contracts
|
||||
THROW_IF_FALSE_WALLET_EX(tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index].type() == typeid(tx_out_bare), "Unexprected type of out in unprocess_htlc_triggers_on_block_removed : " << tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index].type().name());
|
||||
WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index].type() == typeid(tx_out_bare), std::string("Unexprected type of out in unprocess_htlc_triggers_on_block_removed : ") + tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index].type().name());
|
||||
auto pair_key = std::make_pair(boost::get<tx_out_bare>(tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index]).amount, tr.m_global_output_index);
|
||||
auto it_active_htlc = m_active_htlcs.find(pair_key);
|
||||
if (it_active_htlc != m_active_htlcs.end())
|
||||
|
|
@ -1467,7 +1468,7 @@ void wallet2::process_htlc_triggers_on_block_added(uint64_t height)
|
|||
CHECK_AND_ASSERT_MES(tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index].type() == typeid(tx_out_bare), void(), "Unexpected type out in process_htlc_triggers_on_block_added: " << tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index].type().name());
|
||||
uint64_t amount = boost::get<tx_out_bare>(tr.m_ptx_wallet_info->m_tx.vout[tr.m_internal_output_index]).amount;
|
||||
|
||||
auto it_active_htlc = m_active_htlcs.find(std::make_pair(, tr.m_global_output_index));
|
||||
auto it_active_htlc = m_active_htlcs.find(std::make_pair(amount, tr.m_global_output_index));
|
||||
if (it_active_htlc == m_active_htlcs.end())
|
||||
{
|
||||
LOG_ERROR("Erasing active htlc(m_active_htlcs), but it seems to be already erased");
|
||||
|
|
@ -3093,7 +3094,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig
|
|||
for (size_t i = 0; i < ft.tx.vout.size(); ++i)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(ft.tx.vout[i]);
|
||||
VARIANT_CASE(tx_out_bare, out)
|
||||
VARIANT_CASE_CONST(tx_out_bare, out)
|
||||
{
|
||||
if (out.target.type() != typeid(txout_to_key))
|
||||
continue;
|
||||
|
|
@ -3117,7 +3118,7 @@ void wallet2::sign_transfer(const std::string& tx_sources_blob, std::string& sig
|
|||
ft.outs_key_images.push_back(make_serializable_pair(static_cast<uint64_t>(i), ki));
|
||||
}
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum);
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o);
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -3484,10 +3485,11 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b,
|
|||
{
|
||||
//@#@ TODO: add proper support of Zarcanum
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(false, "ZRCANUM BLOCKS NOT IMPLEMENTED YET");
|
||||
return false; // to get rid of warning
|
||||
}else
|
||||
{
|
||||
NLSAG_sig& signatures = boost::get<NLSAG_sig>(b.miner_tx.signature);
|
||||
WLT_CHECK_AND_ASSERT_MES(signatures.size() == 1 && signatures[0].size() == txin.key_offsets.size(),
|
||||
WLT_CHECK_AND_ASSERT_MES(signatures.s.size() == 1 && signatures.s[0].size() == txin.key_offsets.size(),
|
||||
false, "Wrong signatures amount in coinbase transacton");
|
||||
|
||||
|
||||
|
|
@ -3515,12 +3517,12 @@ bool wallet2::prepare_and_sign_pos_block(currency::block& b,
|
|||
keys_ptrs,
|
||||
derived_secret_ephemeral_key,
|
||||
0,
|
||||
&signatures[0][0]);
|
||||
&signatures.s[0][0]);
|
||||
|
||||
WLT_LOG_L4("GENERATED RING SIGNATURE: block_id " << block_hash
|
||||
<< "txin.k_image" << txin.k_image
|
||||
<< "key_ptr:" << *keys_ptrs[0]
|
||||
<< "signature:" << signatures[0][0]);
|
||||
<< "signature:" << signatures.s[0][0]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -4554,12 +4556,12 @@ bool wallet2::prepare_tx_sources(size_t fake_outputs_count, std::vector<currency
|
|||
real_oe.first = td.m_global_output_index; // TODO: use ref_by_id when neccessary
|
||||
//@#@
|
||||
VARIANT_SWITCH_BEGIN(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(o);
|
||||
VARIANT_CASE(txout_to_key, o)
|
||||
VARIANT_SWITCH_BEGIN(o.target);
|
||||
VARIANT_CASE_CONST(txout_to_key, o)
|
||||
real_oe.second = o.key;
|
||||
VARIANT_CASE(txout_htlc, htlc)
|
||||
VARIANT_CASE_CONST(txout_htlc, htlc)
|
||||
real_oe.second = htlc.pkey_refund;
|
||||
VARIANT_CASE_OTHER()
|
||||
{
|
||||
|
|
@ -4575,7 +4577,7 @@ bool wallet2::prepare_tx_sources(size_t fake_outputs_count, std::vector<currency
|
|||
src.real_output_in_tx_index = td.m_internal_output_index;
|
||||
print_source_entry(src);
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum);
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o);
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
|
||||
|
|
@ -4622,12 +4624,12 @@ bool wallet2::prepare_tx_sources_htlc(crypto::hash htlc_tx_id, const std::string
|
|||
WLT_THROW_IF_FALSE_WITH_CODE(m_transfers.size() > it->second,
|
||||
"Internal error: index in m_active_htlcs_txid <" << it->second << "> is bigger then size of m_transfers <" << m_transfers.size() << ">", API_RETURN_CODE_INTERNAL_ERROR);
|
||||
|
||||
const transfer_details& td = m_transfers[it->second];
|
||||
//@#@
|
||||
WLT_THROW_IF_FALSE_WITH_CODE(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type() == typeid(tx_out_bare),
|
||||
"Unexpected out type in prepare_tx_sources_htlc:" << td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type().name());
|
||||
"Unexpected out type in prepare_tx_sources_htlc:" << td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].type().name(), API_RETURN_CODE_INTERNAL_ERROR);
|
||||
|
||||
const tx_out_bare& out_bare = boost::get<tx_out_bare>(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]);
|
||||
const transfer_details& td = m_transfers[it->second];
|
||||
WLT_THROW_IF_FALSE_WITH_CODE(out_bare.target.type() == typeid(txout_htlc),
|
||||
"Unexpected type in active htlc", API_RETURN_CODE_INTERNAL_ERROR);
|
||||
|
||||
|
|
@ -5015,7 +5017,7 @@ bool wallet2::is_transfer_able_to_go(const transfer_details& td, uint64_t fake_o
|
|||
if (!td.is_spendable())
|
||||
return false;
|
||||
VARIANT_SWITCH_BEGIN(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]);
|
||||
VARIANT_CASE(tx_out_bare, o);
|
||||
VARIANT_CASE_CONST(tx_out_bare, o);
|
||||
{
|
||||
if (o.target.type() == typeid(txout_htlc))
|
||||
{
|
||||
|
|
@ -5028,7 +5030,7 @@ bool wallet2::is_transfer_able_to_go(const transfer_details& td, uint64_t fake_o
|
|||
return false;
|
||||
}
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum);
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o);
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
return true;
|
||||
|
|
@ -5047,7 +5049,7 @@ bool wallet2::prepare_free_transfers_cache(uint64_t fake_outputs_count)
|
|||
if (is_transfer_able_to_go(td, fake_outputs_count))
|
||||
{
|
||||
//@#@
|
||||
boost::get<tx_out_bare>(m_found_free_amounts[td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].amount]).insert(i);
|
||||
m_found_free_amounts[boost::get<tx_out_bare>(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]).amount].insert(i);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
#define KEEP_WALLET_LOG_MACROS
|
||||
#include "wallet2.h"
|
||||
#include "currency_core/currency_format_utils.h"
|
||||
#include "common/variant_helper.h"
|
||||
|
||||
#undef LOG_DEFAULT_CHANNEL
|
||||
#define LOG_DEFAULT_CHANNEL "wallet"
|
||||
|
|
@ -75,7 +76,7 @@ bool wallet2::validate_escrow_proposal(const wallet_public::wallet_transfer_info
|
|||
for (size_t i = 0; i != prop.tx_template.vout.size(); ++i)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(prop.tx_template.vout[i]);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
{
|
||||
if (o.target.type() == typeid(txout_multisig))
|
||||
{
|
||||
|
|
@ -87,7 +88,7 @@ bool wallet2::validate_escrow_proposal(const wallet_public::wallet_transfer_info
|
|||
else
|
||||
LOC_CHK(false, "Invalid output type: " << o.target.type().name());
|
||||
}
|
||||
VARIANT_CASE_TV(tx_out_zarcanum);
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o);
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
|
@ -191,7 +192,7 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n
|
|||
for (size_t i = 0; i != tx.vout.size(); ++i)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(tx.vout[i]);
|
||||
VARIANT_CASE(tx_out_bare, o);
|
||||
VARIANT_CASE_CONST(tx_out_bare, o);
|
||||
{
|
||||
if (o.target.type() == typeid(txout_to_key))
|
||||
{
|
||||
|
|
@ -208,8 +209,8 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n
|
|||
else
|
||||
LOC_CHK(false, "Invalid output type: " << o.target.type().name());
|
||||
}
|
||||
VARIANT_CASE(tx_out_zarcanum, o)
|
||||
LOC_CHK(false, "Invalid output type: " << o.type().name());
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
LOC_CHK(false, "Invalid output type: " << typeid(o).name());
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
||||
|
|
@ -234,9 +235,9 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n
|
|||
|
||||
// (5/5) signatures
|
||||
VARIANT_SWITCH_BEGIN(tx.signature);
|
||||
VARIANT_CASE(NLSAG_sig, signatures)
|
||||
VARIANT_CASE_CONST(NLSAG_sig, signatures)
|
||||
{
|
||||
LOC_CHK(signatures.size() == 1, "invalid singatures size: " << signatures.size()); // only 1 input means only 1 signature vector
|
||||
LOC_CHK(signatures.s.size() == 1, "invalid singatures size: " << signatures.s.size()); // only 1 input means only 1 signature vector
|
||||
|
||||
// As we don't have b_keys we can't be sure which signature is B's and which is reserved for A (should be a null-placeholder, if present).
|
||||
// Having a_keys, we determine index of A key in multisig output keys array.
|
||||
|
|
@ -249,17 +250,17 @@ bool wallet2::validate_escrow_release(const transaction& tx, bool release_type_n
|
|||
LOC_CHK(r, "derive_public_key failed");
|
||||
|
||||
LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid ms output keys array, size: " << source_ms_out.keys.size());
|
||||
LOC_CHK(signatures[0].size() == 2, "internal error: invalid signature size for input #0: " << signatures[0].size())
|
||||
LOC_CHK(signatures.s[0].size() == 2, "internal error: invalid signature size for input #0: " << signatures.s[0].size())
|
||||
size_t ms_out_key_a_index = std::find(source_ms_out.keys.begin(), source_ms_out.keys.end(), ephemeral_pub_key) - source_ms_out.keys.begin();
|
||||
LOC_CHK(ms_out_key_a_index < source_ms_out.keys.size(), "internal error: can't find A ephemeral pub key within ms output keys");
|
||||
size_t ms_out_key_b_index = 1 - ms_out_key_a_index;
|
||||
|
||||
// in this particular case (source_ms_out.minimum_sigs == source_ms_out.keys.size() == 2) index in 'keys' is the same as index in signatures[0]
|
||||
// in this particular case (source_ms_out.minimum_sigs == source_ms_out.keys.size() == 2) index in 'keys' is the same as index in signatures.s[0]
|
||||
crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, 0, get_transaction_hash(tx));
|
||||
r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[ms_out_key_b_index], signatures[0][ms_out_key_b_index]);
|
||||
r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[ms_out_key_b_index], signatures.s[0][ms_out_key_b_index]);
|
||||
LOC_CHK(r, "B signature for multisig input is invalid");
|
||||
}
|
||||
VARIANT_CASE(zarcanum_sig, s);
|
||||
VARIANT_CASE_CONST(zarcanum_sig, s);
|
||||
//@#@
|
||||
VARIANT_CASE_THROW_ON_OTHER();
|
||||
VARIANT_SWITCH_END();
|
||||
|
|
@ -388,7 +389,7 @@ bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, co
|
|||
for (size_t i = 0; i != tx.vout.size(); ++i)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(tx.vout[i]);
|
||||
VARIANT_CASE(tx_out_bare, o)
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (o.target.type() == typeid(txout_to_key))
|
||||
{
|
||||
total_outputs_amount += o.amount;
|
||||
|
|
@ -401,8 +402,8 @@ bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, co
|
|||
}
|
||||
else
|
||||
LOC_CHK(false, "Invalid output type: " << o.target.type().name());
|
||||
VARIANT_CASE_TV(tx_out_zarcanum)
|
||||
LOC_CHK(false, "Invalid output type: " << tv.type().name());
|
||||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
LOC_CHK(false, "Invalid output type: " << typeid(o).name());
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
|
||||
|
|
@ -418,19 +419,19 @@ bool wallet2::validate_escrow_cancel_release(const currency::transaction& tx, co
|
|||
|
||||
// (5/5) signatures
|
||||
VARIANT_SWITCH_BEGIN(tx.signature);
|
||||
VARIANT_CASE(NLSAG_sig, signatures)
|
||||
VARIANT_CASE_CONST(NLSAG_sig, signatures)
|
||||
{
|
||||
LOC_CHK(signatures.size() == 1, "invalid singatures size: " << signatures.size()); // only 1 input means only 1 signature vector
|
||||
LOC_CHK(signatures[0].size() == 2, "invalid signature[0] size: " << signatures[0].size()); // it's expected to contain A-party signature and null-sig placeholder
|
||||
LOC_CHK(signatures.s.size() == 1, "invalid singatures size: " << signatures.s.size()); // only 1 input means only 1 signature vector
|
||||
LOC_CHK(signatures.s[0].size() == 2, "invalid signature[0] size: " << signatures.s[0].size()); // it's expected to contain A-party signature and null-sig placeholder
|
||||
LOC_CHK(source_ms_out.keys.size() == 2, "internal error: invalid source ms output keys array, size: " << source_ms_out.keys.size());
|
||||
|
||||
size_t a_sign_index = (signatures[0][0] != null_sig) ? 0 : 1;
|
||||
size_t a_sign_index = (signatures.s[0][0] != null_sig) ? 0 : 1;
|
||||
|
||||
crypto::hash tx_hash_for_signature = prepare_prefix_hash_for_sign(tx, 0, get_transaction_hash(tx));
|
||||
r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[a_sign_index], signatures[0][a_sign_index]);
|
||||
r = crypto::check_signature(tx_hash_for_signature, source_ms_out.keys[a_sign_index], signatures.s[0][a_sign_index]);
|
||||
LOC_CHK(r, "A signature for multisig input is invalid");
|
||||
}
|
||||
VARIANT_CASE(zarcanum_sig, s);
|
||||
VARIANT_CASE_CONST(zarcanum_sig, s);
|
||||
//@#@
|
||||
VARIANT_CASE_THROW_ON_OTHER();
|
||||
VARIANT_SWITCH_END();
|
||||
|
|
|
|||
|
|
@ -884,8 +884,8 @@ bool gen_alias_reg_with_locked_money::generate(std::vector<test_event_entry>& ev
|
|||
ai.m_address = miner_acc.get_public_address();
|
||||
|
||||
currency::tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).target).key));
|
||||
se.amount = boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).target).key));
|
||||
se.real_output = 0;
|
||||
se.real_output_in_tx_index = 0;
|
||||
se.real_out_tx_key = currency::get_tx_pub_key_from_extra(blk_0.miner_tx);
|
||||
|
|
@ -1159,8 +1159,8 @@ bool gen_alias_tx_no_outs::generate(std::vector<test_event_entry>& events) const
|
|||
ai.m_address = miner_acc.get_public_address();
|
||||
|
||||
currency::tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).target).key));
|
||||
se.amount = boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).target).key));
|
||||
se.real_output = 0;
|
||||
se.real_output_in_tx_index = 0;
|
||||
se.real_out_tx_key = currency::get_tx_pub_key_from_extra(blk_0.miner_tx);
|
||||
|
|
|
|||
|
|
@ -59,9 +59,9 @@ bool block_template_against_txs_size::c1(currency::core& c, size_t ev_index, con
|
|||
keypair ephemeral = AUTO_VAL_INIT(ephemeral);
|
||||
r = generate_key_image_helper(miner_acc.get_keys(), get_tx_pub_key_from_extra(blk_0.miner_tx), 0, ephemeral, ki);
|
||||
CHECK_AND_ASSERT_MES(r, false, "generate_key_image_helper failed");
|
||||
CHECK_AND_ASSERT_MES(boost::get<txout_to_key>(blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).target).key == ephemeral.pub, false, "ephemeral.pub doesn't match with output key");
|
||||
CHECK_AND_ASSERT_MES(boost::get<txout_to_key>(boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).target).key == ephemeral.pub, false, "ephemeral.pub doesn't match with output key");
|
||||
pos_entry pe = AUTO_VAL_INIT(pe);
|
||||
pe.amount = blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).amount;
|
||||
pe.amount = boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).amount;
|
||||
pe.block_timestamp = UINT64_MAX; // doesn't matter
|
||||
pe.index = 0; // global index
|
||||
pe.keyimage = ki;
|
||||
|
|
@ -100,7 +100,7 @@ bool block_template_against_txs_size::c1(currency::core& c, size_t ev_index, con
|
|||
r = bcs.validate_miner_transaction(b, cumulative_block_size, g_block_txs_fee, base_reward, bcs.total_coins());
|
||||
CHECK_AND_ASSERT_MES(r, false, "validate_miner_transaction failed, txs_total_size = " << txs_total_size);
|
||||
|
||||
uint64_t generated_coins = get_outs_money_amount(b.miner_tx) - (is_pos != 0 ? b.miner_tx.vout.back().amount : 0) - g_block_txs_fee / 2;
|
||||
uint64_t generated_coins = get_outs_money_amount(b.miner_tx) - (is_pos != 0 ? boost::get<tx_out_bare>(b.miner_tx.vout.back()).amount : 0) - g_block_txs_fee / 2;
|
||||
uint64_t base_block_reward = is_pos != 0 ? base_block_reward_pos : base_block_reward_pow;
|
||||
|
||||
if (txs_total_size % 1000 == 0)
|
||||
|
|
|
|||
|
|
@ -311,8 +311,8 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events
|
|||
GENERATE_ACCOUNT(alice);
|
||||
|
||||
tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<txout_to_key>(blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).target).key));
|
||||
se.amount = boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<txout_to_key>(boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[0]).target).key));
|
||||
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;
|
||||
|
|
@ -356,8 +356,8 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>
|
|||
REWIND_BLOCKS(events, blk_1r, blk_1, miner_account);
|
||||
|
||||
tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_1.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<txout_to_key>(blk_1.boost::get<currency::tx_out_bare>(miner_tx.vout[0]).target).key));
|
||||
se.amount = boost::get<currency::tx_out_bare>(blk_1.miner_tx.vout[0]).amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<txout_to_key>(boost::get<currency::tx_out_bare>(blk_1.miner_tx.vout[0]).target).key));
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,16 @@ 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_bare& 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_v& o_)
|
||||
{
|
||||
auto& o = boost::get<currency::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;
|
||||
|
|
|
|||
|
|
@ -620,8 +620,8 @@ bool test_generator::build_outputs_indext_for_chain(const blockchain_vector& blo
|
|||
std::vector<uint64_t>& coinbase_outs = txs_outs[currency::get_transaction_hash(blocks[h]->b.miner_tx)];
|
||||
for (size_t out_i = 0; out_i != blocks[h]->b.miner_tx.vout.size(); out_i++)
|
||||
{
|
||||
coinbase_outs.push_back(index[blocks[h]->b.boost::get<currency::tx_out_bare>(miner_tx.vout[out_i]).amount].size());
|
||||
index[blocks[h]->b.boost::get<currency::tx_out_bare>(miner_tx.vout[out_i]).amount].push_back(std::tuple<size_t, size_t, size_t>(h, 0, out_i));
|
||||
coinbase_outs.push_back(index[boost::get<currency::tx_out_bare>(blocks[h]->b.miner_tx.vout[out_i]).amount].size());
|
||||
index[boost::get<currency::tx_out_bare>(blocks[h]->b.miner_tx.vout[out_i]).amount].push_back(std::tuple<size_t, size_t, size_t>(h, 0, out_i));
|
||||
}
|
||||
|
||||
for (size_t tx_index = 0; tx_index != blocks[h]->m_transactions.size(); tx_index++)
|
||||
|
|
@ -629,8 +629,8 @@ bool test_generator::build_outputs_indext_for_chain(const blockchain_vector& blo
|
|||
std::vector<uint64_t>& tx_outs_indx = txs_outs[currency::get_transaction_hash(blocks[h]->m_transactions[tx_index])];
|
||||
for (size_t out_i = 0; out_i != blocks[h]->m_transactions[tx_index].vout.size(); out_i++)
|
||||
{
|
||||
tx_outs_indx.push_back(index[blocks[h]->m_transactions[tx_index]boost::get<currency::tx_out_bare>(.vout[out_i]).amount].size());
|
||||
index[blocks[h]->m_transactions[tx_index]boost::get<currency::tx_out_bare>(.vout[out_i]).amount].push_back(std::tuple<size_t, size_t, size_t>(h, tx_index + 1, out_i));
|
||||
tx_outs_indx.push_back(index[boost::get<currency::tx_out_bare>(blocks[h]->m_transactions[tx_index].vout[out_i]).amount].size());
|
||||
index[boost::get<currency::tx_out_bare>(blocks[h]->m_transactions[tx_index].vout[out_i]).amount].push_back(std::tuple<size_t, size_t, size_t>(h, tx_index + 1, out_i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -663,13 +663,13 @@ bool test_generator::get_output_details_by_global_index(const test_generator::bl
|
|||
CHECK_AND_ASSERT_THROW_MES(tx_out_index < tx->vout.size(), "tx_index < blck_chain[h].m_transactions.size()");
|
||||
|
||||
tx_pub_key = get_tx_pub_key_from_extra(*tx);
|
||||
CHECK_AND_ASSERT_THROW_MES(tx->vout[tx_out_index].target.type() == typeid(currency::txout_to_key),
|
||||
CHECK_AND_ASSERT_THROW_MES(boost::get<tx_out_bare>(tx->vout[tx_out_index]).target.type() == typeid(currency::txout_to_key),
|
||||
"blck_chain[h]->m_transactions[tx_index]boost::get<currency::tx_out_bare>(.vout[tx_out_index]).target.type() == typeid(currency::txout_to_key)");
|
||||
|
||||
CHECK_AND_ASSERT_THROW_MES(tx->vout[tx_out_index].amount == amount,
|
||||
CHECK_AND_ASSERT_THROW_MES(boost::get<tx_out_bare>(tx->vout[tx_out_index]).amount == amount,
|
||||
"blck_chain[h]->m_transactions[tx_index]boost::get<currency::tx_out_bare>(.vout[tx_out_index]).amount == amount");
|
||||
|
||||
output_key = boost::get<currency::txout_to_key>(tx->vout[tx_out_index].target).key;
|
||||
output_key = boost::get<currency::txout_to_key>(boost::get<tx_out_bare>(tx->vout[tx_out_index]).target).key;
|
||||
return 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_bare &out = tx.vout[j];
|
||||
const tx_out_bare &out = boost::get<tx_out_bare>(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))
|
||||
|
|
@ -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_bare &out = tx.vout[tx_out_index];
|
||||
const tx_out_bare &out = boost::get<tx_out_bare>(tx.vout[tx_out_index]);
|
||||
if (out.target.type() == typeid(txout_to_key)) {
|
||||
uint64_t global_out_index = global_outputs[out.amount]++;
|
||||
|
||||
|
|
@ -2053,7 +2053,7 @@ bool check_ring_signature_at_gen_time(const std::vector<test_event_entry>& event
|
|||
auto it = mtx.find(rbi.tx_id);
|
||||
CHECK_AND_ASSERT_MES(it != mtx.end(), false, "it == end");
|
||||
CHECK_AND_ASSERT_MES(rbi.n < it->second->vout.size(), false, "FAIL: rbi.n < it->second->vout.size()");
|
||||
auto& pub_key = boost::get<txout_to_key>(it->second->vout[rbi.n].target).key;
|
||||
auto& pub_key = boost::get<txout_to_key>(boost::get<tx_out_bare>(it->second->vout[rbi.n]).target).key;
|
||||
|
||||
pub_keys.push_back(pub_key);
|
||||
pub_keys_ptrs.push_back(&pub_keys.back());
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ bool gen_double_spend_in_tx<txs_kept_by_block>::generate(std::vector<test_event_
|
|||
// find correct output by amount (selecting random or fixed one can be possibly mistaken with changeback)
|
||||
for (auto out : tx_0.vout)
|
||||
{
|
||||
se.amount = out.amount;
|
||||
se.amount = boost::get<currency::tx_out_bare>(out).amount;
|
||||
if (se.amount == send_amount)
|
||||
break;
|
||||
++se.real_output_in_tx_index;
|
||||
|
|
|
|||
|
|
@ -124,7 +124,12 @@ 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_bare& l, const currency::tx_out_bare& 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_v& l, const currency::tx_out_v& r)
|
||||
{
|
||||
return boost::get<tx_out_bare>(l).amount < boost::get<tx_out_bare>(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,8 +108,8 @@ 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_bare& o){
|
||||
if (o.target.type() == typeid(txout_multisig))
|
||||
auto it = std::find_if(escrow_template_tx.vout.begin(), escrow_template_tx.vout.end(), [](const tx_out_v& o){
|
||||
if (boost::get<tx_out_bare>(o).target.type() == typeid(txout_multisig))
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -653,9 +653,9 @@ bool hard_fork_2_auditable_addresses_basics::generate(std::vector<test_event_ent
|
|||
// make sure all Bob's outputs has mix_attr = 1
|
||||
for (auto& out : tx_1.vout)
|
||||
{
|
||||
if (out.amount != MK_TEST_COINS(5))
|
||||
if (boost::get<tx_out_bare>(out).amount != MK_TEST_COINS(5))
|
||||
continue; // skip change
|
||||
uint8_t mix_attr = boost::get<txout_to_key>(out.target).mix_attr;
|
||||
uint8_t mix_attr = boost::get<txout_to_key>(boost::get<tx_out_bare>(out).target).mix_attr;
|
||||
CHECK_AND_ASSERT_MES(mix_attr == CURRENCY_TO_KEY_OUT_FORCED_NO_MIX, false, "Incorrect mix_attr in tx_1: " << mix_attr);
|
||||
}
|
||||
|
||||
|
|
@ -686,9 +686,9 @@ bool hard_fork_2_auditable_addresses_basics::c1(currency::core& c, size_t ev_ind
|
|||
// make sure all Bob's outputs has mix_attr = 1
|
||||
for (auto& out : tx.vout)
|
||||
{
|
||||
if (out.amount != MK_TEST_COINS(1))
|
||||
if (boost::get<tx_out_bare>(out).amount != MK_TEST_COINS(1))
|
||||
continue; // skip change
|
||||
uint8_t mix_attr = boost::get<txout_to_key>(out.target).mix_attr;
|
||||
uint8_t mix_attr = boost::get<txout_to_key>(boost::get<tx_out_bare>(out).target).mix_attr;
|
||||
CHECK_AND_ASSERT_MES(mix_attr == CURRENCY_TO_KEY_OUT_FORCED_NO_MIX, false, "Incorrect mix_attr in tx: " << mix_attr);
|
||||
}
|
||||
|
||||
|
|
@ -711,9 +711,9 @@ bool hard_fork_2_auditable_addresses_basics::c1(currency::core& c, size_t ev_ind
|
|||
// make sure all Bob's outputs has mix_attr = 1
|
||||
for (auto& out : tx.vout)
|
||||
{
|
||||
if (out.amount != MK_TEST_COINS(1))
|
||||
if (boost::get<tx_out_bare>(out).amount != MK_TEST_COINS(1))
|
||||
continue; // skip change
|
||||
uint8_t mix_attr = boost::get<txout_to_key>(out.target).mix_attr;
|
||||
uint8_t mix_attr = boost::get<txout_to_key>(boost::get<tx_out_bare>(out).target).mix_attr;
|
||||
CHECK_AND_ASSERT_MES(mix_attr == CURRENCY_TO_KEY_OUT_FORCED_NO_MIX, false, "Incorrect mix_attr in tx: " << mix_attr);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ bool gen_uint_overflow_2::generate(std::vector<test_event_entry>& events) const
|
|||
std::vector<currency::tx_source_entry> sources;
|
||||
for (size_t i = 0; i < blk_0.miner_tx.vout.size(); ++i)
|
||||
{
|
||||
if (TESTS_DEFAULT_FEE < blk_0.boost::get<currency::tx_out_bare>(miner_tx.vout[i]).amount)
|
||||
if (TESTS_DEFAULT_FEE < boost::get<currency::tx_out_bare>(blk_0.miner_tx.vout[i]).amount)
|
||||
{
|
||||
append_tx_source_entry(sources, blk_0.miner_tx, i);
|
||||
break;
|
||||
|
|
@ -165,7 +165,7 @@ bool gen_uint_overflow_2::generate(std::vector<test_event_entry>& events) const
|
|||
sources.clear();
|
||||
for (size_t i = 0; i < tx_1.vout.size(); ++i)
|
||||
{
|
||||
auto& tx_1_out = tx_1.vout[i];
|
||||
auto& tx_1_out = boost::get<tx_out_bare>(tx_1.vout[i]);
|
||||
if (tx_1_out.amount < TX_MAX_TRANSFER_AMOUNT - 1)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@ bool mix_in_spent_outs::generate(std::vector<test_event_entry>& events) const
|
|||
m_test_amount = MK_TEST_COINS(6);
|
||||
for(auto& o : blk_0.miner_tx.vout)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(o.amount != m_test_amount, false, "Premine surprisingly has test amount output, change m_test_amount");
|
||||
CHECK_AND_ASSERT_MES(boost::get<tx_out_bare>(o).amount != m_test_amount, false, "Premine surprisingly has test amount output, change m_test_amount");
|
||||
}
|
||||
|
||||
MAKE_TX_LIST_START(events, txs, miner_acc, alice_acc, m_test_amount, blk_0r);
|
||||
|
|
|
|||
|
|
@ -299,7 +299,10 @@ 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_bare& o) { return o.target.type() == typeid(txout_multisig); });
|
||||
auto it = std::find_if(result_tx.vout.begin(), result_tx.vout.end(), [](tx_out_v& o)
|
||||
{
|
||||
return boost::get<tx_out_bare>(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();
|
||||
|
||||
|
|
@ -1411,7 +1414,7 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
se.multisig_id = get_multisig_out_id(blk_1.miner_tx, se.real_output_in_tx_index);
|
||||
//se.participants.push_back(alice_acc.get_keys());
|
||||
se.real_out_tx_key = get_tx_pub_key_from_extra(blk_1.miner_tx);
|
||||
se.ms_keys_count = boost::get<txout_multisig>(blk_1.boost::get<currency::tx_out_bare>(miner_tx.vout[se.real_output_in_tx_index]).target).keys.size();
|
||||
se.ms_keys_count = boost::get<txout_multisig>(boost::get<currency::tx_out_bare>(blk_1.miner_tx.vout[se.real_output_in_tx_index]).target).keys.size();
|
||||
se.ms_sigs_count = 1;
|
||||
sources.assign({ se });
|
||||
|
||||
|
|
@ -1457,9 +1460,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_bare& o) {return o.target.type() == typeid(txout_multisig); });
|
||||
auto it = std::find_if(miner_tx.vout.begin(), miner_tx.vout.end(), [](const tx_out_v& o) {return boost::get<tx_out_bare>(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_bare ms_out = *it;
|
||||
tx_out_bare ms_out = boost::get<tx_out_bare>(*it);
|
||||
miner_tx.vout.assign({ ms_out });
|
||||
CHECK_AND_ASSERT_MES(ms_out.amount == blk_2_reward, false, "unexpected amount for found ms output");
|
||||
|
||||
|
|
@ -1477,7 +1480,7 @@ bool multisig_and_coinbase::generate(std::vector<test_event_entry>& events) cons
|
|||
se.multisig_id = get_multisig_out_id(blk_3.miner_tx, 0);
|
||||
se.real_output_in_tx_index = 0;
|
||||
se.real_out_tx_key = get_tx_pub_key_from_extra(blk_3.miner_tx);
|
||||
se.ms_keys_count= boost::get<txout_multisig>(blk_3.boost::get<currency::tx_out_bare>(miner_tx.vout[se.real_output_in_tx_index]).target).keys.size();
|
||||
se.ms_keys_count= boost::get<txout_multisig>(boost::get<currency::tx_out_bare>(blk_3.miner_tx.vout[se.real_output_in_tx_index]).target).keys.size();
|
||||
se.ms_sigs_count = 1;
|
||||
|
||||
transaction tx_2 = AUTO_VAL_INIT(tx_2);
|
||||
|
|
@ -1874,7 +1877,7 @@ bool multisig_and_checkpoints_bad_txs::generate(std::vector<test_event_entry>& e
|
|||
txb.step1_init();
|
||||
txb.step2_fill_inputs(miner_acc.get_keys(), sources);
|
||||
txb.step3_fill_outputs(destinations, 0, 1);
|
||||
boost::get<txout_multisig>(txb.boost::get<currency::tx_out_bare>(m_tx.vout[0]).target).keys.clear(); // zero keys
|
||||
boost::get<txout_multisig>(boost::get<currency::tx_out_bare>(txb.m_tx.vout[0]).target).keys.clear(); // zero keys
|
||||
txb.step4_calc_hash();
|
||||
txb.step5_sign(sources);
|
||||
transaction tx_4 = txb.m_tx;
|
||||
|
|
@ -1888,8 +1891,8 @@ bool multisig_and_checkpoints_bad_txs::generate(std::vector<test_event_entry>& e
|
|||
txb.step1_init();
|
||||
txb.step2_fill_inputs(miner_acc.get_keys(), sources);
|
||||
txb.step3_fill_outputs(destinations, 0, 1);
|
||||
crypto::public_key k = boost::get<txout_multisig>(txb.boost::get<currency::tx_out_bare>(m_tx.vout[0]).target).keys[0];
|
||||
boost::get<txout_multisig>(txb.boost::get<currency::tx_out_bare>(m_tx.vout[0]).target).keys.resize(1500, k);
|
||||
crypto::public_key k = boost::get<txout_multisig>(boost::get<currency::tx_out_bare>(txb.m_tx.vout[0]).target).keys[0];
|
||||
boost::get<txout_multisig>(boost::get<currency::tx_out_bare>(txb.m_tx.vout[0]).target).keys.resize(1500, k);
|
||||
txb.step4_calc_hash();
|
||||
txb.step5_sign(sources);
|
||||
boost::get<currency::NLSAG_sig>(txb.m_tx.signature).s.clear();
|
||||
|
|
|
|||
|
|
@ -494,7 +494,7 @@ bool gen_tx_txout_to_key_has_invalid_key::generate(std::vector<test_event_entry>
|
|||
builder.step2_fill_inputs(miner_account.get_keys(), sources);
|
||||
builder.step3_fill_outputs(destinations);
|
||||
|
||||
txout_to_key& out_to_key = boost::get<txout_to_key>(builder.m_tx.vout.front().target);
|
||||
txout_to_key& out_to_key = boost::get<txout_to_key>(boost::get<tx_out_bare>(builder.m_tx.vout.front()).target);
|
||||
out_to_key.key = tx_builder::generate_invalid_pub_key();
|
||||
|
||||
builder.step4_calc_hash();
|
||||
|
|
@ -523,7 +523,7 @@ bool gen_tx_output_with_zero_amount::generate(std::vector<test_event_entry>& eve
|
|||
builder.step2_fill_inputs(miner_account.get_keys(), sources);
|
||||
builder.step3_fill_outputs(destinations);
|
||||
|
||||
builder.m_tx.vout.front().amount = 0;
|
||||
boost::get<tx_out_bare>(builder.m_tx.vout.front()).amount = 0;
|
||||
|
||||
builder.step4_calc_hash();
|
||||
builder.step5_sign(sources);
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ const std::wstring g_wallet_filename = L"~coretests.wallet.file.tmp";
|
|||
const std::string g_wallet_password = "dofatibmzibeziyekigo";
|
||||
const currency::account_base null_account = AUTO_VAL_INIT(null_account);
|
||||
|
||||
|
||||
//@#@: TODO: need refactoring, unsafe operations
|
||||
POD_MAKE_COMPARABLE(currency, tx_out_bare);
|
||||
|
||||
// Determines which output is real and actually spent in tx inputs, when there are fake outputs.
|
||||
|
|
@ -39,7 +39,8 @@ bool determine_tx_real_inputs(currency::core& c, const currency::transaction& tx
|
|||
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);
|
||||
auto is_even = [&](const tx_out_v& v) { return boost::get<tx_out_bare>(v) == out; };
|
||||
auto it = std::find_if(validated_tx.vout.begin(), validated_tx.vout.end(), is_even);
|
||||
if (it == validated_tx.vout.end())
|
||||
return false;
|
||||
size_t output_tx_index = it - validated_tx.vout.begin();
|
||||
|
|
|
|||
|
|
@ -196,7 +196,7 @@ uint64_t got_money_in_first_transfers(const tools::wallet2::transfer_container&
|
|||
size_t count = 0;
|
||||
BOOST_FOREACH(const tools::wallet2::transfer_details& td, incoming_transfers)
|
||||
{
|
||||
summ += td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].amount;
|
||||
summ += boost::get<tx_out_bare>(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]).amount;
|
||||
if(++count >= n_transfers)
|
||||
return summ;
|
||||
}
|
||||
|
|
@ -459,9 +459,9 @@ bool transactions_flow_test(
|
|||
|
||||
++count;
|
||||
currency::transaction tx_s;
|
||||
if (w1.unlocked_balance() >= td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].amount)
|
||||
if (w1.unlocked_balance() >= boost::get<tx_out_bare>(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]).amount)
|
||||
{
|
||||
bool r = do_send_money_by_fractions(w1, w1, 0, td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index].amount - TX_DEFAULT_FEE, tx_s, transfer_size);
|
||||
bool r = do_send_money_by_fractions(w1, w1, 0, boost::get<tx_out_bare>(td.m_ptx_wallet_info->m_tx.vout[td.m_internal_output_index]).amount - TX_DEFAULT_FEE, tx_s, transfer_size);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Failed to send starter tx " << get_transaction_hash(tx_s));
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ public:
|
|||
|
||||
bool test()
|
||||
{
|
||||
const currency::txout_to_key& tx_out = boost::get<currency::txout_to_key>(m_tx.vout[0].target);
|
||||
const currency::txout_to_key& tx_out = boost::get<currency::txout_to_key>(boost::get<tx_out_bare>(m_tx.vout[0]).target);
|
||||
return currency::is_out_to_acc(m_bob.get_keys(), tx_out, m_tx_pub_key, 0);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,13 +32,13 @@ public:
|
|||
if (!construct_miner_tx(0, 0, 0, 2, 0, m_miners[i].get_keys().m_account_address, m_miner_txs[i], TRANSACTION_VERSION_PRE_HF4))
|
||||
return false;
|
||||
|
||||
txout_to_key tx_out = boost::get<txout_to_key>(m_miner_txs[i].vout[0].target);
|
||||
txout_to_key tx_out = boost::get<txout_to_key>(boost::get<tx_out_bare>(m_miner_txs[i].vout[0]).target);
|
||||
output_entries.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(i, tx_out.key));
|
||||
m_public_keys[i] = tx_out.key;
|
||||
m_public_key_ptrs[i] = &m_public_keys[i];
|
||||
}
|
||||
|
||||
m_source_amount = m_miner_txs[0].vout[0].amount;
|
||||
m_source_amount = boost::get<tx_out_bare>(m_miner_txs[0].vout[0]).amount;
|
||||
|
||||
tx_source_entry source_entry;
|
||||
source_entry.amount = m_source_amount;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue