forked from lthn/blockchain
Merge branch 'develop' into develop_test
This commit is contained in:
commit
937301997a
14 changed files with 89 additions and 127 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -5,4 +5,5 @@
|
|||
._.DS_Store
|
||||
Thumbs.db
|
||||
._*
|
||||
.idea
|
||||
.idea
|
||||
.vs/*
|
||||
|
|
@ -102,7 +102,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_definitions("/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0 /D__SSE4_1__")
|
||||
add_definitions("/D_CRT_SECURE_NO_WARNINGS /D_WIN32_WINNT=0x0600 /DWIN32_LEAN_AND_MEAN /DGTEST_HAS_TR1_TUPLE=0")
|
||||
add_compile_options(/bigobj /Zm1000 /Z7 /MP2 /W3 /GS- /wd4996 /wd4503 /wd4345 /wd4091 /FIinline_c.h)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:10485760 /DEBUG dbghelp.lib crypt32.lib")
|
||||
if(STATIC)
|
||||
|
|
@ -224,7 +224,7 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|||
elseif(APPLE)
|
||||
find_package(Boost 1.71 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale)
|
||||
else()
|
||||
find_package(Boost 1.70 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale)
|
||||
find_package(Boost 1.70 REQUIRED COMPONENTS system filesystem thread timer date_time chrono regex serialization atomic program_options locale log)
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ endif()
|
|||
set_property(TARGET upnpc-static mdbx_chk mdbx_copy mdbx_dump mdbx_load mdbx_stat PROPERTY FOLDER "unused")
|
||||
|
||||
if(MSVC)
|
||||
set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused")
|
||||
#set_property(TARGET ntdll_extra_target PROPERTY FOLDER "unused")
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -45,61 +45,6 @@ if(CC_HAS_VISIBILITY AND (LTO_ENABLED OR INTERPROCEDURAL_OPTIMIZATION))
|
|||
set_target_properties(mdbx PROPERTIES LINK_FLAGS "-fvisibility=hidden")
|
||||
endif()
|
||||
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
if(MSVC)
|
||||
if(NOT MSVC_LIB_EXE)
|
||||
# Find lib.exe
|
||||
get_filename_component(CL_NAME ${CMAKE_C_COMPILER} NAME)
|
||||
string(REPLACE cl.exe lib.exe MSVC_LIB_EXE ${CL_NAME})
|
||||
find_program(MSVC_LIB_EXE ${MSVC_LIB_EXE})
|
||||
endif()
|
||||
if(MSVC_LIB_EXE)
|
||||
message(STATUS "Found MSVC's lib tool: ${MSVC_LIB_EXE}")
|
||||
set(MDBX_NTDLL_EXTRA_IMPLIB ${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.lib)
|
||||
add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB}
|
||||
COMMENT "Create extra-import-library for ntdll.dll"
|
||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def"
|
||||
COMMAND ${MSVC_LIB_EXE} /def:"${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" /out:"${MDBX_NTDLL_EXTRA_IMPLIB}" ${INITIAL_CMAKE_STATIC_LINKER_FLAGS})
|
||||
else()
|
||||
message(SEND_ERROR "MSVC's lib tool not found")
|
||||
endif()
|
||||
elseif(MINGW OR MINGW64)
|
||||
if(NOT DLLTOOL)
|
||||
# Find dlltool
|
||||
get_filename_component(GCC_NAME ${CMAKE_C_COMPILER} NAME)
|
||||
string(REPLACE gcc dlltool DLLTOOL_NAME ${GCC_NAME})
|
||||
find_program(DLLTOOL NAMES ${DLLTOOL_NAME})
|
||||
endif()
|
||||
if(DLLTOOL)
|
||||
message(STATUS "Found dlltool: ${DLLTOOL}")
|
||||
set(MDBX_NTDLL_EXTRA_IMPLIB "${CMAKE_CURRENT_BINARY_DIR}/mdbx_ntdll_extra.a")
|
||||
add_custom_command(OUTPUT ${MDBX_NTDLL_EXTRA_IMPLIB}
|
||||
COMMENT "Create extra-import-library for ntdll.dll"
|
||||
MAIN_DEPENDENCY "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def"
|
||||
COMMAND ${DLLTOOL} -d "${CMAKE_CURRENT_SOURCE_DIR}/elements/ntdll.def" -l "${MDBX_NTDLL_EXTRA_IMPLIB}")
|
||||
else()
|
||||
message(SEND_ERROR "dlltool not found")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ${CMAKE_THREAD_LIBS_INIT})
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
|
||||
target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ntdll.lib)
|
||||
if(MDBX_NTDLL_EXTRA_IMPLIB)
|
||||
# LY: Sometimes Cmake requires a nightmarish magic for simple things.
|
||||
# 1) create a target out of the library compilation result
|
||||
add_custom_target(ntdll_extra_target DEPENDS ${MDBX_NTDLL_EXTRA_IMPLIB})
|
||||
# 2) create an library target out of the library compilation result
|
||||
add_library(ntdll_extra STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(ntdll_extra ntdll_extra_target)
|
||||
# 3) specify where the library is (and where to find the headers)
|
||||
set_target_properties(ntdll_extra
|
||||
PROPERTIES
|
||||
IMPORTED_LOCATION ${MDBX_NTDLL_EXTRA_IMPLIB})
|
||||
target_link_libraries(mdbx ${MDBX_LIBDEP_MODE} ntdll_extra)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties(mdbx PROPERTIES
|
||||
INTERPROCEDURAL_OPTIMIZATION $<BOOL:${INTERPROCEDURAL_OPTIMIZATION}>
|
||||
|
|
|
|||
|
|
@ -137,11 +137,17 @@ namespace tools
|
|||
|
||||
STACKFRAME64 frame;
|
||||
memset(&frame, 0, sizeof frame);
|
||||
#ifndef _M_ARM64
|
||||
frame.AddrPC.Offset = context.Rip;
|
||||
#endif
|
||||
frame.AddrPC.Mode = AddrModeFlat;
|
||||
#ifndef _M_ARM64
|
||||
frame.AddrStack.Offset = context.Rsp;
|
||||
#endif
|
||||
frame.AddrStack.Mode = AddrModeFlat;
|
||||
#ifndef _M_ARM64
|
||||
frame.AddrFrame.Offset = context.Rbp;
|
||||
#endif
|
||||
frame.AddrFrame.Mode = AddrModeFlat;
|
||||
|
||||
IMAGEHLP_LINE64 line = { 0 };
|
||||
|
|
|
|||
|
|
@ -1166,6 +1166,11 @@ namespace crypto
|
|||
return scalar_t(crypto::cn_fast_hash(str.c_str(), str.size())); // will reduce mod L
|
||||
}
|
||||
|
||||
static hash h(const std::string& str)
|
||||
{
|
||||
return crypto::cn_fast_hash(str.c_str(), str.size());
|
||||
}
|
||||
|
||||
struct hs_t
|
||||
{
|
||||
hs_t(size_t size_to_reserve = 0)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "hash-ops.h"
|
||||
#include "malloc.h"
|
||||
|
||||
void tree_hash(const char (*hashes)[HASH_SIZE], size_t count, char *root_hash) {
|
||||
assert(count > 0);
|
||||
|
|
|
|||
|
|
@ -3828,14 +3828,7 @@ bool blockchain_storage::unprocess_blockchain_tx_extra(const transaction& tx)
|
|||
if (ei.m_asset_operation.operation_type != ASSET_DESCRIPTOR_OPERATION_UNDEFINED)
|
||||
{
|
||||
crypto::public_key asset_id = currency::null_pkey;
|
||||
if (ei.m_asset_operation.operation_type == ASSET_DESCRIPTOR_OPERATION_REGISTER)
|
||||
{
|
||||
calculate_asset_id(ei.m_asset_operation.descriptor.owner, nullptr, &asset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
CHECK_AND_NO_ASSERT_MES(false, false, "asset operation not implemented");
|
||||
}
|
||||
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ei.m_asset_operation, nullptr, &asset_id), false, "get_or_calculate_asset_id failed");
|
||||
r = pop_asset_info(asset_id);
|
||||
CHECK_AND_ASSERT_MES(r, false, "failed to pop_alias_info");
|
||||
}
|
||||
|
|
@ -4086,12 +4079,9 @@ bool blockchain_storage::pop_asset_info(const crypto::public_key& asset_id)
|
|||
//------------------------------------------------------------------
|
||||
bool blockchain_storage::validate_ado_ownership(asset_op_verification_context& avc)
|
||||
{
|
||||
// asset_id = AUTO_VAL_INIT(asset_id);
|
||||
// CHECK_AND_ASSERT_MES(validate_asset_operation_balance_proof(tx, tx_id, ado, asset_id), false, "asset operation validation failed!");
|
||||
asset_operation_ownership_proof aoop = AUTO_VAL_INIT(aoop);
|
||||
bool r = get_type_in_variant_container(avc.tx.proofs, aoop);
|
||||
CHECK_AND_ASSERT_MES(r, false, "Ownership validation failed - missing signature");
|
||||
|
||||
CHECK_AND_ASSERT_MES(r, false, "Ownership validation failed - missing signature (asset_operation_ownership_proof)");
|
||||
|
||||
CHECK_AND_ASSERT_MES(avc.asset_op_history->size() != 0, false, "asset with id " << avc.asset_id << " has invalid history size() == 0");
|
||||
|
||||
|
|
@ -4107,7 +4097,8 @@ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::has
|
|||
|
||||
if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_REGISTER)
|
||||
{
|
||||
calculate_asset_id(avc.ado.descriptor.owner, &avc.asset_id_pt, &avc.asset_id);
|
||||
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(avc.ado, &avc.asset_id_pt, &avc.asset_id), false, "get_or_calculate_asset_id failed");
|
||||
|
||||
avc.asset_op_history = m_db_assets.find(avc.asset_id);
|
||||
CHECK_AND_ASSERT_MES(!avc.asset_op_history, false, "asset with id " << avc.asset_id << " has already been registered");
|
||||
|
||||
|
|
@ -4121,10 +4112,8 @@ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::has
|
|||
}
|
||||
else
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(avc.ado.opt_asset_id, false, "asset_id not provided for asset altering operation");
|
||||
avc.asset_op_history = m_db_assets.find(*avc.ado.opt_asset_id);
|
||||
avc.asset_id = *avc.ado.opt_asset_id; // consider redisign
|
||||
avc.asset_id_pt.from_public_key(avc.asset_id);
|
||||
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(avc.ado, &avc.asset_id_pt, &avc.asset_id), false, "get_or_calculate_asset_id failed");
|
||||
avc.asset_op_history = m_db_assets.find(avc.asset_id);
|
||||
|
||||
CHECK_AND_ASSERT_MES(avc.asset_op_history && avc.asset_op_history->size(), false, "asset with id " << avc.asset_id << " has not been registered");
|
||||
// check ownership permission
|
||||
|
|
@ -4159,7 +4148,7 @@ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::has
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_ERROR("Unknown operation type: " << ado.operation_type);
|
||||
LOG_ERROR("Unknown operation type: " << (int)ado.operation_type);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -4171,7 +4160,7 @@ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::has
|
|||
|
||||
assets_container::t_value_type local_asset_history = *avc.asset_op_history;
|
||||
local_asset_history.push_back(ado);
|
||||
m_db_assets.set(*avc.ado.opt_asset_id, local_asset_history);
|
||||
m_db_assets.set(avc.asset_id, local_asset_history);
|
||||
|
||||
switch(ado.operation_type)
|
||||
{
|
||||
|
|
@ -4185,7 +4174,7 @@ bool blockchain_storage::put_asset_info(const transaction& tx, const crypto::has
|
|||
LOG_PRINT_MAGENTA("[ASSET_BURNT]: " << print_money_brief(avc.amount_to_validate, ado.descriptor.decimal_point) << ", " << avc.asset_id << ": " << ado.descriptor.ticker << ", \"" << ado.descriptor.full_name << "\"", LOG_LEVEL_1);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("Unknown operation type: " << ado.operation_type);
|
||||
LOG_ERROR("Unknown operation type: " << (int)ado.operation_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
// Copyright (c) 2014-2019 Zano Project
|
||||
// Copyright (c) 2014-2024 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Cryptonote developers
|
||||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
|
|
@ -10,7 +10,7 @@
|
|||
#ifndef TESTNET
|
||||
#define CURRENCY_FORMATION_VERSION 84
|
||||
#else
|
||||
#define CURRENCY_FORMATION_VERSION 96
|
||||
#define CURRENCY_FORMATION_VERSION 97
|
||||
#endif
|
||||
|
||||
#define CURRENCY_GENESIS_NONCE (CURRENCY_FORMATION_VERSION + 101011010121) //bender's nightmare
|
||||
|
|
|
|||
|
|
@ -171,17 +171,8 @@ namespace currency
|
|||
asset_descriptor_operation ado{};
|
||||
if (is_asset_emitting_transaction(tx, &ado))
|
||||
{
|
||||
crypto::point_t asset_id_pt = crypto::c_point_0;
|
||||
if (ado.opt_asset_id)
|
||||
{
|
||||
//emmit on existing asset, we SHOULD not calculate asset_id, instead we use the one provided
|
||||
//since the owner might have been changed since creation
|
||||
asset_id_pt = crypto::point_t(*ado.opt_asset_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
calculate_asset_id(ado.descriptor.owner, &asset_id_pt, nullptr); // TODO @#@# optimization: this expensive calculation should be done only once
|
||||
}
|
||||
crypto::point_t asset_id_pt{};
|
||||
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ado, &asset_id_pt, nullptr), false, "get_or_calculate_asset_id failed"); // TODO @#@# expensive operation, consider caching
|
||||
pseudo_outs_blinded_asset_ids.emplace_back(asset_id_pt); // additional ring member for asset emitting tx
|
||||
}
|
||||
|
||||
|
|
@ -2121,20 +2112,45 @@ namespace currency
|
|||
}
|
||||
|
||||
#define CRYPTO_HASH_ASSET_ID_ITERATIONS 1024
|
||||
void calculate_asset_id(const crypto::public_key& asset_owner, crypto::point_t* p_result_point, crypto::public_key* p_result_pub_key)
|
||||
bool get_or_calculate_asset_id(const asset_descriptor_operation& ado, crypto::point_t* p_result_point, crypto::public_key* p_result_pub_key)
|
||||
{
|
||||
crypto::hash h = get_hash_from_POD_objects(CRYPTO_HDS_ASSET_ID, asset_owner);
|
||||
if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMIT ||
|
||||
ado.operation_type == ASSET_DESCRIPTOR_OPERATION_UPDATE ||
|
||||
ado.operation_type == ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN )
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(ado.opt_asset_id.has_value(), false, "ado.opt_asset_id has no value, op: " << (int)ado.operation_type << ", " << get_asset_operation_type_string(ado.operation_type));
|
||||
//LOG_PRINT_YELLOW("ado.opt_asset_id = " << ado.opt_asset_id.get(), LOG_LEVEL_0);
|
||||
if (p_result_pub_key)
|
||||
*p_result_pub_key = ado.opt_asset_id.get();
|
||||
if (p_result_point)
|
||||
*p_result_point = crypto::point_t(ado.opt_asset_id.get());
|
||||
return true;
|
||||
}
|
||||
|
||||
// otherwise, calculate asset id
|
||||
|
||||
crypto::hash_helper_t::hs_t hsc;
|
||||
hsc.add_32_chars(CRYPTO_HDS_ASSET_ID);
|
||||
hsc.add_hash(crypto::hash_helper_t::h(ado.descriptor.ticker));
|
||||
hsc.add_hash(crypto::hash_helper_t::h(ado.descriptor.full_name));
|
||||
hsc.add_hash(crypto::hash_helper_t::h(ado.descriptor.meta_info));
|
||||
hsc.add_scalar(crypto::scalar_t(ado.descriptor.total_max_supply));
|
||||
hsc.add_scalar(crypto::scalar_t(ado.descriptor.decimal_point));
|
||||
hsc.add_pub_key(ado.descriptor.owner);
|
||||
crypto::hash h = hsc.calc_hash_no_reduce();
|
||||
|
||||
// this hash function needs to be computationally expensive (s.a. the whitepaper)
|
||||
for(uint64_t i = 0; i < CRYPTO_HASH_ASSET_ID_ITERATIONS; ++i)
|
||||
h = get_hash_from_POD_objects(CRYPTO_HDS_ASSET_ID, h, i);
|
||||
|
||||
crypto::point_t local_point{};
|
||||
if (!p_result_point)
|
||||
p_result_point = &local_point;
|
||||
*p_result_point = crypto::hash_helper_t::hp(&h, sizeof h);
|
||||
crypto::point_t result = crypto::hash_helper_t::hp(&h, sizeof h);
|
||||
if (p_result_point)
|
||||
*p_result_point = result;
|
||||
if (p_result_pub_key)
|
||||
p_result_point->to_public_key(*p_result_pub_key);
|
||||
result.to_public_key(*p_result_pub_key);
|
||||
|
||||
//LOG_PRINT_YELLOW("calculated asset_id = " << result, LOG_LEVEL_0);
|
||||
return true;
|
||||
}
|
||||
|
||||
const asset_descriptor_base& get_native_coin_asset_descriptor()
|
||||
|
|
@ -2168,13 +2184,17 @@ namespace currency
|
|||
//crypto::secret_key asset_control_key{};
|
||||
//bool r = derive_key_pair_from_key_pair(sender_account_keys.account_address.spend_public_key, tx_key.sec, asset_control_key, ado.descriptor.owner, CRYPTO_HDS_ASSET_CONTROL_KEY);
|
||||
//CHECK_AND_ASSERT_MES(r, false, "derive_key_pair_from_key_pair failed");
|
||||
//
|
||||
// old:
|
||||
// asset_control_key = Hs(CRYPTO_HDS_ASSET_CONTROL_KEY, 8 * tx_key.sec * sender_account_keys.account_address.spend_public_key, 0)
|
||||
// ado.descriptor.owner = asset_control_key * G
|
||||
|
||||
ado.descriptor.owner = sender_account_keys.account_address.spend_public_key;
|
||||
|
||||
calculate_asset_id(ado.descriptor.owner, &gen_context.ao_asset_id_pt, &gen_context.ao_asset_id);
|
||||
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ado, &gen_context.ao_asset_id_pt, &gen_context.ao_asset_id), false, "get_or_calculate_asset_id failed");
|
||||
|
||||
// calculate amount blinding mask
|
||||
gen_context.ao_amount_blinding_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_ASSET_CONTROL_ABM, tx_key.sec, tx_key.pub);
|
||||
gen_context.ao_amount_blinding_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_ASSET_CONTROL_ABM, tx_key.sec);
|
||||
|
||||
// set correct asset_id to the corresponding destination entries
|
||||
uint64_t amount_of_emitted_asset = 0;
|
||||
|
|
@ -2193,12 +2213,10 @@ namespace currency
|
|||
}
|
||||
else if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(ado.opt_asset_id, false, "ado.opt_asset_id is not found at ado.operation_type == ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN");
|
||||
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ado, &gen_context.ao_asset_id_pt, &gen_context.ao_asset_id), false, "get_or_calculate_asset_id failed");
|
||||
|
||||
gen_context.ao_asset_id = *ado.opt_asset_id;
|
||||
gen_context.ao_asset_id_pt.from_public_key(gen_context.ao_asset_id);
|
||||
// calculate amount blinding mask
|
||||
gen_context.ao_amount_blinding_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_ASSET_CONTROL_ABM, tx_key.sec, tx_key.pub);
|
||||
gen_context.ao_amount_blinding_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_ASSET_CONTROL_ABM, tx_key.sec);
|
||||
gen_context.ao_commitment_in_outputs = true;
|
||||
|
||||
// set correct asset_id to the corresponding destination entries
|
||||
|
|
@ -2230,12 +2248,10 @@ namespace currency
|
|||
{
|
||||
if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMIT)
|
||||
{
|
||||
CHECK_AND_ASSERT_MES(ado.opt_asset_id, false, "ado.opt_asset_id is not found at ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMIT");
|
||||
CHECK_AND_ASSERT_MES(get_or_calculate_asset_id(ado, &gen_context.ao_asset_id_pt, &gen_context.ao_asset_id), false, "get_or_calculate_asset_id failed");
|
||||
|
||||
gen_context.ao_asset_id = *ado.opt_asset_id;
|
||||
gen_context.ao_asset_id_pt.from_public_key(gen_context.ao_asset_id);
|
||||
// calculate amount blinding mask
|
||||
gen_context.ao_amount_blinding_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_ASSET_CONTROL_ABM, tx_key.sec, tx_key.pub);
|
||||
gen_context.ao_amount_blinding_mask = crypto::hash_helper_t::hs(CRYPTO_HDS_ASSET_CONTROL_ABM, tx_key.sec);
|
||||
|
||||
// set correct asset_id to the corresponding destination entries
|
||||
uint64_t amount_of_emitted_asset = 0;
|
||||
|
|
@ -2266,7 +2282,7 @@ namespace currency
|
|||
/*
|
||||
//seal it with owners signature
|
||||
crypto::signature sig = currency::null_sig;
|
||||
crypto::hash h = get_signature_hash_for_asset_operation(ado)
|
||||
crypto::hash h = get_signature_hash_for_asset_operation(ado);
|
||||
if (ftp.pthirdparty_sign_handler)
|
||||
{
|
||||
bool r = ftp.pthirdparty_sign_handler->sign(h, ftp.ado_current_asset_owner, sig);
|
||||
|
|
|
|||
|
|
@ -342,7 +342,7 @@ namespace currency
|
|||
|
||||
uint64_t get_tx_version(uint64_t tx_expected_block_height, const hard_forks_descriptor& hfd); // returns tx version based on the height of the block where the transaction is expected to be
|
||||
bool construct_tx(const account_keys& sender_account_keys, const finalize_tx_param& param, finalized_tx& result);
|
||||
void calculate_asset_id(const crypto::public_key& asset_owner, crypto::point_t* p_result_point, crypto::public_key* p_result_pub_key);
|
||||
bool get_or_calculate_asset_id(const asset_descriptor_operation& ado, crypto::point_t* p_result_point, crypto::public_key* p_result_pub_key);
|
||||
const asset_descriptor_base& get_native_coin_asset_descriptor();
|
||||
|
||||
bool sign_multisig_input_in_tx(currency::transaction& tx, size_t ms_input_index, const currency::account_keys& keys, const currency::transaction& source_tx, bool *p_is_input_fully_signed = nullptr);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,6 @@
|
|||
#define PROJECT_REVISION "0"
|
||||
#define PROJECT_VERSION PROJECT_MAJOR_VERSION "." PROJECT_MINOR_VERSION "." PROJECT_REVISION
|
||||
|
||||
#define PROJECT_VERSION_BUILD_NO 259
|
||||
#define PROJECT_VERSION_BUILD_NO 261
|
||||
#define PROJECT_VERSION_BUILD_NO_STR STRINGIFY_EXPAND(PROJECT_VERSION_BUILD_NO)
|
||||
#define PROJECT_VERSION_LONG PROJECT_VERSION "." PROJECT_VERSION_BUILD_NO_STR "[" BUILD_COMMIT_ID "]"
|
||||
|
|
|
|||
|
|
@ -400,14 +400,15 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
|
|||
{
|
||||
do
|
||||
{
|
||||
crypto::public_key asset_id{};
|
||||
if (ado.operation_type != ASSET_DESCRIPTOR_OPERATION_UNDEFINED)
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(get_or_calculate_asset_id(ado, nullptr, &asset_id), "get_or_calculate_asset_id failed");
|
||||
|
||||
if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_REGISTER)
|
||||
{
|
||||
if (ado.descriptor.owner != m_account.get_public_address().spend_public_key)
|
||||
{
|
||||
break;
|
||||
}
|
||||
crypto::public_key asset_id{};
|
||||
calculate_asset_id(ado.descriptor.owner, nullptr, &asset_id);
|
||||
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(m_own_asset_descriptors.count(asset_id) == 0, "asset with asset_id " << asset_id << " has already been registered in the wallet as own asset");
|
||||
wallet_own_asset_context& asset_context = m_own_asset_descriptors[asset_id];
|
||||
asset_context.asset_descriptor = ado.descriptor;
|
||||
|
|
@ -429,8 +430,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
|
|||
}
|
||||
else if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_EMIT || ado.operation_type == ASSET_DESCRIPTOR_OPERATION_PUBLIC_BURN)
|
||||
{
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(ado.opt_asset_id, get_asset_operation_type_string(ado.operation_type) << " failed with empty opt_asset_id");
|
||||
auto it = m_own_asset_descriptors.find(*ado.opt_asset_id);
|
||||
auto it = m_own_asset_descriptors.find(asset_id);
|
||||
if (it == m_own_asset_descriptors.end())
|
||||
break;
|
||||
//asset had been updated
|
||||
|
|
@ -439,20 +439,19 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
|
|||
}
|
||||
else if (ado.operation_type == ASSET_DESCRIPTOR_OPERATION_UPDATE )
|
||||
{
|
||||
WLT_THROW_IF_FALSE_WALLET_CMN_ERR_EX(ado.opt_asset_id, get_asset_operation_type_string(ado.operation_type) << " failed with empty opt_asset_id");
|
||||
auto it = m_own_asset_descriptors.find(*ado.opt_asset_id);
|
||||
auto it = m_own_asset_descriptors.find(asset_id);
|
||||
if (it == m_own_asset_descriptors.end())
|
||||
{
|
||||
if (ado.descriptor.owner == m_account.get_public_address().spend_public_key)
|
||||
{
|
||||
// ownership of the asset acquired
|
||||
|
||||
wallet_own_asset_context& asset_context = m_own_asset_descriptors[*ado.opt_asset_id];
|
||||
wallet_own_asset_context& asset_context = m_own_asset_descriptors[asset_id];
|
||||
asset_context.asset_descriptor = ado.descriptor;
|
||||
|
||||
std::stringstream ss;
|
||||
ss << "Asset ownership acquired:"
|
||||
<< ENDL << "asset id: " << *ado.opt_asset_id
|
||||
<< ENDL << "asset id: " << asset_id
|
||||
<< ENDL << "Name: " << ado.descriptor.full_name
|
||||
<< ENDL << "Ticker: " << ado.descriptor.ticker
|
||||
<< ENDL << "Total Max Supply: " << print_asset_money(ado.descriptor.total_max_supply, ado.descriptor.decimal_point)
|
||||
|
|
@ -460,7 +459,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
|
|||
<< ENDL << "Decimal Point: " << ado.descriptor.decimal_point;
|
||||
|
||||
|
||||
add_rollback_event(ptc.height, asset_register_event{ *ado.opt_asset_id });
|
||||
add_rollback_event(ptc.height, asset_register_event{ asset_id });
|
||||
WLT_LOG_MAGENTA(ss.str(), LOG_LEVEL_0);
|
||||
if (m_wcallback)
|
||||
m_wcallback->on_message(i_wallet2_callback::ms_yellow, ss.str());
|
||||
|
|
@ -482,7 +481,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
|
|||
|
||||
std::stringstream ss;
|
||||
ss << "Asset ownership lost:"
|
||||
<< ENDL << "asset id: " << *ado.opt_asset_id
|
||||
<< ENDL << "asset id: " << asset_id
|
||||
<< ENDL << "New owner: " << ado.descriptor.owner
|
||||
<< ENDL << "Name: " << ado.descriptor.full_name
|
||||
<< ENDL << "Ticker: " << ado.descriptor.ticker
|
||||
|
|
@ -490,7 +489,7 @@ void wallet2::process_ado_in_new_transaction(const currency::asset_descriptor_op
|
|||
<< ENDL << "Current Supply: " << print_asset_money(ado.descriptor.current_supply, ado.descriptor.decimal_point)
|
||||
<< ENDL << "Decimal Point: " << ado.descriptor.decimal_point;
|
||||
|
||||
add_rollback_event(ptc.height, asset_register_event{ *ado.opt_asset_id });
|
||||
add_rollback_event(ptc.height, asset_register_event{ asset_id });
|
||||
WLT_LOG_MAGENTA(ss.str(), LOG_LEVEL_0);
|
||||
if (m_wcallback)
|
||||
m_wcallback->on_message(i_wallet2_callback::ms_yellow, ss.str());
|
||||
|
|
@ -4915,7 +4914,7 @@ void wallet2::deploy_new_asset(const currency::asset_descriptor_base& asset_info
|
|||
currency::asset_descriptor_operation ado = AUTO_VAL_INIT(ado);
|
||||
bool r = get_type_in_variant_container(result_tx.extra, ado);
|
||||
CHECK_AND_ASSERT_THROW_MES(r, "Failed find asset info in tx");
|
||||
calculate_asset_id(ado.descriptor.owner, nullptr, &new_asset_id);
|
||||
CHECK_AND_ASSERT_THROW_MES(get_or_calculate_asset_id(ado, nullptr, &new_asset_id), "get_or_calculate_asset_id failed");
|
||||
|
||||
m_custom_assets[new_asset_id] = ado.descriptor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ add_executable(net_load_tests_srv net_load_tests/srv.cpp)
|
|||
|
||||
add_dependencies(coretests version)
|
||||
|
||||
target_link_libraries(coretests rpc wallet currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(coretests rpc wallet currency_core common crypto zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
target_link_libraries(functional_tests rpc wallet currency_core crypto common zlibstatic ethash libminiupnpc-static ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(hash-tests crypto ethash)
|
||||
target_link_libraries(hash-target-tests crypto currency_core ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue