htlc in work: scanning for outputs and validation agains internal errors
This commit is contained in:
parent
3c51c95941
commit
b2a7423ab4
13 changed files with 82 additions and 62 deletions
|
|
@ -2560,7 +2560,7 @@ bool blockchain_storage::is_pos_allowed() const
|
|||
return get_top_block_height() >= m_core_runtime_config.pos_minimum_heigh;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::update_spent_tx_flags_for_input(uint64_t amount, const txout_v& o, bool spent)
|
||||
bool blockchain_storage::update_spent_tx_flags_for_input(uint64_t amount, const txout_ref_v& o, bool spent)
|
||||
{
|
||||
if (o.type() == typeid(ref_by_id))
|
||||
return update_spent_tx_flags_for_input(boost::get<ref_by_id>(o).tx_id, boost::get<ref_by_id>(o).n, spent);
|
||||
|
|
@ -3802,7 +3802,11 @@ namespace currency
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator()(const txin_htlc& in) const
|
||||
{
|
||||
//HTLC TODO
|
||||
return true;
|
||||
}
|
||||
bool operator()(const txin_gen& in) const { return true; }
|
||||
bool operator()(const txin_multisig& in) const
|
||||
{
|
||||
|
|
@ -3815,11 +3819,6 @@ namespace currency
|
|||
}
|
||||
return true;
|
||||
}
|
||||
bool operator()(const txin_htlc& in) const
|
||||
{
|
||||
//HTLC TODO
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -4110,7 +4109,7 @@ bool blockchain_storage::print_tx_outputs_lookup(const crypto::hash& tx_id)const
|
|||
if(amount_it == usage_stat.end())
|
||||
continue;
|
||||
|
||||
for (txout_v& off : txi_in_tokey.key_offsets)
|
||||
for (txout_ref_v& off : txi_in_tokey.key_offsets)
|
||||
{
|
||||
if(off.type() != typeid(uint64_t))
|
||||
continue;
|
||||
|
|
@ -4276,7 +4275,7 @@ bool blockchain_storage::check_tx_input(const transaction& tx, size_t in_index,
|
|||
for (auto& ptr : output_keys)
|
||||
output_keys_ptrs.push_back(&ptr);
|
||||
|
||||
return check_tokey_input(tx, in_index, txin, tx_prefix_hash, sig, output_keys_ptrs);
|
||||
return check_input_signature(tx, in_index, txin, tx_prefix_hash, sig, output_keys_ptrs);
|
||||
}
|
||||
//----------------------------------------------------------------
|
||||
struct outputs_visitor
|
||||
|
|
@ -4335,31 +4334,37 @@ struct outputs_visitor
|
|||
// 1) source tx unlock time validity
|
||||
// 2) mixin restrictions
|
||||
// 3) general gindex/ref_by_id corectness
|
||||
bool blockchain_storage::get_output_keys_for_input_with_checks(const transaction& tx, uint64_t amount, const std::vector<txout_v>& key_offsets, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase, scan_for_keys_context& scan_context) const
|
||||
bool blockchain_storage::get_output_keys_for_input_with_checks(const transaction& tx, const txin_v& verifying_input, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase, scan_for_keys_context& scan_context) const
|
||||
{
|
||||
CRITICAL_REGION_LOCAL(m_read_lock);
|
||||
|
||||
outputs_visitor vi(output_keys, *this, source_max_unlock_time_for_pos_coinbase, scan_context);
|
||||
return scan_outputkeys_for_indexes(tx, amount, key_offsets, vi, max_related_block_height, scan_context);
|
||||
return scan_outputkeys_for_indexes(tx, verifying_input, vi, max_related_block_height, scan_context);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::get_output_keys_for_input_with_checks(const transaction& tx, uint64_t amount, const std::vector<txout_v>& key_offsets, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase) const
|
||||
bool blockchain_storage::get_output_keys_for_input_with_checks(const transaction& tx, const txin_v& verifying_input, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase) const
|
||||
{
|
||||
scan_for_keys_context scan_context_dummy = AUTO_VAL_INIT(scan_context_dummy);
|
||||
return get_output_keys_for_input_with_checks(tx, amount, key_offsets, output_keys, max_related_block_height, source_max_unlock_time_for_pos_coinbase, scan_context_dummy);
|
||||
return get_output_keys_for_input_with_checks(tx, verifying_input, output_keys, max_related_block_height, source_max_unlock_time_for_pos_coinbase, scan_context_dummy);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
// Note: this function can be used for checking to_key inputs against either main chain or alt chain, that's why it has output_keys_ptrs parameter
|
||||
// Doesn't check spent flags, the caller must check it.
|
||||
bool blockchain_storage::check_tokey_input(const transaction& tx, size_t in_index, const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const std::vector<const crypto::public_key*>& output_keys_ptrs) const
|
||||
bool blockchain_storage::check_input_signature(const transaction& tx, size_t in_index, const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const std::vector<const crypto::public_key*>& output_keys_ptrs) const
|
||||
{
|
||||
return check_tokey_input(tx, in_index, txin.key_offsets, txin.amount, txin.k_image, txin.etc_details, tx_prefix_hash, sig, output_keys_ptrs);
|
||||
if (txin.key_offsets.size() != output_keys_ptrs.size())
|
||||
{
|
||||
LOG_PRINT_L0("Output keys for tx with amount = " << txin.amount << " and count indexes " << txin.key_offsets.size() << " returned wrong keys count " << output_keys_ptrs.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
return check_input_signature(tx, in_index, /*txin.key_offsets,*/ txin.amount, txin.k_image, txin.etc_details, tx_prefix_hash, sig, output_keys_ptrs);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::check_tokey_input(const transaction& tx,
|
||||
bool blockchain_storage::check_input_signature(const transaction& tx,
|
||||
size_t in_index,
|
||||
const std::vector<txout_v>& in_key_offsets,
|
||||
// const std::vector<txout_ref_v>& in_key_offsets,
|
||||
uint64_t in_amount,
|
||||
const crypto::key_image& in_k_image,
|
||||
const std::vector<txin_etc_details_v>& in_etc_details,
|
||||
|
|
@ -4370,12 +4375,6 @@ bool blockchain_storage::check_tokey_input(const transaction& tx,
|
|||
CRITICAL_REGION_LOCAL(m_read_lock);
|
||||
|
||||
TIME_MEASURE_START_PD(tx_check_inputs_loop_ch_in_val_sig);
|
||||
|
||||
if (in_key_offsets.size() != output_keys_ptrs.size())
|
||||
{
|
||||
LOG_PRINT_L0("Output keys for tx with amount = " << in_amount << " and count indexes " << in_key_offsets.size() << " returned wrong keys count " << output_keys_ptrs.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
if(m_is_in_checkpoint_zone)
|
||||
return true;
|
||||
|
|
@ -4550,10 +4549,10 @@ bool blockchain_storage::check_tx_input(const transaction& tx, size_t in_index,
|
|||
//TIME_MEASURE_START_PD(tx_check_inputs_loop_ch_in_get_keys_loop);
|
||||
|
||||
std::vector<crypto::public_key> output_keys;
|
||||
std::vector<txout_v> key_offsets(1, txin.key_offset);
|
||||
std::vector<txout_ref_v> key_offsets(1, txin.key_offset);
|
||||
scan_for_keys_context scan_contex = AUTO_VAL_INIT(scan_contex);
|
||||
uint64_t source_max_unlock_time_for_pos_coinbase_dummy = AUTO_VAL_INIT(source_max_unlock_time_for_pos_coinbase_dummy);
|
||||
if (!get_output_keys_for_input_with_checks(tx, txin.amount, key_offsets, output_keys, max_related_block_height, source_max_unlock_time_for_pos_coinbase_dummy, scan_contex))
|
||||
if (!get_output_keys_for_input_with_checks(tx, txin, output_keys, max_related_block_height, source_max_unlock_time_for_pos_coinbase_dummy, scan_contex))
|
||||
{
|
||||
LOG_PRINT_L0("Failed to get output keys for input #" << in_index << " (amount = " << print_money(txin.amount) << ", key_offset.size = " << key_offsets.size() << ")");
|
||||
return false;
|
||||
|
|
@ -4588,7 +4587,9 @@ bool blockchain_storage::check_tx_input(const transaction& tx, size_t in_index,
|
|||
for (auto& ptr : output_keys)
|
||||
output_keys_ptrs.push_back(&ptr);
|
||||
|
||||
return check_tokey_input(tx, in_index, key_offsets, txin.amount, txin.k_image, txin.etc_details, tx_prefix_hash, sig, output_keys_ptrs);
|
||||
CHECK_AND_ASSERT_THROW_MES(output_keys_ptrs.size() == 1, "Internal error: output_keys_ptrs.size() is not equal 1 for HTLC");
|
||||
|
||||
return check_input_signature(tx, in_index, key_offsets, txin.amount, txin.k_image, txin.etc_details, tx_prefix_hash, sig, output_keys_ptrs);
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
uint64_t blockchain_storage::get_adjusted_time() const
|
||||
|
|
@ -6125,7 +6126,7 @@ bool blockchain_storage::validate_alt_block_input(const transaction& input_tx, s
|
|||
TIME_MEASURE_FINISH(ki_lookup_time);
|
||||
ki_lookuptime = ki_lookup_time;
|
||||
|
||||
std::vector<txout_v> abs_key_offsets = relative_output_offsets_to_absolute(input.key_offsets);
|
||||
std::vector<txout_ref_v> abs_key_offsets = relative_output_offsets_to_absolute(input.key_offsets);
|
||||
CHECK_AND_ASSERT_MES(abs_key_offsets.size() > 0 && abs_key_offsets.size() == input.key_offsets.size(), false, "internal error: abs_key_offsets.size()==" << abs_key_offsets.size() << ", input.key_offsets.size()==" << input.key_offsets.size());
|
||||
// eventually we should found all public keys for all outputs this input refers to, for checking ring signature
|
||||
std::vector<crypto::public_key> pub_keys(abs_key_offsets.size(), null_pkey);
|
||||
|
|
@ -6243,7 +6244,7 @@ bool blockchain_storage::validate_alt_block_input(const transaction& input_tx, s
|
|||
}
|
||||
|
||||
// do input checks (attachment_info, ring signature and extra signature, etc.)
|
||||
r = check_tokey_input(input_tx, input_index, input, input_tx_hash, input_sigs, pub_key_pointers);
|
||||
r = check_input_signature(input_tx, input_index, input, input_tx_hash, input_sigs, pub_key_pointers);
|
||||
CHECK_AND_ASSERT_MES(r, false, "to_key input validation failed");
|
||||
|
||||
// TODO: consider checking input_tx for valid extra attachment info as it's checked in check_tx_inputs()
|
||||
|
|
|
|||
|
|
@ -237,10 +237,11 @@ namespace currency
|
|||
template<class visitor_t>
|
||||
bool scan_outputkeys_for_indexes(const transaction &validated_tx, const txin_to_key& tx_in_to_key, visitor_t& vis)
|
||||
{
|
||||
uint64_t stub = 0; return scan_outputkeys_for_indexes(validated_tx, tx_in_to_key.amount, tx_in_to_key.key_offsets, vis, stub);
|
||||
uint64_t stub = 0;
|
||||
return scan_outputkeys_for_indexes(validated_tx, tx_in_to_key, vis, stub);
|
||||
}
|
||||
template<class visitor_t>
|
||||
bool scan_outputkeys_for_indexes(const transaction &validated_tx, uint64_t amount, const std::vector<txout_v>& key_offsets, visitor_t& vis, uint64_t& max_related_block_height, scan_for_keys_context& /*scan_context*/) const;
|
||||
bool scan_outputkeys_for_indexes(const transaction &validated_tx, const txin_v& verified_input, visitor_t& vis, uint64_t& max_related_block_height, scan_for_keys_context& /*scan_context*/) const;
|
||||
|
||||
|
||||
uint64_t get_current_blockchain_size() const;
|
||||
|
|
@ -288,12 +289,11 @@ namespace currency
|
|||
bool check_tx_inputs(const transaction& tx, const crypto::hash& tx_prefix_hash, uint64_t& max_used_block_height, crypto::hash& max_used_block_id)const;
|
||||
bool check_ms_input(const transaction& tx, size_t in_index, const txin_multisig& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const transaction& source_tx, size_t out_n) const;
|
||||
bool validate_tx_for_hardfork_specific_terms(const transaction& tx, const crypto::hash& tx_id, uint64_t block_height) const;
|
||||
bool get_output_keys_for_input_with_checks(const transaction& tx, uint64_t amount, const std::vector<txout_v>& key_offsets, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase, scan_for_keys_context& scan_context) const;
|
||||
bool get_output_keys_for_input_with_checks(const transaction& tx, uint64_t amount, const std::vector<txout_v>& key_offsets, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase) const;
|
||||
bool check_tokey_input(const transaction& tx, size_t in_index, const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const std::vector<const crypto::public_key*>& output_keys_ptrs) const;
|
||||
bool check_tokey_input(const transaction& tx,
|
||||
bool get_output_keys_for_input_with_checks(const transaction& tx, const txin_v& verified_input, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase, scan_for_keys_context& scan_context) const;
|
||||
bool get_output_keys_for_input_with_checks(const transaction& tx, const txin_v& verified_input, std::vector<crypto::public_key>& output_keys, uint64_t& max_related_block_height, uint64_t& source_max_unlock_time_for_pos_coinbase) const;
|
||||
bool check_input_signature(const transaction& tx, size_t in_index, const txin_to_key& txin, const crypto::hash& tx_prefix_hash, const std::vector<crypto::signature>& sig, const std::vector<const crypto::public_key*>& output_keys_ptrs) const;
|
||||
bool check_input_signature(const transaction& tx,
|
||||
size_t in_index,
|
||||
const std::vector<txout_v>& in_key_offsets,
|
||||
uint64_t in_amount,
|
||||
const crypto::key_image& k_image,
|
||||
const std::vector<txin_etc_details_v>& in_etc_details,
|
||||
|
|
@ -628,7 +628,7 @@ namespace currency
|
|||
// bool build_stake_modifier_for_alt(const alt_chain_type& alt_chain, stake_modifier_type& sm);
|
||||
template<class visitor_t>
|
||||
bool enum_blockchain(visitor_t& v, const alt_chain_type& alt_chain = alt_chain_type(), uint64_t split_height = 0) const;
|
||||
bool update_spent_tx_flags_for_input(uint64_t amount, const txout_v& o, bool spent);
|
||||
bool update_spent_tx_flags_for_input(uint64_t amount, const txout_ref_v& o, bool spent);
|
||||
bool update_spent_tx_flags_for_input(uint64_t amount, uint64_t global_index, bool spent);
|
||||
bool update_spent_tx_flags_for_input(const crypto::hash& multisig_id, uint64_t spent_height);
|
||||
bool update_spent_tx_flags_for_input(const crypto::hash& tx_id, size_t n, bool spent);
|
||||
|
|
@ -681,12 +681,31 @@ namespace currency
|
|||
|
||||
return !keep_going;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//------------------------------------------------------------------
|
||||
template<class visitor_t>
|
||||
bool blockchain_storage::scan_outputkeys_for_indexes(const transaction &validated_tx, uint64_t amount, const std::vector<txout_v>& key_offsets, visitor_t& vis, uint64_t& max_related_block_height, scan_for_keys_context& /*scan_context*/) const
|
||||
bool blockchain_storage::scan_outputkeys_for_indexes(const transaction &validated_tx, const txin_v& verified_input, visitor_t& vis, uint64_t& max_related_block_height, scan_for_keys_context& /*scan_context*/) const
|
||||
{
|
||||
std::vector<txout_ref_v> key_offsets_dummy;
|
||||
uint64_t amount = 0;
|
||||
const std::vector<txout_ref_v>& key_offsets = [&] -> const std::vector<txout_ref_v>&
|
||||
{
|
||||
if (verified_input.type() == typeid(txin_htlc))
|
||||
{
|
||||
//hltc
|
||||
const txin_htlc& htlc = boost::get<txin_htlc>(verified_input);
|
||||
key_offsets_dummy.push_back(htlc.key_offset);
|
||||
amount = htlc.amount;
|
||||
return key_offsets_dummy;
|
||||
}
|
||||
else if (verified_input.type() == typeid(txin_to_key))
|
||||
{
|
||||
//regular to key output
|
||||
const txin_to_key& to_key = boost::get<txin_to_key>(verified_input);
|
||||
amount = to_key.amount;
|
||||
return to_key.key_offsets;
|
||||
}
|
||||
};
|
||||
|
||||
CRITICAL_REGION_LOCAL(m_read_lock);
|
||||
TIME_MEASURE_START_PD(tx_check_inputs_loop_scan_outputkeys_get_item_size);
|
||||
|
||||
|
|
@ -695,11 +714,11 @@ namespace currency
|
|||
if (!outs_count_for_amount)
|
||||
return false;
|
||||
TIME_MEASURE_START_PD(tx_check_inputs_loop_scan_outputkeys_relative_to_absolute);
|
||||
std::vector<txout_v> absolute_offsets = relative_output_offsets_to_absolute(key_offsets);
|
||||
std::vector<txout_ref_v> absolute_offsets = relative_output_offsets_to_absolute(key_offsets);
|
||||
TIME_MEASURE_FINISH_PD(tx_check_inputs_loop_scan_outputkeys_relative_to_absolute);
|
||||
TIME_MEASURE_START_PD(tx_check_inputs_loop_scan_outputkeys_loop);
|
||||
size_t output_index = 0;
|
||||
for(const txout_v& o : absolute_offsets)
|
||||
for(const txout_ref_v& o : absolute_offsets)
|
||||
{
|
||||
crypto::hash tx_id = null_hash;
|
||||
size_t n = 0;
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ namespace currency
|
|||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
typedef boost::variant<uint64_t, ref_by_id> txout_v;
|
||||
typedef boost::variant<uint64_t, ref_by_id> txout_ref_v;
|
||||
|
||||
|
||||
struct signed_parts
|
||||
|
|
@ -211,7 +211,7 @@ namespace currency
|
|||
struct txin_to_key
|
||||
{
|
||||
uint64_t amount;
|
||||
std::vector<txout_v> key_offsets;
|
||||
std::vector<txout_ref_v> key_offsets;
|
||||
crypto::key_image k_image; // double spending protection
|
||||
std::vector<txin_etc_details_v> etc_details; //this flag used when TX_FLAG_SIGNATURE_MODE_SEPARATE flag is set, point to which amount of outputs(starting from zero) used in signature
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ namespace currency
|
|||
{
|
||||
uint64_t amount;
|
||||
std::string hltc_origin;
|
||||
txout_v key_offset;
|
||||
txout_ref_v key_offset;
|
||||
crypto::key_image k_image; // double spending protection
|
||||
std::vector<txin_etc_details_v> etc_details; //this flag used when TX_FLAG_SIGNATURE_MODE_SEPARATE flag is set, point to which amount of outputs(starting from zero) used in signature
|
||||
|
||||
|
|
|
|||
|
|
@ -2049,11 +2049,11 @@ namespace currency
|
|||
return genesis_id;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
std::vector<txout_v> relative_output_offsets_to_absolute(const std::vector<txout_v>& off)
|
||||
std::vector<txout_ref_v> relative_output_offsets_to_absolute(const std::vector<txout_ref_v>& off)
|
||||
{
|
||||
//if array has both types of outs, then global index (uint64_t) should be first, and then the rest could be out_by_id
|
||||
|
||||
std::vector<txout_v> res = off;
|
||||
std::vector<txout_ref_v> res = off;
|
||||
for (size_t i = 1; i < res.size(); i++)
|
||||
{
|
||||
if (res[i].type() == typeid(ref_by_id))
|
||||
|
|
@ -2064,13 +2064,13 @@ namespace currency
|
|||
return res;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
std::vector<txout_v> absolute_output_offsets_to_relative(const std::vector<txout_v>& off)
|
||||
std::vector<txout_ref_v> absolute_output_offsets_to_relative(const std::vector<txout_ref_v>& off)
|
||||
{
|
||||
std::vector<txout_v> res = off;
|
||||
std::vector<txout_ref_v> res = off;
|
||||
if (off.size() < 2)
|
||||
return res;
|
||||
|
||||
std::sort(res.begin(), res.end(), [](const txout_v& lft, const txout_v& rght)
|
||||
std::sort(res.begin(), res.end(), [](const txout_ref_v& lft, const txout_ref_v& rght)
|
||||
{
|
||||
if (lft.type() == typeid(uint64_t))
|
||||
{
|
||||
|
|
@ -2429,7 +2429,7 @@ namespace currency
|
|||
txin_to_key& tk = boost::get<txin_to_key>(in);
|
||||
tei.ins.back().amount = tk.amount;
|
||||
tei.ins.back().kimage_or_ms_id = epee::string_tools::pod_to_hex(tk.k_image);
|
||||
std::vector<txout_v> absolute_offsets = relative_output_offsets_to_absolute(tk.key_offsets);
|
||||
std::vector<txout_ref_v> absolute_offsets = relative_output_offsets_to_absolute(tk.key_offsets);
|
||||
for (auto& ao : absolute_offsets)
|
||||
{
|
||||
tei.ins.back().global_indexes.push_back(0);
|
||||
|
|
|
|||
|
|
@ -255,8 +255,8 @@ namespace currency
|
|||
bool check_inputs_overflow(const transaction& tx);
|
||||
uint64_t get_block_height(const transaction& coinbase);
|
||||
uint64_t get_block_height(const block& b);
|
||||
std::vector<txout_v> relative_output_offsets_to_absolute(const std::vector<txout_v>& off);
|
||||
std::vector<txout_v> absolute_output_offsets_to_relative(const std::vector<txout_v>& off);
|
||||
std::vector<txout_ref_v> relative_output_offsets_to_absolute(const std::vector<txout_ref_v>& off);
|
||||
std::vector<txout_ref_v> absolute_output_offsets_to_relative(const std::vector<txout_ref_v>& off);
|
||||
|
||||
// prints amount in format "3.14", "0.0"
|
||||
std::string print_money_brief(uint64_t amount);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ namespace currency
|
|||
{
|
||||
struct tx_source_entry
|
||||
{
|
||||
typedef serializable_pair<txout_v, crypto::public_key> output_entry; // txout_v is either global output index or ref_by_id; public_key - is output ephemeral pub key
|
||||
typedef serializable_pair<txout_ref_v, crypto::public_key> output_entry; // txout_v is either global output index or ref_by_id; public_key - is output ephemeral pub key
|
||||
|
||||
std::vector<output_entry> outputs; //index + key
|
||||
uint64_t real_output; //index in outputs vector of real output_entry
|
||||
|
|
|
|||
|
|
@ -1562,7 +1562,7 @@ uint64_t wallet2::get_directly_spent_transfer_id_by_input_in_tracking_wallet(con
|
|||
uint64_t tid = UINT64_MAX;
|
||||
|
||||
// try to find a reference among own UTXOs
|
||||
std::vector<txout_v> abs_key_offsets = relative_output_offsets_to_absolute(intk.key_offsets); // potential speed-up: don't convert to abs offsets as we interested only in direct spends for auditable wallets. Now it's kind a bit paranoid.
|
||||
std::vector<txout_ref_v> abs_key_offsets = relative_output_offsets_to_absolute(intk.key_offsets); // potential speed-up: don't convert to abs offsets as we interested only in direct spends for auditable wallets. Now it's kind a bit paranoid.
|
||||
for (auto v : abs_key_offsets)
|
||||
{
|
||||
if (v.type() != typeid(uint64_t))
|
||||
|
|
|
|||
|
|
@ -870,7 +870,7 @@ bool gen_alias_reg_with_locked_money::generate(std::vector<test_event_entry>& ev
|
|||
|
||||
currency::tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_0.miner_tx.vout[0].amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(blk_0.miner_tx.vout[0].target).key));
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(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);
|
||||
|
|
@ -1140,7 +1140,7 @@ bool gen_alias_tx_no_outs::generate(std::vector<test_event_entry>& events) const
|
|||
|
||||
currency::tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_0.miner_tx.vout[0].amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(blk_0.miner_tx.vout[0].target).key));
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(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);
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ bool gen_block_miner_tx_has_2_in::generate(std::vector<test_event_entry>& events
|
|||
|
||||
tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_0.miner_tx.vout[0].amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_v, crypto::public_key>(0, boost::get<txout_to_key>(blk_0.miner_tx.vout[0].target).key));
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<txout_to_key>(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;
|
||||
|
|
@ -355,7 +355,7 @@ bool gen_block_miner_tx_with_txin_to_key::generate(std::vector<test_event_entry>
|
|||
|
||||
tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = blk_1.miner_tx.vout[0].amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_v, crypto::public_key>(0, boost::get<txout_to_key>(blk_1.miner_tx.vout[0].target).key));
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<txout_to_key>(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;
|
||||
|
|
|
|||
|
|
@ -1229,7 +1229,7 @@ bool fill_tx_sources(std::vector<currency::tx_source_entry>& sources, const std:
|
|||
{
|
||||
for (const auto& s_outputs_el : s.outputs) // avoid all outputs, including fake mix-ins
|
||||
{
|
||||
txout_v sout = s_outputs_el.first;
|
||||
txout_ref_v sout = s_outputs_el.first;
|
||||
if (sout.type().hash_code() == typeid(uint64_t).hash_code()) // output by global index
|
||||
{
|
||||
uint64_t gindex = boost::get<uint64_t>(sout);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ bool gen_double_spend_in_tx<txs_kept_by_block>::generate(std::vector<test_event_
|
|||
uint64_t global_out_index = 0;
|
||||
bool r = find_global_index_for_output(events, get_block_hash(blk_1r), tx_0, se.real_output_in_tx_index, global_out_index);
|
||||
CHECK_AND_ASSERT_MES(r, false, "find_global_index_for_output failed");
|
||||
se.outputs.push_back(make_serializable_pair<currency::txout_v, crypto::public_key>(global_out_index, boost::get<currency::txout_to_key>(tx_0.vout[se.real_output_in_tx_index].target).key));
|
||||
se.outputs.push_back(make_serializable_pair<currency::txout_ref_v, crypto::public_key>(global_out_index, boost::get<currency::txout_to_key>(tx_0.vout[se.real_output_in_tx_index].target).key));
|
||||
se.real_output = 0;
|
||||
se.real_out_tx_key = get_tx_pub_key_from_extra(tx_0);
|
||||
sources.push_back(se);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ namespace
|
|||
{
|
||||
currency::tx_source_entry se = AUTO_VAL_INIT(se);
|
||||
se.amount = tx.vout[out_idx].amount;
|
||||
se.outputs.push_back(make_serializable_pair<txout_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(tx.vout[out_idx].target).key));
|
||||
se.outputs.push_back(make_serializable_pair<txout_ref_v, crypto::public_key>(0, boost::get<currency::txout_to_key>(tx.vout[out_idx].target).key));
|
||||
se.real_output = 0;
|
||||
se.real_out_tx_key = get_tx_pub_key_from_extra(tx);
|
||||
se.real_output_in_tx_index = out_idx;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
return false;
|
||||
|
||||
txout_to_key tx_out = boost::get<txout_to_key>(m_miner_txs[i].vout[0].target);
|
||||
output_entries.push_back(make_serializable_pair<txout_v, crypto::public_key>(i, tx_out.key));
|
||||
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];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue