forked from lthn/blockchain
Merge branch 'multiassets' into zarcanum
This commit is contained in:
commit
254877421c
15 changed files with 230 additions and 81 deletions
|
|
@ -4,22 +4,19 @@ AlignConsecutiveAssignments: 'true'
|
|||
AlignConsecutiveDeclarations: 'false'
|
||||
AlignEscapedNewlines: Right
|
||||
AlignOperands: 'false'
|
||||
AlignTrailingComments: 'true'
|
||||
AlignTrailingComments: 'false'
|
||||
AllowAllParametersOfDeclarationOnNextLine: 'false'
|
||||
AllowShortBlocksOnASingleLine: 'false'
|
||||
AllowShortCaseLabelsOnASingleLine: 'true'
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: 'true'
|
||||
AllowShortLoopsOnASingleLine: 'false'
|
||||
AlwaysBreakAfterReturnType: None
|
||||
AlwaysBreakBeforeMultilineStrings: 'false'
|
||||
AlwaysBreakTemplateDeclarations: 'true'
|
||||
BinPackArguments: 'true'
|
||||
BinPackParameters: 'true'
|
||||
BreakAfterJavaFieldAnnotations: 'true'
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeBraces: Stroustrup
|
||||
BreakBeforeInheritanceComma: 'false'
|
||||
BreakBeforeBraces: Allman
|
||||
BreakBeforeTernaryOperators: 'false'
|
||||
BreakConstructorInitializers: BeforeColon
|
||||
BreakStringLiterals: 'false'
|
||||
|
|
@ -56,4 +53,4 @@ SpacesInParentheses: 'false'
|
|||
SpacesInSquareBrackets: 'false'
|
||||
Standard: Cpp11
|
||||
TabWidth: '2'
|
||||
UseTab: Never
|
||||
UseTab: Never
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 486a46e927449a5827cf3cb69731bc0e3811b46a
|
||||
Subproject commit b589edb1906dccb387cfeded6ed12286c5f0405f
|
||||
|
|
@ -3153,8 +3153,12 @@ namespace currency
|
|||
VARIANT_CASE_CONST(tx_out_zarcanum, o)
|
||||
//@#@
|
||||
VARIANT_SWITCH_END();
|
||||
|
||||
}
|
||||
#ifdef TESTNET
|
||||
found_alias_reward = 10 * COIN;
|
||||
#else
|
||||
@#@ fix it for mainnet bui
|
||||
#endif
|
||||
return found_alias_reward;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -142,6 +142,8 @@ bool MainWindow::init_window()
|
|||
m_view->page()->setWebChannel(m_channel);
|
||||
|
||||
QWidget* central_widget_to_be_set = m_view;
|
||||
double zoom_factor_test = 0.75;
|
||||
m_view->setZoomFactor(zoom_factor_test);
|
||||
|
||||
std::string qt_dev_tools_option = m_backend.get_qt_dev_tools_option();
|
||||
if (!qt_dev_tools_option.empty())
|
||||
|
|
@ -2127,6 +2129,38 @@ QString MainWindow::get_mining_estimate(const QString& param)
|
|||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
}
|
||||
QString MainWindow::add_custom_asset_id(const QString& param)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
LOG_API_TIMING();
|
||||
PREPARE_ARG_FROM_JSON(view::wallet_and_asset_id, waid);
|
||||
PREPARE_RESPONSE(currency::COMMAND_RPC_GET_ASSET_INFO::response, ar);
|
||||
|
||||
ar.error_code = m_backend.add_custom_asset_id(waid.wallet_id, waid.asset_id, ar.response_data.asset_descriptor);
|
||||
ar.response_data.status = ar.error_code;
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
}
|
||||
QString MainWindow::remove_custom_asset_id(const QString& param)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
LOG_API_TIMING();
|
||||
PREPARE_ARG_FROM_JSON(view::wallet_and_asset_id, waid);
|
||||
default_ar.error_code = m_backend.delete_custom_asset_id(waid.wallet_id, waid.asset_id);
|
||||
return MAKE_RESPONSE(default_ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
}
|
||||
QString MainWindow::get_wallet_info(const QString& param)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
LOG_API_TIMING();
|
||||
PREPARE_ARG_FROM_JSON(view::wallet_id_obj, waid);
|
||||
PREPARE_RESPONSE(view::wallet_info, ar);
|
||||
ar.error_code = m_backend.get_wallet_info(waid.wallet_id, ar.response_data);
|
||||
return MAKE_RESPONSE(ar);
|
||||
CATCH_ENTRY_FAIL_API_RESPONCE();
|
||||
}
|
||||
|
||||
QString MainWindow::backup_wallet_keys(const QString& param)
|
||||
{
|
||||
TRY_ENTRY();
|
||||
|
|
|
|||
|
|
@ -168,7 +168,11 @@ public:
|
|||
QString get_default_fee();
|
||||
QString get_options();
|
||||
void bool_toggle_icon(const QString& param);
|
||||
|
||||
QString add_custom_asset_id(const QString& param);
|
||||
QString remove_custom_asset_id(const QString& param);
|
||||
QString get_wallet_info(const QString& param);
|
||||
|
||||
|
||||
bool get_is_disabled_notifications();
|
||||
bool set_is_disabled_notifications(const bool& param);
|
||||
QString export_wallet_history(const QString& param);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 14def6aef99d4f10e81990e2055a7cf490f2e797
|
||||
Subproject commit f8d6ed1bbe38d48d7e762154ea9ccbdb33d88424
|
||||
|
|
@ -56,7 +56,7 @@ int main(int argc, char *argv[])
|
|||
#ifdef _MSC_VER
|
||||
#if _MSC_VER >= 1910
|
||||
QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); //HiDPI pixmaps
|
||||
qputenv("QT_SCALE_FACTOR", "0.75");
|
||||
//qputenv("QT_SCALE_FACTOR", "0.75");
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -82,16 +82,19 @@ namespace currency
|
|||
};
|
||||
};
|
||||
|
||||
struct asset_id_kv
|
||||
{
|
||||
crypto::hash asset_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
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()
|
||||
};
|
||||
typedef asset_id_kv request;
|
||||
|
||||
struct response
|
||||
{
|
||||
|
|
|
|||
|
|
@ -226,6 +226,8 @@ simple_wallet::simple_wallet()
|
|||
m_cmd_binder.set_handler("tor_enable", boost::bind(&simple_wallet::tor_enable, this, ph::_1), "Enable relaying transactions over TOR network(enabled by default)");
|
||||
m_cmd_binder.set_handler("tor_disable", boost::bind(&simple_wallet::tor_disable, this, ph::_1), "Enable relaying transactions over TOR network(enabled by default)");
|
||||
m_cmd_binder.set_handler("deploy_new_asset", boost::bind(&simple_wallet::deploy_new_asset, this, ph::_1), "Deploys new asset in the network, with current wallet as a maintainer");
|
||||
m_cmd_binder.set_handler("add_custom_asset_id", boost::bind(&simple_wallet::add_custom_asset_id, this, _1), "Approve asset id to be recognized in the wallet and returned in balances");
|
||||
m_cmd_binder.set_handler("remove_custom_asset_id", boost::bind(&simple_wallet::remove_custom_asset_id, this, _1), "Cancel previously made approval for asset id");
|
||||
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
@ -640,14 +642,13 @@ std::string print_money_trailing_zeros_replaced_with_spaces(uint64_t amount)
|
|||
return s;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void simple_wallet::on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined)
|
||||
void simple_wallet::on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, const std::list<tools::wallet_public::asset_balance_entry>& balances, uint64_t total_mined)
|
||||
{
|
||||
epee::log_space::console_colors color = wti.is_income ? epee::log_space::console_color_green : epee::log_space::console_color_magenta;
|
||||
message_writer(color, false) <<
|
||||
"height " << wti.height <<
|
||||
", tx " << wti.tx_hash <<
|
||||
" " << std::right << std::setw(18) << print_money_trailing_zeros_replaced_with_spaces(wti.amount) << (wti.is_income ? " received," : " spent, ") <<
|
||||
" balance: " << print_money_brief(balance);
|
||||
" " << std::right << std::setw(18) << print_money_trailing_zeros_replaced_with_spaces(wti.amount) << (wti.is_income ? " received," : " spent");
|
||||
m_refresh_progress_reporter.update(wti.height, true);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
@ -764,7 +765,7 @@ bool simple_wallet::show_balance(const std::vector<std::string>& args/* = std::v
|
|||
std::stringstream ss;
|
||||
for (const tools::wallet_public::asset_balance_entry& b : balances)
|
||||
{
|
||||
ss << std::setw(21) << print_fixed_decimal_point(b.total, b.asset_info.decimal_point) << "\t" << b.asset_info.ticker << ENDL;
|
||||
ss << std::setw(21) << print_fixed_decimal_point(b.total, b.asset_info.decimal_point) << "\t" << b.asset_info.ticker << "\t" << b.asset_info.asset_id << ENDL;
|
||||
}
|
||||
success_msg_writer() << "Balance: " << ENDL << ss.str();
|
||||
return true;
|
||||
|
|
@ -1790,7 +1791,7 @@ bool simple_wallet::deploy_new_asset(const std::vector<std::string> &args)
|
|||
asset_descriptor_base adb = AUTO_VAL_INIT(adb);
|
||||
if (!args.size() || args.size() > 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid agruments count: " << args.size() << ", expected 1";
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
}
|
||||
bool r = epee::serialization::load_t_from_json_file(adb, args[0]);
|
||||
if (!r)
|
||||
|
|
@ -1818,6 +1819,63 @@ bool simple_wallet::deploy_new_asset(const std::vector<std::string> &args)
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::add_custom_asset_id(const std::vector<std::string> &args)
|
||||
{
|
||||
if (!args.size() || args.size() > 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
}
|
||||
crypto::hash asset_id = currency::null_hash;
|
||||
if (!epee::string_tools::parse_tpod_from_hex_string(args[0], asset_id))
|
||||
{
|
||||
fail_msg_writer() << "expected valid asset_id";
|
||||
return true;
|
||||
}
|
||||
asset_descriptor_base asset_descriptor = AUTO_VAL_INIT(asset_descriptor);
|
||||
bool r = m_wallet->add_custom_asset_id(asset_id, asset_descriptor);
|
||||
if(!r)
|
||||
{
|
||||
fail_msg_writer() << "Asset id " << asset_id << " not found as registered asset";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
success_msg_writer() << "Added custom asset:" << ENDL
|
||||
<< " Id: " << asset_id << ENDL
|
||||
<< " Title: " << asset_descriptor.full_name << ENDL
|
||||
<< " Ticker: " << asset_descriptor.ticker << ENDL
|
||||
<< " Ticker: " << print_fixed_decimal_point(asset_descriptor.current_supply, asset_descriptor.decimal_point) << ENDL
|
||||
;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::remove_custom_asset_id(const std::vector<std::string> &args)
|
||||
{
|
||||
if (!args.size() || args.size() > 1)
|
||||
{
|
||||
fail_msg_writer() << "invalid arguments count: " << args.size() << ", expected 1";
|
||||
}
|
||||
crypto::hash asset_id = currency::null_hash;
|
||||
if (!epee::string_tools::parse_tpod_from_hex_string(args[0], asset_id))
|
||||
{
|
||||
fail_msg_writer() << "expected valid asset_id";
|
||||
return true;
|
||||
}
|
||||
|
||||
bool r = m_wallet->delete_custom_asset_id(asset_id);
|
||||
if (!r)
|
||||
{
|
||||
fail_msg_writer() << "Asset id " << asset_id << " not present in this wallet";
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
success_msg_writer() << "Asset id " << asset_id << " removed from wallet custom list" << ENDL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool simple_wallet::sweep_below(const std::vector<std::string> &args)
|
||||
{
|
||||
bool r = false;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,9 @@ namespace currency
|
|||
bool tor_enable(const std::vector<std::string> &args);
|
||||
bool tor_disable(const std::vector<std::string> &args);
|
||||
bool deploy_new_asset(const std::vector<std::string> &args);
|
||||
bool add_custom_asset_id(const std::vector<std::string> &args);
|
||||
bool remove_custom_asset_id(const std::vector<std::string> &args);
|
||||
|
||||
bool validate_wrap_status(uint64_t amount);
|
||||
|
||||
bool get_alias_from_daemon(const std::string& alias_name, currency::extra_alias_entry_base& ai);
|
||||
|
|
@ -99,7 +102,7 @@ namespace currency
|
|||
|
||||
//----------------- i_wallet2_callback ---------------------
|
||||
virtual void on_new_block(uint64_t height, const currency::block& block) override;
|
||||
virtual void on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) override;
|
||||
virtual void on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, const std::list<tools::wallet_public::asset_balance_entry>& balances, uint64_t total_mined) override;
|
||||
virtual void on_message(i_wallet2_callback::message_severity severity, const std::string& m) override;
|
||||
virtual void on_tor_status_change(const std::string& state) override;
|
||||
|
||||
|
|
|
|||
|
|
@ -377,16 +377,14 @@ public:
|
|||
struct transfer_event_info
|
||||
{
|
||||
tools::wallet_public::wallet_transfer_info ti;
|
||||
uint64_t unlocked_balance;
|
||||
uint64_t balance;
|
||||
std::list<tools::wallet_public::asset_balance_entry> balances;
|
||||
uint64_t total_mined;
|
||||
uint64_t wallet_id;
|
||||
bool is_wallet_in_sync_process;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(ti)
|
||||
KV_SERIALIZE(unlocked_balance)
|
||||
KV_SERIALIZE(balance)
|
||||
KV_SERIALIZE(balances)
|
||||
KV_SERIALIZE(total_mined)
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(is_wallet_in_sync_process)
|
||||
|
|
@ -426,10 +424,10 @@ public:
|
|||
|
||||
struct get_recent_transfers_request
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
uint64_t offset;
|
||||
uint64_t count;
|
||||
bool exclude_mining_txs;
|
||||
uint64_t wallet_id = 0;
|
||||
uint64_t offset = 0;
|
||||
uint64_t count = 0;
|
||||
bool exclude_mining_txs = false;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
|
|
@ -439,9 +437,20 @@ public:
|
|||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct wallet_and_asset_id
|
||||
{
|
||||
uint64_t wallet_id = 0;
|
||||
crypto::hash asset_id = currency::null_hash;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct reset_pass_request
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
uint64_t wallet_id = 0;
|
||||
std::string pass;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
|
|
|
|||
|
|
@ -1429,11 +1429,10 @@ void wallet2::rise_on_transfer2(const wallet_public::wallet_transfer_info& wti)
|
|||
PROFILE_FUNC("wallet2::rise_on_transfer2");
|
||||
if (!m_do_rise_transfer)
|
||||
return;
|
||||
uint64_t fake = 0;
|
||||
uint64_t unlocked_balance = 0;
|
||||
std::list<wallet_public::asset_balance_entry> balances;
|
||||
uint64_t mined = 0;
|
||||
uint64_t balance = this->balance(unlocked_balance, fake, fake, mined);
|
||||
m_wcallback->on_transfer2(wti, balance, unlocked_balance, mined);
|
||||
this->balance(balances, mined);
|
||||
m_wcallback->on_transfer2(wti, balances, mined);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void wallet2::handle_money_spent2(const currency::block& b,
|
||||
|
|
@ -2372,7 +2371,7 @@ void wallet2::refresh(size_t & blocks_fetched, bool& received_money, std::atomic
|
|||
}
|
||||
|
||||
|
||||
WLT_LOG("Refresh done, blocks received: " << blocks_fetched << ", balance: " << print_money_brief(balance()) << ", unlocked: " << print_money_brief(unlocked_balance()), blocks_fetched > 0 ? LOG_LEVEL_1 : LOG_LEVEL_2);
|
||||
WLT_LOG("Refresh done, blocks received: " << blocks_fetched, blocks_fetched > 0 ? LOG_LEVEL_1 : LOG_LEVEL_2);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::handle_expiration_list(uint64_t tx_expiration_ts_median)
|
||||
|
|
@ -3145,47 +3144,63 @@ bool wallet2::balance(std::unordered_map<crypto::hash, wallet_public::asset_bala
|
|||
bool wallet2::balance(std::list<wallet_public::asset_balance_entry>& balances, uint64_t& mined) const
|
||||
{
|
||||
load_whitelisted_tokens_if_not_loaded();
|
||||
balances.clear();
|
||||
std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base> balances_map;
|
||||
this->balance(balances_map, mined);
|
||||
std::unordered_map<crypto::hash, currency::asset_descriptor_base> custom_assets_local = m_custom_assets;
|
||||
|
||||
for (auto& own_asset : m_own_asset_descriptors)
|
||||
{
|
||||
if (m_whitelisted_assets.find(own_asset.first) == m_whitelisted_assets.end())
|
||||
{
|
||||
custom_assets_local[own_asset.first] = own_asset.second.asset_descriptor;
|
||||
}
|
||||
}
|
||||
|
||||
asset_descriptor_base native_asset_info = AUTO_VAL_INIT(native_asset_info);
|
||||
native_asset_info.full_name = CURRENCY_NAME_SHORT_BASE;
|
||||
native_asset_info.ticker = CURRENCY_NAME_ABR;
|
||||
native_asset_info.decimal_point = CURRENCY_DISPLAY_DECIMAL_POINT;
|
||||
custom_assets_local[currency::null_hash] = native_asset_info;
|
||||
|
||||
for (const auto& item : balances_map)
|
||||
{
|
||||
asset_descriptor_base native_asset_info = AUTO_VAL_INIT(native_asset_info);
|
||||
native_asset_info.full_name = CURRENCY_NAME_SHORT_BASE;
|
||||
native_asset_info.ticker = CURRENCY_NAME_ABR;
|
||||
native_asset_info.decimal_point = CURRENCY_DISPLAY_DECIMAL_POINT;
|
||||
const asset_descriptor_base* asset_ptr = nullptr;
|
||||
asset_descriptor_base asset_info = AUTO_VAL_INIT(asset_info);
|
||||
//check if asset is whitelisted or customly added
|
||||
if (item.first == currency::null_hash)
|
||||
|
||||
//check if it custom asset
|
||||
auto it_cust = custom_assets_local.find(item.first);
|
||||
if(it_cust == custom_assets_local.end())
|
||||
{
|
||||
asset_ptr = &native_asset_info;
|
||||
auto it_local = m_whitelisted_assets.find(item.first);
|
||||
if(it_local == m_whitelisted_assets.end())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
asset_info = it_local->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
asset_info = it_cust->second;
|
||||
custom_assets_local.erase(it_cust);
|
||||
}
|
||||
|
||||
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;
|
||||
static_cast<currency::asset_descriptor_base&>(new_item.asset_info) = asset_info;
|
||||
}
|
||||
//manually added assets should be always present, at least as zero balanced items
|
||||
for (auto& asset : custom_assets_local)
|
||||
{
|
||||
balances.push_back(wallet_public::asset_balance_entry());
|
||||
wallet_public::asset_balance_entry& new_item = balances.back();
|
||||
new_item.asset_info.asset_id = asset.first;
|
||||
static_cast<currency::asset_descriptor_base&>(new_item.asset_info) = asset.second;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
@ -3197,15 +3212,17 @@ uint64_t wallet2::balance() const
|
|||
return balance(stub, stub, stub, stub);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::add_custom_asset_id(const crypto::hash& asset_id)
|
||||
bool wallet2::add_custom_asset_id(const crypto::hash& asset_id, asset_descriptor_base& asset_descriptor)
|
||||
{
|
||||
currency::COMMAND_RPC_GET_ASSET_INFO::request req = AUTO_VAL_INIT(req);
|
||||
currency::COMMAND_RPC_GET_ASSET_INFO::response resp = AUTO_VAL_INIT(resp);
|
||||
req.asset_id = asset_id;
|
||||
|
||||
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;
|
||||
asset_descriptor = resp.asset_descriptor;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ namespace tools
|
|||
virtual ~i_wallet2_callback() = default;
|
||||
|
||||
virtual void on_new_block(uint64_t /*height*/, const currency::block& /*block*/) {}
|
||||
virtual void on_transfer2(const wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) {}
|
||||
virtual void on_transfer2(const wallet_public::wallet_transfer_info& wti, const std::list<wallet_public::asset_balance_entry>& balances, uint64_t total_mined) {}
|
||||
virtual void on_pos_block_found(const currency::block& /*block*/) {}
|
||||
virtual void on_sync_progress(const uint64_t& /*percents*/) {}
|
||||
virtual void on_transfer_canceled(const wallet_public::wallet_transfer_info& wti) {}
|
||||
|
|
@ -899,7 +899,7 @@ namespace tools
|
|||
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 add_custom_asset_id(const crypto::hash& asset_id, currency::asset_descriptor_base& asset_descriptor);
|
||||
bool delete_custom_asset_id(const crypto::hash& asset_id);
|
||||
bool load_whitelisted_tokens_if_not_loaded() const;
|
||||
bool load_whitelisted_tokens()const;
|
||||
|
|
|
|||
|
|
@ -1361,7 +1361,7 @@ std::string wallets_manager::request_alias_update(const currency::alias_rpc_deta
|
|||
}
|
||||
|
||||
|
||||
std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_params& tp, currency::transaction& res_tx)
|
||||
std::string wallets_manager::transfer(uint64_t wallet_id, const view::transfer_params& tp, currency::transaction& res_tx)
|
||||
{
|
||||
|
||||
std::vector<currency::tx_destination_entry> dsts;
|
||||
|
|
@ -1417,6 +1417,7 @@ std::string wallets_manager::transfer(size_t wallet_id, const view::transfer_par
|
|||
return API_RETURN_CODE_BAD_ARG_WRONG_PAYMENT_ID; // payment id is specified more than once
|
||||
payment_id = embedded_payment_id;
|
||||
}
|
||||
dsts.back().asset_id = d.asset_id;
|
||||
}
|
||||
|
||||
if (payment_id.size())
|
||||
|
|
@ -1538,7 +1539,7 @@ std::string wallets_manager::invoke(uint64_t wallet_id, std::string params)
|
|||
return response_info.m_body;
|
||||
}
|
||||
|
||||
std::string wallets_manager::get_wallet_info(size_t wallet_id, view::wallet_info& wi)
|
||||
std::string wallets_manager::get_wallet_info(uint64_t wallet_id, view::wallet_info& wi)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, w);
|
||||
return get_wallet_info(w, wi);
|
||||
|
|
@ -1675,6 +1676,23 @@ std::string wallets_manager::reset_wallet_password(uint64_t wallet_id, const std
|
|||
else
|
||||
return API_RETURN_CODE_FAIL;
|
||||
}
|
||||
std::string wallets_manager::add_custom_asset_id(uint64_t wallet_id, const crypto::hash& asset_id, currency::asset_descriptor_base& asset_descriptor)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, w);
|
||||
if(w.w->get()->add_custom_asset_id(asset_id, asset_descriptor))
|
||||
return API_RETURN_CODE_OK;
|
||||
else
|
||||
return API_RETURN_CODE_FAIL;
|
||||
}
|
||||
std::string wallets_manager::delete_custom_asset_id(uint64_t wallet_id, const crypto::hash& asset_id)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, w);
|
||||
if (w.w->get()->delete_custom_asset_id(asset_id))
|
||||
return API_RETURN_CODE_OK;
|
||||
else
|
||||
return API_RETURN_CODE_FAIL;
|
||||
|
||||
}
|
||||
std::string wallets_manager::is_wallet_password_valid(uint64_t wallet_id, const std::string& pass)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, w);
|
||||
|
|
@ -1837,12 +1855,12 @@ void wallets_manager::on_new_block(size_t wallet_id, uint64_t /*height*/, const
|
|||
|
||||
}
|
||||
|
||||
void wallets_manager::on_transfer2(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined)
|
||||
void wallets_manager::on_transfer2(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti, const std::list<tools::wallet_public::asset_balance_entry>& balances, uint64_t total_mined)
|
||||
{
|
||||
view::transfer_event_info tei = AUTO_VAL_INIT(tei);
|
||||
tei.ti = wti;
|
||||
tei.balance = balance;
|
||||
tei.unlocked_balance = unlocked_balance;
|
||||
tei.balances = balances;
|
||||
tei.total_mined = total_mined;
|
||||
tei.wallet_id = wallet_id;
|
||||
|
||||
GET_WALLET_OPTIONS_BY_ID_VOID_RET(wallet_id, w);
|
||||
|
|
@ -1886,8 +1904,7 @@ void wallets_manager::on_transfer_canceled(size_t wallet_id, const tools::wallet
|
|||
auto& w = m_wallets[wallet_id].w;
|
||||
if (w->get() != nullptr)
|
||||
{
|
||||
tei.balance = w->get()->balance();
|
||||
tei.unlocked_balance = w->get()->unlocked_balance();
|
||||
w->get()->balance(tei.balances, tei.total_mined);
|
||||
tei.wallet_id = wallet_id;
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public:
|
|||
std::string get_wallet_status(uint64_t wallet_id);
|
||||
std::string run_wallet(uint64_t wallet_id);
|
||||
std::string get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist, bool exclude_mining_txs = false);
|
||||
std::string get_wallet_info(size_t wallet_id, view::wallet_info& wi);
|
||||
std::string get_wallet_info(uint64_t wallet_id, view::wallet_info& wi);
|
||||
std::string get_contracts(size_t wallet_id, std::vector<tools::wallet_public::escrow_contract_details>& contracts);
|
||||
std::string create_proposal(const view::create_proposal_param_gui& cpp);
|
||||
std::string accept_proposal(size_t wallet_id, const crypto::hash& contract_id);
|
||||
|
|
@ -148,7 +148,7 @@ public:
|
|||
std::vector<uint64_t>& days);
|
||||
std::string is_pos_allowed();
|
||||
void toggle_pos_mining();
|
||||
std::string transfer(size_t wallet_id, const view::transfer_params& tp, currency::transaction& res_tx);
|
||||
std::string transfer(uint64_t wallet_id, const view::transfer_params& tp, currency::transaction& res_tx);
|
||||
std::string get_config_folder();
|
||||
std::string is_valid_brain_restore_data(const std::string& seed_phrase, const std::string& seed_password);
|
||||
std::string get_seed_phrase_info(const std::string& seed_phrase, const std::string& seed_password, view::seed_phrase_info& result);
|
||||
|
|
@ -162,6 +162,9 @@ public:
|
|||
std::string get_qt_dev_tools_option() const { return m_qt_dev_tools; }
|
||||
void set_use_deffered_global_outputs(bool use) { m_use_deffered_global_outputs = use; }
|
||||
bool set_use_tor(bool use_tor);
|
||||
std::string add_custom_asset_id(uint64_t wallet_id, const crypto::hash& asset_id, currency::asset_descriptor_base& asset_descriptor);
|
||||
std::string delete_custom_asset_id(uint64_t wallet_id, const crypto::hash& asset_id);
|
||||
|
||||
private:
|
||||
void main_worker(const po::variables_map& vm);
|
||||
bool init_local_daemon();
|
||||
|
|
@ -181,7 +184,7 @@ private:
|
|||
|
||||
//----- i_backend_wallet_callback ------
|
||||
virtual void on_new_block(size_t wallet_id, uint64_t height, const currency::block& block);
|
||||
virtual void on_transfer2(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined);
|
||||
virtual void on_transfer2(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti, const std::list<tools::wallet_public::asset_balance_entry>& balances, uint64_t total_mined);
|
||||
virtual void on_pos_block_found(size_t wallet_id, const currency::block& /*block*/);
|
||||
virtual void on_sync_progress(size_t wallet_id, const uint64_t& /*percents*/);
|
||||
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue