forked from lthn/blockchain
fixes in simplewallet and mainwindow for new recent_history structure
This commit is contained in:
parent
bf908f43a6
commit
c3397a00eb
9 changed files with 129 additions and 22 deletions
|
|
@ -577,9 +577,9 @@ namespace currency
|
|||
}
|
||||
//---------------------------------------------------------------
|
||||
template<typename t_number>
|
||||
std::string print_money(t_number amount)
|
||||
std::string print_money(t_number amount, uint64_t decimals = CURRENCY_DISPLAY_DECIMAL_POINT)
|
||||
{
|
||||
return print_fixed_decimal_point(amount, CURRENCY_DISPLAY_DECIMAL_POINT);
|
||||
return print_fixed_decimal_point(amount, decimals);
|
||||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -1059,9 +1059,9 @@ bool MainWindow::money_transfer(const view::transfer_event_info& tei)
|
|||
|
||||
if (!m_tray_icon)
|
||||
return true;
|
||||
if (!tei.ti.is_income)
|
||||
if (tei.ti.has_outgoing_entries())
|
||||
return true;
|
||||
if (!tei.ti.amount)
|
||||
if (!tei.ti.get_native_amount())
|
||||
return true;
|
||||
// if (tei.ti.is_mining && m_wallet_states->operator [](tei.wallet_id) != view::wallet_status_info::wallet_state_ready)
|
||||
// return true;
|
||||
|
|
@ -1075,9 +1075,9 @@ bool MainWindow::money_transfer(const view::transfer_event_info& tei)
|
|||
return true;
|
||||
}
|
||||
|
||||
auto amount_str = currency::print_money_brief(tei.ti.amount);
|
||||
auto amount_str = currency::print_money_brief(tei.ti.get_native_amount()); //@#@ add handling of assets
|
||||
std::string title, msg;
|
||||
if (tei.ti.height == 0) // unconfirmed trx
|
||||
if (tei.ti.height == 0) // unconfirmed tx
|
||||
{
|
||||
msg = amount_str + " " + CURRENCY_NAME_ABR + " " + m_localization[localization_id_is_received];
|
||||
title = m_localization[localization_id_income_transfer_unconfirmed];
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 1471e71f4ff685dd080e6551773cf129f1d02c43
|
||||
Subproject commit e1aea269ee057ccb5b68bce83b8beeb4866e560d
|
||||
|
|
@ -715,7 +715,7 @@ void simple_wallet::on_new_block(uint64_t height, const currency::block& block)
|
|||
m_refresh_progress_reporter.update(height, false);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::string print_money_trailing_zeros_replaced_with_spaces(uint64_t amount)
|
||||
std::string print_money_trailing_zeros_replaced_with_spaces(uint64_t amount, size_t decimal_point = CURRENCY_DISPLAY_DECIMAL_POINT)
|
||||
{
|
||||
std::string s = print_money(amount);
|
||||
size_t p = s.find_last_not_of('0');
|
||||
|
|
@ -729,13 +729,64 @@ std::string print_money_trailing_zeros_replaced_with_spaces(uint64_t amount)
|
|||
return s;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
std::string simple_wallet::get_tocken_info_string(const crypto::public_key& asset_id, uint64_t& decimal_points)
|
||||
{
|
||||
std::string token_info = "ZANO";
|
||||
decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
|
||||
if (asset_id != currency::native_coin_asset_id)
|
||||
{
|
||||
currency::asset_descriptor_base adb = AUTO_VAL_INIT(adb);
|
||||
bool whitelisted = false;
|
||||
if (!m_wallet->get_asset_id_info(asset_id, adb, whitelisted))
|
||||
{
|
||||
token_info = "!UNKNOWN!";
|
||||
}
|
||||
else {
|
||||
decimal_points = adb.decimal_point;
|
||||
token_info = adb.ticker;
|
||||
|
||||
if (whitelisted)
|
||||
{
|
||||
token_info += "[*]";
|
||||
}
|
||||
else
|
||||
{
|
||||
token_info += std::string("[") + epee::string_tools::pod_to_hex(asset_id) + "]";
|
||||
}
|
||||
}
|
||||
}
|
||||
return token_info;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
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");
|
||||
|
||||
if (wti.subtransfers.size() == 1)
|
||||
{
|
||||
epee::log_space::console_colors color = !wti.has_outgoing_entries() ? epee::log_space::console_color_green : epee::log_space::console_color_magenta;
|
||||
uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
|
||||
std::string token_info = get_tocken_info_string(wti.subtransfers[0].asset_id, decimal_points);
|
||||
message_writer(color, false) <<
|
||||
"height " << wti.height <<
|
||||
", tx " << wti.tx_hash <<
|
||||
" " << std::right << std::setw(18) << print_money_trailing_zeros_replaced_with_spaces(wti.subtransfers[0].amount, decimal_points) << (wti.subtransfers[0].is_income ? " received," : " spent") << " " << token_info;
|
||||
}
|
||||
else
|
||||
{
|
||||
message_writer(epee::log_space::console_color_cyan, false) <<
|
||||
"height " << wti.height <<
|
||||
", tx " << wti.tx_hash;
|
||||
for (const auto& st : wti.subtransfers)
|
||||
{
|
||||
epee::log_space::console_colors color = st.is_income ? epee::log_space::console_color_green : epee::log_space::console_color_magenta;
|
||||
uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
|
||||
std::string token_info = get_tocken_info_string(st.asset_id, decimal_points);
|
||||
|
||||
message_writer(epee::log_space::console_color_cyan, false) << " "
|
||||
<< std::right << std::setw(18) << print_money_trailing_zeros_replaced_with_spaces(st.amount, decimal_points) << (st.is_income ? " received," : " spent") << " " << token_info;
|
||||
}
|
||||
}
|
||||
|
||||
m_refresh_progress_reporter.update(wti.height, true);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
@ -861,10 +912,10 @@ bool simple_wallet::show_balance(const std::vector<std::string>& args/* = std::v
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool print_wti(const tools::wallet_public::wallet_transfer_info& wti)
|
||||
bool simple_wallet::print_wti(const tools::wallet_public::wallet_transfer_info& wti)
|
||||
{
|
||||
epee::log_space::console_colors cl;
|
||||
if (wti.is_income)
|
||||
if (!wti.has_outgoing_entries())
|
||||
cl = epee::log_space::console_color_green;
|
||||
else
|
||||
cl = epee::log_space::console_color_magenta;
|
||||
|
|
@ -886,11 +937,30 @@ bool print_wti(const tools::wallet_public::wallet_transfer_info& wti)
|
|||
remote_side += remote_side.empty() ? it : (separator + it);
|
||||
}
|
||||
|
||||
success_msg_writer(cl) << "[" << wti.transfer_internal_index << "]" << epee::misc_utils::get_time_str_v2(wti.timestamp) << " "
|
||||
<< (wti.is_income ? "Received " : "Sent ")
|
||||
<< print_money(wti.amount) << "(fee:" << print_money(wti.fee) << ") "
|
||||
<< remote_side
|
||||
<< " " << wti.tx_hash << payment_id_placeholder;
|
||||
if (wti.subtransfers.size() == 1)
|
||||
{
|
||||
success_msg_writer(cl) << "[" << wti.transfer_internal_index << "]" << epee::misc_utils::get_time_str_v2(wti.timestamp) << " "
|
||||
<< (wti.subtransfers[0].is_income ? "Received " : "Sent ")
|
||||
<< print_money(wti.subtransfers[0].amount) << "(fee:" << print_money(wti.fee) << ") "
|
||||
<< remote_side
|
||||
<< " " << wti.tx_hash << payment_id_placeholder;
|
||||
}else
|
||||
{
|
||||
success_msg_writer(cl) << "[" << wti.transfer_internal_index << "]" << epee::misc_utils::get_time_str_v2(wti.timestamp) << " (fee:" << print_money(wti.fee) << ") "
|
||||
<< remote_side
|
||||
<< " " << wti.tx_hash << payment_id_placeholder;
|
||||
for (auto& st: wti.subtransfers)
|
||||
{
|
||||
epee::log_space::console_colors cl = st.is_income ? epee::log_space::console_color_green: epee::log_space::console_color_magenta;
|
||||
uint64_t decimal_points = CURRENCY_DISPLAY_DECIMAL_POINT;
|
||||
std::string token_info = get_tocken_info_string(st.asset_id, decimal_points);
|
||||
|
||||
success_msg_writer(cl)
|
||||
<< (st.is_income ? "Received " : "Sent ")
|
||||
<< print_money(st.amount, decimal_points) << token_info;
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -104,6 +104,8 @@ namespace currency
|
|||
|
||||
uint64_t get_daemon_blockchain_height(std::string& err);
|
||||
bool try_connect_to_daemon();
|
||||
std::string get_tocken_info_string(const crypto::public_key& asset_id, uint64_t& decimal_point);
|
||||
bool simple_wallet::print_wti(const tools::wallet_public::wallet_transfer_info& wti);
|
||||
|
||||
//----------------- i_wallet2_callback ---------------------
|
||||
virtual void on_new_block(uint64_t height, const currency::block& block) override;
|
||||
|
|
|
|||
|
|
@ -3405,6 +3405,38 @@ bool wallet2::balance(std::list<wallet_public::asset_balance_entry>& balances, u
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::get_asset_id_info(const crypto::public_key& asset_id, currency::asset_descriptor_base& asset_info, bool& whitelist_) const
|
||||
{
|
||||
if (asset_id == currency::native_coin_asset_id)
|
||||
{
|
||||
return CURRENCY_NAME_ABR;
|
||||
}
|
||||
//check if asset is whitelisted or customly added
|
||||
whitelist_ = false;
|
||||
auto it_white = m_whitelisted_assets.find(asset_id);
|
||||
if (it_white == m_whitelisted_assets.end())
|
||||
{
|
||||
//check if it custom asset
|
||||
auto it_cust = m_custom_assets.find(asset_id);
|
||||
if (it_cust == m_custom_assets.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
asset_info = it_cust->second;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
asset_info = it_white->second;
|
||||
whitelist_ = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
|
||||
uint64_t wallet2::balance() const
|
||||
{
|
||||
uint64_t stub = 0;
|
||||
|
|
|
|||
|
|
@ -668,7 +668,7 @@ namespace tools
|
|||
uint64_t balance(uint64_t& unloked) const;
|
||||
|
||||
uint64_t unlocked_balance() const;
|
||||
|
||||
bool get_asset_id_info(const crypto::public_key& asset_id, currency::asset_descriptor_base& asset_info, bool& whitelist_) const;
|
||||
void transfer(uint64_t amount, const currency::account_public_address& acc, const crypto::public_key& asset_id = currency::native_coin_asset_id);
|
||||
void transfer(uint64_t amount, size_t fake_outs_count, const currency::account_public_address& acc, uint64_t fee = TX_DEFAULT_FEE, const crypto::public_key& asset_id = currency::native_coin_asset_id);
|
||||
void transfer(uint64_t amount, const currency::account_public_address& acc, currency::transaction& result_tx, const crypto::public_key& asset_id = currency::native_coin_asset_id);
|
||||
|
|
@ -1195,7 +1195,7 @@ private:
|
|||
mutable uint64_t m_current_wallet_file_size;
|
||||
bool m_use_deffered_global_outputs;
|
||||
bool m_disable_tor_relay;
|
||||
bool m_use_assets_whitelisting = false;
|
||||
bool m_use_assets_whitelisting = true;
|
||||
|
||||
mutable current_operation_context m_current_context;
|
||||
//this needed to access wallets state in coretests, for creating abnormal blocks and tranmsactions
|
||||
|
|
|
|||
|
|
@ -561,9 +561,11 @@ namespace wallet_public
|
|||
{
|
||||
uint64_t amount;
|
||||
std::string address;
|
||||
crypto::public_key asset_id;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(amount)
|
||||
KV_SERIALIZE(address)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(asset_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -366,6 +366,7 @@ namespace tools
|
|||
payment_id = embedded_payment_id;
|
||||
}
|
||||
de.amount = it->amount;
|
||||
de.asset_id = (it->asset_id == currency::null_pkey ? currency::native_coin_asset_id : it->asset_id);
|
||||
dsts.push_back(de);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue