diff --git a/contrib/epee/include/print_fixed_point_helper.h b/contrib/epee/include/print_fixed_point_helper.h index c652f601..91de1dd4 100644 --- a/contrib/epee/include/print_fixed_point_helper.h +++ b/contrib/epee/include/print_fixed_point_helper.h @@ -1,3 +1,4 @@ +// Copyright (c) 2024, Zano Project // Copyright (c) 2006-2017, Andrey N. Sabelnikov, www.sabelnikov.net // All rights reserved. // @@ -39,7 +40,8 @@ namespace epee { s.insert(0, decimal_point + 1 - s.size(), '0'); } - s.insert(s.size() - decimal_point, "."); + if (decimal_point > 0) + s.insert(s.size() - decimal_point, "."); return s; } } diff --git a/src/currency_core/currency_basic.h b/src/currency_core/currency_basic.h index 771ae1a8..0d3e5891 100644 --- a/src/currency_core/currency_basic.h +++ b/src/currency_core/currency_basic.h @@ -700,7 +700,7 @@ namespace currency { uint64_t total_max_supply = 0; uint64_t current_supply = 0; - uint8_t decimal_point = 12; + uint8_t decimal_point = 0; std::string ticker; std::string full_name; std::string meta_info; diff --git a/src/currency_core/currency_format_utils.cpp b/src/currency_core/currency_format_utils.cpp index ce80baf3..c28a212d 100644 --- a/src/currency_core/currency_format_utils.cpp +++ b/src/currency_core/currency_format_utils.cpp @@ -3467,7 +3467,7 @@ namespace currency uint64_t remainder = amount % coin; amount /= coin; if (remainder == 0) - return std::to_string(amount) + ".0"; + return std::to_string(amount) + (decimal_point > 0 ? ".0" : ""); std::string r = std::to_string(remainder); if (r.size() < decimal_point) r.insert(0, decimal_point - r.size(), '0'); diff --git a/src/currency_core/currency_format_utils.h b/src/currency_core/currency_format_utils.h index 66fcce6a..17d6711e 100644 --- a/src/currency_core/currency_format_utils.h +++ b/src/currency_core/currency_format_utils.h @@ -610,20 +610,25 @@ namespace currency return true; } //--------------------------------------------------------------- - // outputs "1391306.970000000000" + // outputs "1391306.970000000000" (decimal_point = 12) + // outputs "1391306970000000000" (decimal_point = 0) template std::string print_fixed_decimal_point(t_number amount, size_t decimal_point) { return epee::string_tools::print_fixed_decimal_point(amount, decimal_point); } //--------------------------------------------------------------- - // outputs "1391306.97 " + // outputs "1391306.97 " (decimal_point = 12) + // outputs "139130697 " (decimal_point = 0) template std::string print_fixed_decimal_point_with_trailing_spaces(t_number amount, size_t decimal_point) { std::string s = epee::string_tools::print_fixed_decimal_point(amount, decimal_point); - for(size_t n = s.size() - 1; n != 0 && s[n] == '0' && s[n-1] != '.'; --n) - s[n] = ' '; + if (s.find('.') != std::string::npos) + { + for(size_t n = s.size() - 1; n != 0 && s[n] == '0' && s[n-1] != '.'; --n) + s[n] = ' '; + } return s; } //--------------------------------------------------------------- diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 182995fb..b4bb5b65 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -3870,7 +3870,7 @@ size_t wallet2::get_asset_decimal_point(const crypto::public_key& asset_id) cons if (it_own != m_own_asset_descriptors.end()) return it_own->second.decimal_point; - return CURRENCY_DISPLAY_DECIMAL_POINT; // fallback to the default + return 0; // fallback to the 0 decimal point (raw numbers) as the default } //---------------------------------------------------------------------------------------------------- @@ -7086,8 +7086,8 @@ bool wallet2::select_indices_for_transfer(assets_selection_context& needed_money const crypto::public_key asset_id = item.first; asset_descriptor_base asset_info{}; uint32_t asset_flags = 0; - bool r = get_asset_info(asset_id, asset_info, asset_flags); - WLT_THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "got unknown asset id: " << asset_id); + if (!get_asset_info(asset_id, asset_info, asset_flags)) + WLT_LOG_L1("select_indices_for_transfer: unknown asset id: " << asset_id); auto asset_cache_it = m_found_free_amounts.find(asset_id); WLT_THROW_IF_FALSE_WALLET_EX_MES(asset_cache_it != m_found_free_amounts.end(), error::not_enough_money, "", item.second.found_amount, item.second.needed_amount, 0, asset_id, asset_info.decimal_point);