forked from lthn/blockchain
Merge branch 'multiassets' into zarcanum
This commit is contained in:
commit
fd456f2445
23 changed files with 1884 additions and 1555 deletions
|
|
@ -5,9 +5,14 @@ PROJECT(Zano)
|
|||
|
||||
set(VERSION "1.0")
|
||||
|
||||
# if(POLICY CMP0043)
|
||||
# cmake_policy(SET CMP0043 OLD)
|
||||
# endif()
|
||||
if(POLICY CMP0043)
|
||||
cmake_policy(SET CMP0043 NEW)
|
||||
endif()
|
||||
if(POLICY CMP0043)
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
endif()
|
||||
|
||||
|
||||
|
||||
# if(POLICY CMP0020)
|
||||
# cmake_policy(SET CMP0020 OLD)
|
||||
|
|
@ -50,6 +55,7 @@ message("Generated with config types: ${CMAKE_CONFIGURATION_TYPES}, and built ty
|
|||
|
||||
enable_testing()
|
||||
|
||||
find_package(OpenSSL REQUIRED)
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10.5)
|
||||
|
|
@ -60,7 +66,7 @@ set(DISABLE_TOR FALSE CACHE BOOL "Disable TOR library(and related tor-connect su
|
|||
set(TESTNET FALSE CACHE BOOL "Compile for testnet")
|
||||
set(BUILD_GUI FALSE CACHE BOOL "Build qt-daemon")
|
||||
|
||||
include_directories(src contrib/eos_portable_archive contrib contrib/epee/include "${CMAKE_BINARY_DIR}/version" "${CMAKE_BINARY_DIR}/contrib/zlib")
|
||||
include_directories(src contrib/eos_portable_archive contrib contrib/epee/include ${OPENSSL_INCLUDE_DIR} "${CMAKE_BINARY_DIR}/version" "${CMAKE_BINARY_DIR}/contrib/zlib")
|
||||
|
||||
add_definitions(-DSTATICLIB)
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -155,6 +155,13 @@ namespace net_utils
|
|||
{
|
||||
content.port = boost::lexical_cast<uint64_t>(result[6]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (content.schema == "http")
|
||||
content.port = 80;
|
||||
else if (content.schema == "https")
|
||||
content.port = 443;
|
||||
}
|
||||
if(result[7].matched)
|
||||
{
|
||||
content.uri = result[7];
|
||||
|
|
|
|||
|
|
@ -34,6 +34,19 @@ namespace epee
|
|||
{
|
||||
namespace net_utils
|
||||
{
|
||||
|
||||
template<class t_response>
|
||||
bool get_http_json_t(const std::string& url, t_response& result_struct, unsigned int timeout = 5000, const std::string& method = "GET")
|
||||
{
|
||||
std::string body;
|
||||
if (!http::fetch_url(url, body, method, "", timeout))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return serialization::load_t_from_json(result_struct, body);
|
||||
}
|
||||
|
||||
|
||||
template<class t_request, class t_response, class t_transport>
|
||||
bool invoke_http_json_remote_command2(const std::string& url, t_request& out_struct, t_response& result_struct, t_transport& transport, unsigned int timeout = 5000, const std::string& method = "GET")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ ENABLE_SHARED_PCH(currency_core CURRENCY_CORE)
|
|||
add_library(wallet ${WALLET})
|
||||
if(CMAKE_SYSTEM_NAME STREQUAL "Android" )
|
||||
add_dependencies(wallet version ${PCH_LIB_NAME})
|
||||
target_link_libraries(wallet currency_core crypto common zlibstatic ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} android log)
|
||||
target_link_libraries(wallet currency_core crypto common zlibstatic ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} android log OpenSSL::SSL OpenSSL::Crypto)
|
||||
else()
|
||||
add_dependencies(wallet version ${PCH_LIB_NAME})
|
||||
ENABLE_SHARED_PCH(wallet WALLET)
|
||||
|
|
@ -162,19 +162,19 @@ target_link_libraries(currency_core lmdb mdbx)
|
|||
|
||||
add_executable(daemon ${DAEMON} ${P2P} ${CURRENCY_PROTOCOL})
|
||||
add_dependencies(daemon version)
|
||||
target_link_libraries(daemon rpc stratum currency_core crypto common libminiupnpc-static zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(daemon rpc stratum currency_core crypto common libminiupnpc-static zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
ENABLE_SHARED_PCH(daemon DAEMON)
|
||||
ENABLE_SHARED_PCH_EXECUTABLE(daemon)
|
||||
|
||||
add_executable(connectivity_tool ${CONN_TOOL})
|
||||
add_dependencies(connectivity_tool version)
|
||||
target_link_libraries(connectivity_tool currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(connectivity_tool currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
ENABLE_SHARED_PCH(connectivity_tool CONN_TOOL)
|
||||
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})
|
||||
target_link_libraries(simplewallet wallet rpc currency_core crypto common zlibstatic ethash ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
|
||||
ENABLE_SHARED_PCH(simplewallet SIMPLEWALLET)
|
||||
ENABLE_SHARED_PCH_EXECUTABLE(simplewallet)
|
||||
|
|
@ -199,7 +199,7 @@ if(BUILD_GUI)
|
|||
QT5_USE_MODULES(Zano WebEngineWidgets WebChannel)
|
||||
find_package(Qt5PrintSupport REQUIRED)
|
||||
|
||||
target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES})
|
||||
target_link_libraries(Zano wallet rpc currency_core crypto common zlibstatic ethash Qt5::WebEngineWidgets Qt5::PrintSupport ${CMAKE_THREAD_LIBS_INIT} ${Boost_LIBRARIES} OpenSSL::SSL OpenSSL::Crypto)
|
||||
if (UNIX AND NOT APPLE)
|
||||
target_link_libraries(Zano rt)
|
||||
endif()
|
||||
|
|
|
|||
|
|
@ -732,7 +732,6 @@ namespace currency
|
|||
};
|
||||
|
||||
|
||||
|
||||
struct asset_descriptor_base
|
||||
{
|
||||
uint64_t total_max_supply = 0;
|
||||
|
|
@ -740,6 +739,7 @@ namespace currency
|
|||
uint8_t decimal_point = 12;
|
||||
std::string ticker;
|
||||
std::string full_name;
|
||||
std::string meta_info;
|
||||
crypto::public_key owner = currency::null_pkey;
|
||||
|
||||
BEGIN_VERSIONED_SERIALIZE()
|
||||
|
|
@ -748,6 +748,7 @@ namespace currency
|
|||
FIELD(decimal_point)
|
||||
FIELD(ticker)
|
||||
FIELD(full_name)
|
||||
FIELD(meta_info)
|
||||
FIELD(owner)
|
||||
END_SERIALIZE()
|
||||
|
||||
|
|
@ -758,8 +759,37 @@ namespace currency
|
|||
BOOST_SERIALIZE(decimal_point)
|
||||
BOOST_SERIALIZE(ticker)
|
||||
BOOST_SERIALIZE(full_name)
|
||||
BOOST_SERIALIZE(meta_info)
|
||||
BOOST_SERIALIZE(owner)
|
||||
END_BOOST_SERIALIZATION()
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(total_max_supply)
|
||||
KV_SERIALIZE(current_supply)
|
||||
KV_SERIALIZE(decimal_point)
|
||||
KV_SERIALIZE(ticker)
|
||||
KV_SERIALIZE(full_name)
|
||||
KV_SERIALIZE(meta_info)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(owner)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct asset_descriptor_with_id: public asset_descriptor_base
|
||||
{
|
||||
crypto::hash asset_id = currency::null_hash;
|
||||
|
||||
/*
|
||||
BEGIN_VERSIONED_SERIALIZE()
|
||||
FIELD(*static_cast<asset_descriptor_base>(this))
|
||||
FIELD(asset_id)
|
||||
END_SERIALIZE()
|
||||
*/
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_CHAIN_BASE(asset_descriptor_base)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -271,4 +271,8 @@
|
|||
static_assert(CURRENCY_MINER_TX_MAX_OUTS <= CURRENCY_TX_MAX_ALLOWED_OUTS, "Miner tx must obey normal tx max outs limit");
|
||||
static_assert(PREMINE_AMOUNT / WALLET_MAX_ALLOWED_OUTPUT_AMOUNT < CURRENCY_MINER_TX_MAX_OUTS, "Premine can't be divided into reasonable number of outs");
|
||||
|
||||
#define CURRENCY_RELAY_TXS_MAX_COUNT 5
|
||||
#define CURRENCY_RELAY_TXS_MAX_COUNT 5
|
||||
|
||||
|
||||
#define WALLET_ASSETS_WHITELIST_URL "https://zano.org/assets_whitelist.json"
|
||||
#define WALLET_ASSETS_WHITELIST_VALIDATION_PUBLIC_KEY "" //TODO@#@
|
||||
|
|
@ -627,6 +627,17 @@ namespace currency
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_get_asset_info(const COMMAND_RPC_GET_ASSET_INFO::request& req, COMMAND_RPC_GET_ASSET_INFO::response& res, connection_context& cntx)
|
||||
{
|
||||
if (!m_core.get_blockchain_storage().get_asset_info(req.asset_id, res.asset_descriptor))
|
||||
{
|
||||
res.status = API_RETURN_CODE_NOT_FOUND;
|
||||
return true;
|
||||
}
|
||||
res.status = API_RETURN_CODE_OK;
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool core_rpc_server::on_get_main_block_details(const COMMAND_RPC_GET_BLOCK_DETAILS::request& req, COMMAND_RPC_GET_BLOCK_DETAILS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx)
|
||||
{
|
||||
if (!m_core.get_blockchain_storage().get_main_block_rpc_details(req.id, res.block_details))
|
||||
|
|
|
|||
|
|
@ -82,7 +82,8 @@ namespace currency
|
|||
bool on_get_pool_txs_brief_details(const COMMAND_RPC_GET_POOL_TXS_BRIEF_DETAILS::request& req, COMMAND_RPC_GET_POOL_TXS_BRIEF_DETAILS::response& res, connection_context& cntx);
|
||||
bool on_get_all_pool_tx_list(const COMMAND_RPC_GET_ALL_POOL_TX_LIST::request& req, COMMAND_RPC_GET_ALL_POOL_TX_LIST::response& res, connection_context& cntx);
|
||||
bool on_get_pool_info(const COMMAND_RPC_GET_POOL_INFO::request& req, COMMAND_RPC_GET_POOL_INFO::response& res, connection_context& cntx);
|
||||
|
||||
bool on_get_asset_info(const COMMAND_RPC_GET_ASSET_INFO::request& req, COMMAND_RPC_GET_ASSET_INFO::response& res, connection_context& cntx);
|
||||
|
||||
bool on_get_main_block_details(const COMMAND_RPC_GET_BLOCK_DETAILS::request& req, COMMAND_RPC_GET_BLOCK_DETAILS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
|
||||
bool on_get_alt_block_details(const COMMAND_RPC_GET_BLOCK_DETAILS::request& req, COMMAND_RPC_GET_BLOCK_DETAILS::response& res, epee::json_rpc::error& error_resp, connection_context& cntx);
|
||||
bool on_get_alt_blocks_details(const COMMAND_RPC_GET_ALT_BLOCKS_DETAILS::request& req, COMMAND_RPC_GET_ALT_BLOCKS_DETAILS::response& res, connection_context& cntx);
|
||||
|
|
@ -137,6 +138,8 @@ namespace currency
|
|||
MAP_JON_RPC ("get_pool_txs_brief_details", on_get_pool_txs_brief_details, COMMAND_RPC_GET_POOL_TXS_BRIEF_DETAILS)
|
||||
MAP_JON_RPC ("get_all_pool_tx_list", on_get_all_pool_tx_list, COMMAND_RPC_GET_ALL_POOL_TX_LIST)
|
||||
MAP_JON_RPC ("get_pool_info", on_get_pool_info, COMMAND_RPC_GET_POOL_INFO)
|
||||
//assets api
|
||||
MAP_JON_RPC ("get_asset_info", on_get_asset_info, COMMAND_RPC_GET_ASSET_INFO)
|
||||
|
||||
MAP_JON_RPC_WE("get_main_block_details", on_get_main_block_details, COMMAND_RPC_GET_BLOCK_DETAILS)
|
||||
MAP_JON_RPC_WE("get_alt_block_details", on_get_alt_block_details, COMMAND_RPC_GET_BLOCK_DETAILS)
|
||||
|
|
|
|||
|
|
@ -82,6 +82,29 @@ namespace currency
|
|||
};
|
||||
};
|
||||
|
||||
struct COMMAND_RPC_GET_ASSET_INFO
|
||||
{
|
||||
struct request
|
||||
{
|
||||
crypto::hash asset_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct response
|
||||
{
|
||||
std::string status;
|
||||
asset_descriptor_base asset_descriptor;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(status)
|
||||
KV_SERIALIZE(asset_descriptor)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
};
|
||||
|
||||
struct COMMAND_RPC_GET_HEIGHT
|
||||
{
|
||||
struct request
|
||||
|
|
|
|||
|
|
@ -168,6 +168,11 @@ namespace tools
|
|||
return invoke_http_json_rpc_update_is_disconnect("get_pool_info", req, res);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool default_http_core_proxy::call_COMMAND_RPC_GET_ASSET_INFO(const currency::COMMAND_RPC_GET_ASSET_INFO::request& req, currency::COMMAND_RPC_GET_ASSET_INFO::response& res)
|
||||
{
|
||||
return invoke_http_json_rpc_update_is_disconnect("get_asset_info", req, res);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool default_http_core_proxy::get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id)
|
||||
{
|
||||
return tools::get_transfer_address(adr_str, addr, payment_id, this);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ namespace tools
|
|||
bool call_COMMAND_RPC_GET_BLOCKS_DETAILS(const currency::COMMAND_RPC_GET_BLOCKS_DETAILS::request& req, currency::COMMAND_RPC_GET_BLOCKS_DETAILS::response& res) override;
|
||||
bool call_COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN(const currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::request& req, currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::response& res) override;
|
||||
bool call_COMMAND_RPC_GET_POOL_INFO(const currency::COMMAND_RPC_GET_POOL_INFO::request& req, currency::COMMAND_RPC_GET_POOL_INFO::response& res) override;
|
||||
bool call_COMMAND_RPC_GET_ASSET_INFO(const currency::COMMAND_RPC_GET_ASSET_INFO::request& req, currency::COMMAND_RPC_GET_ASSET_INFO::response& res) override;
|
||||
|
||||
bool check_connection() override;
|
||||
bool get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id) override;
|
||||
|
|
|
|||
|
|
@ -133,6 +133,11 @@ namespace tools
|
|||
return m_rpc.on_get_pool_info(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
virtual bool call_COMMAND_RPC_GET_ASSET_INFO(const currency::COMMAND_RPC_GET_ASSET_INFO::request& req, currency::COMMAND_RPC_GET_ASSET_INFO::response& res)override
|
||||
{
|
||||
return m_rpc.on_get_asset_info(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
virtual bool get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id) override
|
||||
{
|
||||
return tools::get_transfer_address(adr_str, addr, payment_id, this);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ namespace tools
|
|||
virtual bool call_COMMAND_RPC_GET_OFFERS_EX(const currency::COMMAND_RPC_GET_OFFERS_EX::request& req, currency::COMMAND_RPC_GET_OFFERS_EX::response& res){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN(const currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::request& req, currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::response& res){ return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_POOL_INFO(const currency::COMMAND_RPC_GET_POOL_INFO::request& req, currency::COMMAND_RPC_GET_POOL_INFO::response& res) { return false; }
|
||||
virtual bool call_COMMAND_RPC_GET_ASSET_INFO(const currency::COMMAND_RPC_GET_ASSET_INFO::request& req, currency::COMMAND_RPC_GET_ASSET_INFO::response& res) { return false; }
|
||||
|
||||
i_core_proxy()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -197,26 +197,19 @@ public:
|
|||
wallet_state_error = 3
|
||||
};
|
||||
|
||||
uint64_t balance;
|
||||
uint64_t unlocked_balance;
|
||||
uint64_t awaiting_in;
|
||||
uint64_t awaiting_out;
|
||||
std::list<tools::wallet_public::asset_balance_entry> balances;
|
||||
uint64_t minied_total;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_CHAIN_BASE(wallet_status_info_base)
|
||||
KV_SERIALIZE(balance)
|
||||
KV_SERIALIZE(unlocked_balance)
|
||||
KV_SERIALIZE(awaiting_in)
|
||||
KV_SERIALIZE(awaiting_out)
|
||||
KV_SERIALIZE(balances)
|
||||
KV_SERIALIZE(minied_total)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct wallet_info
|
||||
{
|
||||
uint64_t unlocked_balance;
|
||||
uint64_t balance;
|
||||
std::list<tools::wallet_public::asset_balance_entry> balances;
|
||||
uint64_t mined_total;
|
||||
std::string address;
|
||||
std::string view_sec_key;
|
||||
|
|
@ -225,8 +218,7 @@ public:
|
|||
bool is_watch_only;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(unlocked_balance)
|
||||
KV_SERIALIZE(balance)
|
||||
KV_SERIALIZE(balances)
|
||||
KV_SERIALIZE(mined_total)
|
||||
KV_SERIALIZE(address)
|
||||
KV_SERIALIZE(view_sec_key)
|
||||
|
|
|
|||
|
|
@ -3140,12 +3140,89 @@ bool wallet2::balance(std::unordered_map<crypto::hash, wallet_public::asset_bala
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::balance(std::list<wallet_public::asset_balance_entry>& balances, uint64_t& mined) const
|
||||
{
|
||||
std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base> balances_map;
|
||||
this->balance(balances_map, mined);
|
||||
for (const auto& item : balances_map)
|
||||
{
|
||||
const asset_descriptor_base* asset_ptr = nullptr;
|
||||
//check if asset is whitelisted or customly added
|
||||
auto it = m_whitelisted_assets.find(item.first);
|
||||
if (it == m_whitelisted_assets.end())
|
||||
{
|
||||
//check if it custom asset
|
||||
auto it_cust = m_custom_assets.find(item.first);
|
||||
if (it_cust == m_custom_assets.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
asset_ptr = &it_cust->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asset_ptr = &it->second;
|
||||
}
|
||||
|
||||
balances.push_back(wallet_public::asset_balance_entry());
|
||||
wallet_public::asset_balance_entry& new_item = balances.back();
|
||||
static_cast<wallet_public::asset_balance_entry_base&>(new_item) = item.second;
|
||||
new_item.asset_info.asset_id = item.first;
|
||||
CHECK_AND_ASSERT_THROW_MES(asset_ptr, "Internal error: asset_ptr i nullptr");
|
||||
static_cast<currency::asset_descriptor_base&>(new_item.asset_info) = *asset_ptr;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
uint64_t wallet2::balance() const
|
||||
{
|
||||
uint64_t stub = 0;
|
||||
return balance(stub, stub, stub, stub);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::add_custom_asset_id(const crypto::hash& asset_id)
|
||||
{
|
||||
currency::COMMAND_RPC_GET_ASSET_INFO::request req = AUTO_VAL_INIT(req);
|
||||
currency::COMMAND_RPC_GET_ASSET_INFO::response resp = AUTO_VAL_INIT(resp);
|
||||
|
||||
bool r = m_core_proxy->call_COMMAND_RPC_GET_ASSET_INFO(req, resp);
|
||||
if (resp.status == API_RETURN_CODE_OK)
|
||||
{
|
||||
m_custom_assets[asset_id] = resp.asset_descriptor;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::delete_custom_asset_id(const crypto::hash& asset_id)
|
||||
{
|
||||
auto it = m_custom_assets.find(asset_id);
|
||||
if (it != m_custom_assets.end())
|
||||
{
|
||||
m_custom_assets.erase(it);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::load_whitelisted_tokens_list()
|
||||
{
|
||||
std::string body;
|
||||
wallet_public::assets_whitelist aw = AUTO_VAL_INIT(aw);
|
||||
if (epee::net_utils::get_http_json_t(WALLET_ASSETS_WHITELIST_URL, aw))
|
||||
{
|
||||
for (auto it = aw.assets.begin(); it != aw.assets.end(); it++)
|
||||
{
|
||||
m_whitelisted_assets[it->asset_id] = static_cast<currency::asset_descriptor_base>(*it);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::get_transfers(wallet2::transfer_container& incoming_transfers) const
|
||||
{
|
||||
incoming_transfers = m_transfers;
|
||||
|
|
|
|||
|
|
@ -566,6 +566,8 @@ namespace tools
|
|||
uint64_t balance() const;
|
||||
uint64_t balance(uint64_t& unloked, uint64_t& awaiting_in, uint64_t& awaiting_out, uint64_t& mined) const;
|
||||
bool balance(std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base>& balances, uint64_t& mined) const;
|
||||
bool balance(std::list<wallet_public::asset_balance_entry>& balances, uint64_t& mined) const;
|
||||
|
||||
uint64_t balance(uint64_t& unloked) const;
|
||||
|
||||
uint64_t unlocked_balance() const;
|
||||
|
|
@ -814,6 +816,7 @@ namespace tools
|
|||
return;
|
||||
|
||||
a & m_own_asset_descriptors;
|
||||
a & m_custom_assets;
|
||||
}
|
||||
|
||||
void wipeout_extra_if_needed(std::vector<wallet_public::wallet_transfer_info>& transfer_history);
|
||||
|
|
@ -895,7 +898,11 @@ namespace tools
|
|||
void set_disable_tor_relay(bool disable);
|
||||
uint64_t get_default_fee() {return TX_DEFAULT_FEE;}
|
||||
void export_transaction_history(std::ostream& ss, const std::string& format, bool include_pos_transactions = true);
|
||||
|
||||
|
||||
bool add_custom_asset_id(const crypto::hash& asset_id);
|
||||
bool delete_custom_asset_id(const crypto::hash& asset_id);
|
||||
bool load_whitelisted_tokens_list();
|
||||
|
||||
/*
|
||||
create_htlc_proposal: if htlc_hash == null_hash, then this wallet is originator of the atomic process, and
|
||||
we use deterministic origin, if given some particular htlc_hash, then we use this hash, and this means that
|
||||
|
|
@ -1092,6 +1099,9 @@ private:
|
|||
std::unordered_set<crypto::hash> m_unconfirmed_multisig_transfers;
|
||||
std::unordered_map<crypto::hash, crypto::secret_key> m_tx_keys;
|
||||
std::unordered_map<crypto::hash, wallet_own_asset_context> m_own_asset_descriptors;
|
||||
std::unordered_map<crypto::hash, currency::asset_descriptor_base> m_custom_assets; //assets that manually added by user
|
||||
std::unordered_map<crypto::hash, currency::asset_descriptor_base> m_whitelisted_assets; //assets that manually added by user
|
||||
|
||||
|
||||
std::multimap<uint64_t, htlc_expiration_trigger> m_htlcs; //map [expired_if_more_then] -> height of expiration
|
||||
amount_gindex_to_transfer_id_container m_active_htlcs; // map [amount; gindex] -> transfer index
|
||||
|
|
|
|||
|
|
@ -16,8 +16,7 @@ namespace tools
|
|||
wi = AUTO_VAL_INIT_T(view::wallet_info);
|
||||
wi.address = w.get_account().get_public_address_str();
|
||||
wi.view_sec_key = epee::string_tools::pod_to_hex(w.get_account().get_keys().view_secret_key);
|
||||
uint64_t fake = 0;
|
||||
wi.balance = w.balance(wi.unlocked_balance, fake, fake, wi.mined_total);
|
||||
w.balance(wi.balances, wi.mined_total);
|
||||
wi.path = epee::string_encoding::wstring_to_utf8(w.get_wallet_path());
|
||||
wi.is_auditable = w.is_auditable();
|
||||
wi.is_watch_only = w.is_watch_only();
|
||||
|
|
|
|||
|
|
@ -166,10 +166,10 @@ namespace wallet_public
|
|||
|
||||
struct asset_balance_entry : public asset_balance_entry_base
|
||||
{
|
||||
crypto::hash asset_id = currency::null_hash;
|
||||
currency::asset_descriptor_with_id asset_info;
|
||||
//v2
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(asset_id)
|
||||
KV_SERIALIZE(asset_info)
|
||||
KV_CHAIN_BASE(asset_balance_entry_base)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
|
@ -1178,6 +1178,18 @@ namespace wallet_public
|
|||
};
|
||||
};
|
||||
|
||||
struct assets_whitelist
|
||||
{
|
||||
std::vector<currency::asset_descriptor_with_id> assets;
|
||||
crypto::signature signature = currency::null_sig;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(assets)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(signature)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
inline std::string get_escrow_contract_state_name(uint32_t state)
|
||||
{
|
||||
switch (state)
|
||||
|
|
|
|||
|
|
@ -112,11 +112,11 @@ namespace tools
|
|||
{
|
||||
LOG_PRINT_RED("no connection to the daemon", LOG_LEVEL_0);
|
||||
}
|
||||
catch(std::exception& e)
|
||||
catch (std::exception& e)
|
||||
{
|
||||
LOG_ERROR("exeption caught in wallet_rpc_server::idle_handler: " << e.what());
|
||||
}
|
||||
catch(...)
|
||||
catch (...)
|
||||
{
|
||||
LOG_ERROR("unknown exeption caught in wallet_rpc_server::idle_handler");
|
||||
}
|
||||
|
|
@ -157,26 +157,26 @@ namespace tools
|
|||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::handle_http_request(const epee::net_utils::http::http_request_info& query_info, epee::net_utils::http::http_response_info& response, connection_context& m_conn_context)
|
||||
{
|
||||
response.m_response_code = 200;
|
||||
response.m_response_comment = "Ok";
|
||||
std::string reference_stub;
|
||||
bool call_found = false;
|
||||
response.m_response_code = 200;
|
||||
response.m_response_comment = "Ok";
|
||||
std::string reference_stub;
|
||||
bool call_found = false;
|
||||
if (m_deaf)
|
||||
{
|
||||
response.m_response_code = 500;
|
||||
response.m_response_comment = "Internal Server Error";
|
||||
response.m_response_code = 500;
|
||||
response.m_response_comment = "Internal Server Error";
|
||||
return true;
|
||||
}
|
||||
if (!handle_http_request_map(query_info, response, m_conn_context, call_found, reference_stub) && response.m_response_code == 200)
|
||||
{
|
||||
response.m_response_code = 500;
|
||||
response.m_response_comment = "Internal Server Error";
|
||||
response.m_response_code = 500;
|
||||
response.m_response_comment = "Internal Server Error";
|
||||
return true;
|
||||
}
|
||||
if (!call_found)
|
||||
{
|
||||
response.m_response_code = 404;
|
||||
response.m_response_comment = "Not Found";
|
||||
response.m_response_code = 404;
|
||||
response.m_response_comment = "Not Found";
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
|
@ -186,22 +186,17 @@ namespace tools
|
|||
{
|
||||
try
|
||||
{
|
||||
res.balance = m_wallet.balance();
|
||||
res.unlocked_balance = m_wallet.unlocked_balance();
|
||||
// res.balance = m_wallet.balance();
|
||||
// res.unlocked_balance = m_wallet.unlocked_balance();
|
||||
uint64_t mined = 0;
|
||||
std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base> balances;
|
||||
m_wallet.balance(balances, mined);
|
||||
auto it = balances.find(currency::null_hash);
|
||||
if (it != balances.end())
|
||||
m_wallet.balance(res.balances, mined);
|
||||
for (auto it = res.balances.begin(); it != res.balances.end(); it++)
|
||||
{
|
||||
res.balance = it->second.total;
|
||||
res.unlocked_balance = it->second.unlocked;
|
||||
}
|
||||
for (auto el : balances)
|
||||
{
|
||||
res.balances.push_back(wallet_public::asset_balance_entry());
|
||||
static_cast<wallet_public::asset_balance_entry_base&>(res.balances.back()) = el.second;
|
||||
res.balances.back().asset_id = el.first;
|
||||
if (it->asset_info.asset_id == currency::null_hash)
|
||||
{
|
||||
res.balance = it->total;
|
||||
res.unlocked_balance = it->unlocked;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (std::exception& e)
|
||||
|
|
|
|||
|
|
@ -943,6 +943,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
|
|||
w->load(path, password);
|
||||
if (w->is_watch_only() && !w->is_auditable())
|
||||
return API_RETURN_CODE_WALLET_WATCH_ONLY_NOT_SUPPORTED;
|
||||
w->load_whitelisted_tokens_list();
|
||||
|
||||
w->get_recent_transfers_history(owr.recent_history.history, 0, txs_to_return, owr.recent_history.total_history_items, owr.recent_history.last_item_index, exclude_mining_txs);
|
||||
//w->get_unconfirmed_transfers(owr.recent_history.unconfirmed);
|
||||
|
|
@ -1723,7 +1724,7 @@ void wallets_manager::prepare_wallet_status_info(wallet_vs_options& wo, view::wa
|
|||
wsi.is_mining = wo.do_mining;
|
||||
wsi.wallet_id = wo.wallet_id;
|
||||
wsi.is_alias_operations_available = !wo.has_related_alias_in_unconfirmed;
|
||||
wsi.balance = wo.w->get()->balance(wsi.unlocked_balance, wsi.awaiting_in, wsi.awaiting_out, wsi.minied_total);
|
||||
wo.w->get()->balance(wsi.balances, wsi.minied_total);
|
||||
}
|
||||
std::string wallets_manager::check_available_sources(uint64_t wallet_id, std::list<uint64_t>& amounts)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1079,7 +1079,7 @@ int main(int argc, char* argv[])
|
|||
GENERATE_AND_PLAY(zarcanum_basic_test);
|
||||
|
||||
GENERATE_AND_PLAY(multiassets_basic_test);
|
||||
//GENERATE_AND_PLAY(zarcanum_test_n_inputs_validation);
|
||||
GENERATE_AND_PLAY(zarcanum_test_n_inputs_validation);
|
||||
GENERATE_AND_PLAY(zarcanum_gen_time_balance);
|
||||
GENERATE_AND_PLAY(zarcanum_txs_with_big_shuffled_decoy_set_shuffled);
|
||||
GENERATE_AND_PLAY(zarcanum_pos_block_math);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue