forked from lthn/blockchain
zarcanum sig WIP
This commit is contained in:
parent
a90c9931dd
commit
389118e785
10 changed files with 248 additions and 134 deletions
|
|
@ -174,7 +174,7 @@ ENABLE_SHARED_PCH_EXECUTABLE(connectivity_tool)
|
|||
|
||||
add_executable(simplewallet ${SIMPLEWALLET})
|
||||
add_dependencies(simplewallet version)
|
||||
target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} dl)
|
||||
target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
|
||||
ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET)
|
||||
ENABLE_SHARED_PCH_EXECUTABLE(simplewallet)
|
||||
|
|
|
|||
|
|
@ -86,6 +86,9 @@ BLOB_SERIALIZER(crypto::secret_key);
|
|||
BLOB_SERIALIZER(crypto::key_derivation);
|
||||
BLOB_SERIALIZER(crypto::key_image);
|
||||
BLOB_SERIALIZER(crypto::signature);
|
||||
BLOB_SERIALIZER(crypto::scalar_t);
|
||||
BLOB_SERIALIZER(crypto::point_t);
|
||||
|
||||
VARIANT_TAG(debug_archive, crypto::hash, "hash");
|
||||
VARIANT_TAG(debug_archive, crypto::public_key, "public_key");
|
||||
VARIANT_TAG(debug_archive, crypto::secret_key, "secret_key");
|
||||
|
|
@ -134,5 +137,15 @@ namespace boost
|
|||
{
|
||||
a & reinterpret_cast<char (&)[sizeof(crypto::hash)]>(x);
|
||||
}
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, crypto::scalar_t &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & reinterpret_cast<char (&)[sizeof(crypto::scalar_t)]>(x);
|
||||
}
|
||||
template <class Archive>
|
||||
inline void serialize(Archive &a, crypto::point_t &x, const boost::serialization::version_type ver)
|
||||
{
|
||||
a & reinterpret_cast<char (&)[sizeof(crypto::point_t)]>(x);
|
||||
}
|
||||
} // namespace serialization
|
||||
} // namespace boost
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ namespace crypto
|
|||
//
|
||||
// scalar_t - holds a 256-bit scalar, normally in [0..L-1]
|
||||
//
|
||||
struct alignas(32) scalar_t
|
||||
struct /* TODO alignas(32) */ scalar_t
|
||||
{
|
||||
union
|
||||
{
|
||||
|
|
|
|||
|
|
@ -746,6 +746,11 @@ bool blockchain_storage::purge_transaction_keyimages_from_blockchain(const trans
|
|||
{
|
||||
return this->operator()(static_cast<const txin_to_key&>(inp));
|
||||
}
|
||||
bool operator()(const txin_zarcanum_inputs& inp) const
|
||||
{
|
||||
// TODO: #@#@
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
for(const txin_v& in : tx.vin)
|
||||
|
|
@ -1619,13 +1624,13 @@ bool blockchain_storage::purge_keyimage_from_big_heap(const crypto::key_image& k
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::purge_altblock_keyimages_from_big_heap(const block& b, const crypto::hash& id)
|
||||
bool blockchain_storage::purge_altblock_keyimages_from_big_heap(const block& b, const crypto::hash& block_id)
|
||||
{
|
||||
if (is_pos_block(b))
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(b.miner_tx.vin.size()>=2, false, "paranoid check failed");
|
||||
CHECK_AND_ASSERT_MES(b.miner_tx.vin[1].type() == typeid(txin_to_key), false, "paranoid type check failed");
|
||||
purge_keyimage_from_big_heap(boost::get<txin_to_key>(b.miner_tx.vin[1]).k_image, id);
|
||||
purge_keyimage_from_big_heap(boost::get<txin_to_key>(b.miner_tx.vin[1]).k_image, block_id);
|
||||
}
|
||||
for (auto tx_id : b.tx_hashes)
|
||||
{
|
||||
|
|
@ -1639,7 +1644,14 @@ bool blockchain_storage::purge_altblock_keyimages_from_big_heap(const block& b,
|
|||
{
|
||||
if (tx.vin[n].type() == typeid(txin_to_key) || tx.vin[n].type() == typeid(txin_htlc))
|
||||
{
|
||||
purge_keyimage_from_big_heap(get_to_key_input_from_txin_v(tx.vin[n]).k_image, id);
|
||||
purge_keyimage_from_big_heap(get_to_key_input_from_txin_v(tx.vin[n]).k_image, block_id);
|
||||
}
|
||||
else if (tx.vin[n].type() == typeid(txin_zarcanum_inputs))
|
||||
{
|
||||
// TODO @#@# consider refactoring
|
||||
const txin_zarcanum_inputs& zins = boost::get<txin_zarcanum_inputs>(tx.vin[n]);
|
||||
for(const auto& el : zins.elements)
|
||||
purge_keyimage_from_big_heap(el.key_image, block_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2622,6 +2634,9 @@ bool blockchain_storage::update_spent_tx_flags_for_input(uint64_t amount, const
|
|||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::update_spent_tx_flags_for_input(uint64_t amount, uint64_t global_index, bool spent)
|
||||
{
|
||||
if (amount == 0)
|
||||
return true; // fallback for hidden amounts
|
||||
|
||||
CRITICAL_REGION_LOCAL(m_read_lock);
|
||||
uint64_t outs_count = m_db_outputs.get_item_size(amount);
|
||||
CHECK_AND_ASSERT_MES(outs_count, false, "Amount " << amount << " have not found during update_spent_tx_flags_for_input()");
|
||||
|
|
@ -3863,10 +3878,9 @@ namespace currency
|
|||
m_bl_height(bl_height),
|
||||
m_mixins_count(mixins_count)
|
||||
{}
|
||||
bool operator()(const txin_to_key& in) const
|
||||
{
|
||||
const crypto::key_image& ki = in.k_image;
|
||||
|
||||
bool visit(uint64_t amount, const crypto::key_image& ki, const std::vector<txout_ref_v>& key_offsets) const
|
||||
{
|
||||
auto ki_ptr = m_db_spent_keys.get(ki);
|
||||
if (ki_ptr)
|
||||
{
|
||||
|
|
@ -3876,20 +3890,25 @@ namespace currency
|
|||
}
|
||||
m_db_spent_keys.set(ki, m_bl_height);
|
||||
|
||||
if (in.key_offsets.size() == 1)
|
||||
if (key_offsets.size() == 1)
|
||||
{
|
||||
//direct spend detected
|
||||
if (!m_bcs.update_spent_tx_flags_for_input(in.amount, in.key_offsets[0], true))
|
||||
if (!m_bcs.update_spent_tx_flags_for_input(amount, key_offsets[0], true))
|
||||
{
|
||||
//internal error
|
||||
LOG_PRINT_RED_L0("Failed to update_spent_tx_flags_for_input");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_mixins_count < in.key_offsets.size())
|
||||
m_mixins_count = in.key_offsets.size();
|
||||
if (m_mixins_count < key_offsets.size())
|
||||
m_mixins_count = key_offsets.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool operator()(const txin_to_key& in) const
|
||||
{
|
||||
return visit(in.amount, in.k_image, in.key_offsets);
|
||||
}
|
||||
bool operator()(const txin_htlc& in) const
|
||||
{
|
||||
if (!m_bcs.is_hardfork_active(3))
|
||||
|
|
@ -3911,6 +3930,16 @@ namespace currency
|
|||
}
|
||||
return true;
|
||||
}
|
||||
bool operator()(const txin_zarcanum_inputs& in) const
|
||||
{
|
||||
// TODO: @#@# should check for hardfork here?
|
||||
for(auto& el : in.elements)
|
||||
{
|
||||
if (!visit(0, el.key_image, el.key_offsets))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -4260,6 +4289,15 @@ bool blockchain_storage::have_tx_keyimges_as_spent(const transaction &tx) const
|
|||
if (is_multisig_output_spent(boost::get<const txin_multisig>(in).multisig_out_id))
|
||||
return true;
|
||||
}
|
||||
else if (in.type() == typeid(txin_zarcanum_inputs))
|
||||
{
|
||||
const auto& zins = boost::get<txin_zarcanum_inputs>(in);
|
||||
for(auto& el: zins.elements)
|
||||
{
|
||||
if (have_tx_keyimg_as_spent(el.key_image))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (in.type() == typeid(txin_gen))
|
||||
{
|
||||
// skip txin_gen
|
||||
|
|
@ -4863,12 +4901,29 @@ std::shared_ptr<const transaction_chain_entry> blockchain_storage::find_key_imag
|
|||
{
|
||||
if (get_to_key_input_from_txin_v(in).k_image == ki)
|
||||
{
|
||||
id_result = get_transaction_hash(tx_chain_entry->tx);
|
||||
id_result = get_transaction_hash(tx_chain_entry->tx); // ??? @#@# why not just use tx_id ?
|
||||
return tx_chain_entry;
|
||||
}
|
||||
}
|
||||
else if (in.type() == typeid(txin_zarcanum_inputs))
|
||||
{
|
||||
const auto& zins = boost::get<txin_zarcanum_inputs>(in);
|
||||
for(auto& el: zins.elements)
|
||||
{
|
||||
if (el.key_image == ki)
|
||||
{
|
||||
id_result = tx_id;
|
||||
return tx_chain_entry;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// got here, but found nothing -- log such suspicious event
|
||||
CHECK_AND_ASSERT_THROW_MES(block_entry != nullptr, "invalid block_entry");
|
||||
LOG_PRINT_YELLOW("find_key_image_and_related_tx: failed to find key image " << ki << " in block " << get_block_hash(block_entry->bl), LOG_LEVEL_1);
|
||||
|
||||
return std::shared_ptr<const transaction_chain_entry>();
|
||||
}
|
||||
//------------------------------------------------------------------
|
||||
|
|
@ -5015,6 +5070,12 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
|
|||
return true;
|
||||
};
|
||||
|
||||
auto is_allowed_before_hardfork4 = [&](const payload_items_v& el) -> bool
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(el.type() != typeid(zarcanum_tx_data_v1), false, "tx " << tx_id << " contains zarcanum_tx_data_v1 which is not allowed on height " << block_height);
|
||||
return true;
|
||||
};
|
||||
|
||||
bool var_is_after_hardfork_1_zone = m_core_runtime_config.is_hardfork_active_for_height(1, block_height);
|
||||
bool var_is_after_hardfork_2_zone = m_core_runtime_config.is_hardfork_active_for_height(2, block_height);
|
||||
bool var_is_after_hardfork_3_zone = m_core_runtime_config.is_hardfork_active_for_height(3, block_height);
|
||||
|
|
@ -5023,17 +5084,22 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
|
|||
//inputs
|
||||
for (const auto in : tx.vin)
|
||||
{
|
||||
if (in.type() == typeid(txin_htlc))
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(in);
|
||||
VARIANT_CASE_CONST(txin_htlc, in_htlc)
|
||||
if (!var_is_after_hardfork_3_zone)
|
||||
return false;
|
||||
}
|
||||
VARIANT_CASE_CONST(txin_zarcanum_inputs, in_zins)
|
||||
if (!var_is_after_hardfork_4_zone)
|
||||
return false;
|
||||
VARIANT_SWITCH_END();
|
||||
}
|
||||
//outputs
|
||||
for (const auto out : tx.vout)
|
||||
{
|
||||
VARIANT_SWITCH_BEGIN(out);
|
||||
VARIANT_CASE_CONST(tx_out_bare, o)
|
||||
if (var_is_after_hardfork_4_zone)
|
||||
return false; // bare outputs are not allowed after HF4
|
||||
if (o.target.type() == typeid(txout_htlc))
|
||||
{
|
||||
if (!var_is_after_hardfork_3_zone)
|
||||
|
|
@ -5052,6 +5118,8 @@ bool blockchain_storage::validate_tx_for_hardfork_specific_terms(const transacti
|
|||
return false;
|
||||
if (!var_is_after_hardfork_2_zone && !is_allowed_before_hardfork2(el))
|
||||
return false;
|
||||
if (!var_is_after_hardfork_4_zone && !is_allowed_before_hardfork4(el))
|
||||
return false;
|
||||
}
|
||||
|
||||
//attachments
|
||||
|
|
|
|||
|
|
@ -588,7 +588,7 @@ namespace currency
|
|||
bool handle_alternative_block(const block& b, const crypto::hash& id, block_verification_context& bvc);
|
||||
bool is_reorganize_required(const block_extended_info& main_chain_bei, const alt_chain_type& alt_chain, const crypto::hash& proof_alt);
|
||||
wide_difficulty_type get_x_difficulty_after_height(uint64_t height, bool is_pos);
|
||||
bool purge_keyimage_from_big_heap(const crypto::key_image& ki, const crypto::hash& id);
|
||||
bool purge_keyimage_from_big_heap(const crypto::key_image& ki, const crypto::hash& block_id);
|
||||
bool purge_altblock_keyimages_from_big_heap(const block& b, const crypto::hash& id);
|
||||
bool append_altblock_keyimages_to_big_heap(const crypto::hash& block_id, const std::unordered_set<crypto::key_image>& alt_block_keyimages);
|
||||
bool validate_alt_block_input(const transaction& input_tx,
|
||||
|
|
|
|||
|
|
@ -219,7 +219,7 @@ namespace currency
|
|||
{
|
||||
uint64_t amount;
|
||||
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
|
||||
std::vector<txin_etc_details_v> etc_details; // see also TX_FLAG_SIGNATURE_MODE_SEPARATE
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
VARINT_FIELD(amount)
|
||||
|
|
@ -253,35 +253,6 @@ namespace currency
|
|||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct tx_in_zarcanum : public referring_input
|
||||
{
|
||||
tx_in_zarcanum() {}
|
||||
|
||||
// Boost's Assignable concept
|
||||
tx_in_zarcanum(const tx_in_zarcanum&) = default;
|
||||
tx_in_zarcanum& operator=(const tx_in_zarcanum&)= default;
|
||||
|
||||
crypto::key_image key_image;
|
||||
crypto::public_key real_out_amount_commitment;
|
||||
std::vector<txin_etc_details_v> etc_details;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(key_image)
|
||||
FIELD(real_out_amount_commitment)
|
||||
FIELD(key_offsets) // referring_input
|
||||
FIELD(etc_details)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(key_image)
|
||||
BOOST_SERIALIZE(real_out_amount_commitment)
|
||||
BOOST_SERIALIZE(key_offsets) // referring_input
|
||||
BOOST_SERIALIZE(etc_details)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
struct txout_multisig
|
||||
{
|
||||
|
|
@ -313,8 +284,6 @@ namespace currency
|
|||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
typedef boost::variant<txin_gen, txin_to_key, txin_multisig, txin_htlc> txin_v;
|
||||
|
||||
typedef boost::variant<txout_to_key, txout_multisig, txout_htlc> txout_target_v;
|
||||
|
||||
//typedef std::pair<uint64_t, txout> out_t;
|
||||
|
|
@ -330,7 +299,53 @@ namespace currency
|
|||
};
|
||||
|
||||
|
||||
#pragma pack(push, 1)
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Zarcanum structures
|
||||
//
|
||||
//#pragma pack(push, 1)
|
||||
struct zarcanum_input : public referring_input
|
||||
{
|
||||
zarcanum_input() {}
|
||||
// Boost's Assignable concept
|
||||
zarcanum_input(const zarcanum_input&) = default;
|
||||
zarcanum_input& operator=(const zarcanum_input&)= default;
|
||||
|
||||
crypto::key_image key_image;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(key_image)
|
||||
FIELD(key_offsets) // referring_input
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(key_image)
|
||||
BOOST_SERIALIZE(key_offsets) // referring_input
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
// txin_zarcanum_inputs contains several zarcanum_input instances and corresponds to one zarcanum_sig
|
||||
struct txin_zarcanum_inputs
|
||||
{
|
||||
txin_zarcanum_inputs() {}
|
||||
|
||||
// Boost's Assignable concept
|
||||
txin_zarcanum_inputs(const txin_zarcanum_inputs&) = default;
|
||||
txin_zarcanum_inputs& operator=(const txin_zarcanum_inputs&) = default;
|
||||
|
||||
std::vector<zarcanum_input> elements;
|
||||
std::vector<txin_etc_details_v> etc_details;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(elements)
|
||||
FIELD(etc_details)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(elements)
|
||||
BOOST_SERIALIZE(etc_details)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
struct tx_out_zarcanum
|
||||
{
|
||||
tx_out_zarcanum() {}
|
||||
|
|
@ -340,28 +355,71 @@ namespace currency
|
|||
tx_out_zarcanum& operator=(const tx_out_zarcanum&) = default;
|
||||
|
||||
crypto::public_key stealth_address;
|
||||
crypto::public_key concealing_point;
|
||||
crypto::public_key commitment;
|
||||
crypto::public_key concealing_point; // group element Q, see also Zarcanum paper
|
||||
crypto::public_key amount_commitment;
|
||||
uint64_t encrypted_amount;
|
||||
uint64_t token_id = 0;
|
||||
//crypto::public_key token_masked_generator;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(stealth_address)
|
||||
FIELD(concealing_point)
|
||||
FIELD(commitment)
|
||||
FIELD(amount_commitment)
|
||||
FIELD(encrypted_amount)
|
||||
FIELD(token_id)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(stealth_address)
|
||||
BOOST_SERIALIZE(concealing_point)
|
||||
BOOST_SERIALIZE(commitment)
|
||||
BOOST_SERIALIZE(amount_commitment)
|
||||
BOOST_SERIALIZE(encrypted_amount)
|
||||
BOOST_SERIALIZE(token_id)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
struct zarcanum_tx_data_v1
|
||||
{
|
||||
uint64_t fee;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(fee)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(fee)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
struct zarcanum_sig
|
||||
{
|
||||
struct input_proofs_t
|
||||
{
|
||||
crypto::public_key real_out_amount_commitment;
|
||||
// crypto::public_key real_out_token_masked_generator;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(real_out_amount_commitment)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(real_out_amount_commitment)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
crypto::bpp_signature_serialized outputs_range_proof; // aggregated range proof for some or all outputs
|
||||
std::vector<input_proofs_t> input_proofs; // for each input
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(outputs_range_proof)
|
||||
FIELD(input_proofs)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(outputs_range_proof)
|
||||
BOOST_SERIALIZE(input_proofs)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
//#pragma pack(pop)
|
||||
|
||||
typedef boost::variant<txin_gen, txin_to_key, txin_multisig, txin_htlc, txin_zarcanum_inputs> txin_v;
|
||||
|
||||
typedef boost::variant<tx_out_bare, tx_out_zarcanum> tx_out_v;
|
||||
|
||||
|
|
@ -628,10 +686,10 @@ namespace currency
|
|||
END_SERIALIZE()
|
||||
};
|
||||
|
||||
typedef boost::mpl::vector21<
|
||||
typedef boost::mpl::vector22<
|
||||
tx_service_attachment, tx_comment, tx_payer_old, tx_receiver_old, tx_derivation_hint, std::string, tx_crypto_checksum, etc_tx_time, etc_tx_details_unlock_time, etc_tx_details_expiration_time,
|
||||
etc_tx_details_flags, crypto::public_key, extra_attachment_info, extra_alias_entry_old, extra_user_data, extra_padding, etc_tx_flags16_t, etc_tx_details_unlock_time2,
|
||||
tx_payer, tx_receiver, extra_alias_entry
|
||||
tx_payer, tx_receiver, extra_alias_entry, zarcanum_tx_data_v1
|
||||
> all_payload_types;
|
||||
|
||||
typedef boost::make_variant_over<all_payload_types>::type payload_items_v;
|
||||
|
|
@ -639,21 +697,7 @@ namespace currency
|
|||
typedef payload_items_v attachment_v;
|
||||
|
||||
|
||||
struct zarcanum_tx_data_v1
|
||||
{
|
||||
uint64_t fee;
|
||||
std::vector<crypto::bpp_signature_serialized> range_proofs_for_outputs;
|
||||
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
FIELD(fee)
|
||||
FIELD(range_proofs_for_outputs)
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
BOOST_SERIALIZE(fee)
|
||||
BOOST_SERIALIZE(range_proofs_for_outputs)
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
//classic CryptoNote signature by Nicolas Van Saberhagen
|
||||
struct NLSAG_sig
|
||||
|
|
@ -669,16 +713,6 @@ namespace currency
|
|||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
struct zarcanum_sig
|
||||
{
|
||||
//TODO:
|
||||
BEGIN_SERIALIZE_OBJECT()
|
||||
END_SERIALIZE()
|
||||
|
||||
BEGIN_BOOST_SERIALIZATION()
|
||||
END_BOOST_SERIALIZATION()
|
||||
};
|
||||
|
||||
//TODO: @val, should we call it something like schnorr_sig ?
|
||||
struct simple_sig
|
||||
{
|
||||
|
|
@ -963,7 +997,7 @@ SET_VARIANT_TAGS(currency::txout_htlc, 35, "txout_htlc");
|
|||
SET_VARIANT_TAGS(currency::tx_out_bare, 36, "tx_out_bare");
|
||||
|
||||
// Zarcanum
|
||||
SET_VARIANT_TAGS(currency::tx_in_zarcanum, 37, "tx_in_zarcanum");
|
||||
SET_VARIANT_TAGS(currency::txin_zarcanum_inputs, 37, "txin_zarcanum_inputs");
|
||||
SET_VARIANT_TAGS(currency::tx_out_zarcanum, 38, "tx_out_zarcanum");
|
||||
SET_VARIANT_TAGS(currency::zarcanum_tx_data_v1, 39, "zarcanum_tx_data_v1");
|
||||
SET_VARIANT_TAGS(crypto::bpp_signature_serialized, 40, "bpp_signature_serialized");
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ namespace boost
|
|||
{
|
||||
a & x.stealth_address;
|
||||
a & x.concealing_point;
|
||||
a & x.commitment;
|
||||
a & x.amount_commitment;
|
||||
a & x.encrypted_amount;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2605,9 +2605,9 @@ namespace currency
|
|||
pfinalbuff = &deflated_buff;
|
||||
}
|
||||
if (ee.service_id == BC_PAYMENT_ID_SERVICE_ID || ee.service_id == BC_OFFERS_SERVICE_ID)
|
||||
tv.datails_view = *pfinalbuff;
|
||||
tv.details_view = *pfinalbuff;
|
||||
else
|
||||
tv.datails_view = "BINARY DATA";
|
||||
tv.details_view = "BINARY DATA";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2615,7 +2615,7 @@ namespace currency
|
|||
{
|
||||
tv.type = "crypto_checksum";
|
||||
tv.short_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash);
|
||||
tv.datails_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash) + "\n"
|
||||
tv.details_view = std::string("derivation_hash: ") + epee::string_tools::pod_to_hex(ee.derivation_hash) + "\n"
|
||||
+ "encrypted_key_derivation: " + epee::string_tools::pod_to_hex(ee.encrypted_key_derivation);
|
||||
|
||||
return true;
|
||||
|
|
@ -2676,14 +2676,14 @@ namespace currency
|
|||
{
|
||||
tv.type = "attachment_info";
|
||||
tv.short_view = std::to_string(ee.sz) + " bytes";
|
||||
tv.datails_view = currency::obj_to_json_str(ee);
|
||||
tv.details_view = currency::obj_to_json_str(ee);
|
||||
return true;
|
||||
}
|
||||
bool operator()(const extra_alias_entry& ee)
|
||||
{
|
||||
tv.type = "alias_info";
|
||||
tv.short_view = ee.m_alias + "-->" + get_account_address_as_str(ee.m_address);
|
||||
tv.datails_view = currency::obj_to_json_str(ee);
|
||||
tv.details_view = currency::obj_to_json_str(ee);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2695,7 +2695,7 @@ namespace currency
|
|||
{
|
||||
tv.type = "user_data";
|
||||
tv.short_view = std::to_string(ee.buff.size()) + " bytes";
|
||||
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.buff);
|
||||
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.buff);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2704,7 +2704,7 @@ namespace currency
|
|||
tv.type = "extra_padding";
|
||||
tv.short_view = std::to_string(ee.buff.size()) + " bytes";
|
||||
if (!ee.buff.empty())
|
||||
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(&ee.buff[0]), ee.buff.size()));
|
||||
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(std::string(reinterpret_cast<const char*>(&ee.buff[0]), ee.buff.size()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2712,7 +2712,7 @@ namespace currency
|
|||
{
|
||||
tv.type = "comment";
|
||||
tv.short_view = std::to_string(ee.comment.size()) + " bytes(encrypted)";
|
||||
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.comment);
|
||||
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.comment);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2750,7 +2750,7 @@ namespace currency
|
|||
{
|
||||
tv.type = "derivation_hint";
|
||||
tv.short_view = std::to_string(ee.msg.size()) + " bytes";
|
||||
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee.msg);
|
||||
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee.msg);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2758,7 +2758,7 @@ namespace currency
|
|||
{
|
||||
tv.type = "string";
|
||||
tv.short_view = std::to_string(ee.size()) + " bytes";
|
||||
tv.datails_view = epee::string_tools::buff_to_hex_nodelimer(ee);
|
||||
tv.details_view = epee::string_tools::buff_to_hex_nodelimer(ee);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -2766,10 +2766,17 @@ namespace currency
|
|||
{
|
||||
tv.type = "FLAGS16";
|
||||
tv.short_view = epee::string_tools::pod_to_hex(dh);
|
||||
tv.datails_view = epee::string_tools::pod_to_hex(dh);
|
||||
tv.details_view = epee::string_tools::pod_to_hex(dh);
|
||||
|
||||
return true;
|
||||
}
|
||||
bool operator()(const zarcanum_tx_data_v1& ztxd)
|
||||
{
|
||||
tv.type = "zarcanum_tx_data_v1";
|
||||
tv.short_view = "fee = " + print_money_brief(ztxd.fee);
|
||||
tv.details_view = tv.short_view;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
//------------------------------------------------------------------
|
||||
template<class t_container>
|
||||
|
|
|
|||
|
|
@ -374,21 +374,21 @@ namespace currency
|
|||
std::string get_word_from_timstamp(uint64_t timestamp, bool use_password);
|
||||
uint64_t get_timstamp_from_word(std::string word, bool& password_used);
|
||||
std::string generate_origin_for_htlc(const txout_htlc& htlc, const account_keys& acc_keys);
|
||||
|
||||
template<class t_txin_v>
|
||||
typename std::conditional<std::is_const<t_txin_v>::value, const std::vector<txin_etc_details_v>, std::vector<txin_etc_details_v> >::type& get_txin_etc_options(t_txin_v& in)
|
||||
{
|
||||
static typename std::conditional<std::is_const<t_txin_v>::value, const std::vector<txin_etc_details_v>, std::vector<txin_etc_details_v> >::type stub;
|
||||
|
||||
|
||||
//static stub;
|
||||
|
||||
if (in.type() == typeid(txin_to_key))
|
||||
return boost::get<txin_to_key>(in).etc_details;
|
||||
else if (in.type() == typeid(txin_htlc))
|
||||
return boost::get<txin_htlc>(in).etc_details;
|
||||
else if (in.type() == typeid(txin_multisig))
|
||||
return boost::get<txin_multisig>(in).etc_details;
|
||||
else
|
||||
else if (in.type() == typeid(txin_htlc))
|
||||
return boost::get<txin_htlc>(in).etc_details;
|
||||
else if (in.type() == typeid(txin_zarcanum_inputs))
|
||||
return boost::get<txin_zarcanum_inputs>(in).etc_details;
|
||||
else
|
||||
return stub;
|
||||
}
|
||||
|
||||
|
|
@ -663,45 +663,42 @@ namespace currency
|
|||
{
|
||||
struct txin_signature_size_visitor : public boost::static_visitor<size_t>
|
||||
{
|
||||
size_t operator()(const txin_gen& /*txin*/) const { return 0; }
|
||||
size_t operator()(const txin_to_key& txin) const { return txin.key_offsets.size(); }
|
||||
size_t operator()(const txin_multisig& txin) const { return txin.sigs_count; }
|
||||
size_t operator()(const txin_htlc& txin) const { return 1; }
|
||||
size_t operator()(const tx_in_zarcanum& txin) const { throw std::runtime_error("Not implemented yet"); return 0; } //@#@
|
||||
size_t operator()(const txin_gen& /*txin*/) const { return 0; }
|
||||
size_t operator()(const txin_to_key& txin) const { return txin.key_offsets.size(); }
|
||||
size_t operator()(const txin_multisig& txin) const { return txin.sigs_count; }
|
||||
size_t operator()(const txin_htlc& txin) const { return 1; }
|
||||
size_t operator()(const txin_zarcanum_inputs& txin) const { throw std::runtime_error("Not implemented yet"); }
|
||||
};
|
||||
|
||||
return boost::apply_visitor(txin_signature_size_visitor(), tx_in);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
inline const std::vector<txin_etc_details_v>* get_input_etc_details(const txin_v& in)
|
||||
template<class txin_t>
|
||||
typename std::conditional<std::is_const<txin_t>::value, const std::vector<txin_etc_details_v>, std::vector<txin_etc_details_v> >::type*
|
||||
get_input_etc_details(txin_t& in)
|
||||
{
|
||||
if (in.type().hash_code() == typeid(txin_to_key).hash_code())
|
||||
if (in.type() == typeid(txin_to_key))
|
||||
return &boost::get<txin_to_key>(in).etc_details;
|
||||
if (in.type().hash_code() == typeid(txin_htlc).hash_code())
|
||||
return &boost::get<txin_htlc>(in).etc_details;
|
||||
if (in.type().hash_code() == typeid(txin_multisig).hash_code())
|
||||
if (in.type() == typeid(txin_multisig))
|
||||
return &boost::get<txin_multisig>(in).etc_details;
|
||||
if (in.type() == typeid(txin_htlc))
|
||||
return &boost::get<txin_htlc>(in).etc_details;
|
||||
if (in.type() == typeid(txin_zarcanum_inputs))
|
||||
return &boost::get<txin_zarcanum_inputs>(in).etc_details;
|
||||
return nullptr;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
inline std::vector<txin_etc_details_v>* get_input_etc_details(txin_v& in)
|
||||
{
|
||||
if (in.type().hash_code() == typeid(txin_to_key).hash_code())
|
||||
return &boost::get<txin_to_key>(in).etc_details;
|
||||
if (in.type().hash_code() == typeid(txin_htlc).hash_code())
|
||||
return &boost::get<txin_htlc>(in).etc_details;
|
||||
if (in.type().hash_code() == typeid(txin_multisig).hash_code())
|
||||
return &boost::get<txin_multisig>(in).etc_details;
|
||||
return nullptr;
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
struct input_amount_getter : public boost::static_visitor<uint64_t>
|
||||
{
|
||||
template<class t_input>
|
||||
uint64_t operator()(const t_input& i) const{return i.amount;}
|
||||
uint64_t operator()(const txin_gen& i) const {return 0;}
|
||||
uint64_t operator()(const t_input& i) const { return i.amount; }
|
||||
uint64_t operator()(const txin_zarcanum_inputs&) const { return 0; }
|
||||
uint64_t operator()(const txin_gen& i) const { return 0; }
|
||||
};
|
||||
inline uint64_t get_amount_from_variant(const txin_v& v)
|
||||
{
|
||||
return boost::apply_visitor(input_amount_getter(), v);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
inline const tx_out_bare& get_tx_out_bare_from_out_v(const tx_out_v& o)
|
||||
{
|
||||
|
|
@ -709,11 +706,6 @@ namespace currency
|
|||
return boost::get<tx_out_bare>(o);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
inline uint64_t get_amount_from_variant(const txin_v& v)
|
||||
{
|
||||
return boost::apply_visitor(input_amount_getter(), v);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
template <typename container_t>
|
||||
void create_and_add_tx_payer_to_container_from_address(container_t& container, const account_public_address& addr, uint64_t top_block_height, const core_runtime_config& crc)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1217,11 +1217,11 @@ namespace currency
|
|||
{
|
||||
std::string type;
|
||||
std::string short_view;
|
||||
std::string datails_view;
|
||||
std::string details_view;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(type)
|
||||
KV_SERIALIZE(short_view)
|
||||
KV_SERIALIZE(datails_view)
|
||||
KV_SERIALIZE(details_view)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue