mirror of
https://github.com/monero-project/monero.git
synced 2025-08-17 10:20:48 -04:00
simplewallet: report timestamp based expected unlock time on balance
This commit is contained in:
parent
57854a3e21
commit
8b655de8ed
5 changed files with 52 additions and 24 deletions
|
@ -143,6 +143,7 @@ enum TransferType {
|
|||
};
|
||||
|
||||
static std::string get_human_readable_timespan(std::chrono::seconds seconds);
|
||||
static std::string get_human_readable_timespan(uint64_t seconds);
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -5748,15 +5749,19 @@ bool simple_wallet::show_balance_unlocked(bool detailed)
|
|||
success_msg_writer() << tr("Currently selected account: [") << m_current_subaddress_account << tr("] ") << m_wallet->get_subaddress_label({m_current_subaddress_account, 0});
|
||||
const std::string tag = m_wallet->get_account_tags().second[m_current_subaddress_account];
|
||||
success_msg_writer() << tr("Tag: ") << (tag.empty() ? std::string{tr("(No tag assigned)")} : tag);
|
||||
uint64_t blocks_to_unlock;
|
||||
uint64_t unlocked_balance = m_wallet->unlocked_balance(m_current_subaddress_account, false, &blocks_to_unlock);
|
||||
uint64_t blocks_to_unlock, time_to_unlock;
|
||||
uint64_t unlocked_balance = m_wallet->unlocked_balance(m_current_subaddress_account, false, &blocks_to_unlock, &time_to_unlock);
|
||||
std::string unlock_time_message;
|
||||
if (blocks_to_unlock > 0)
|
||||
if (blocks_to_unlock > 0 && time_to_unlock > 0)
|
||||
unlock_time_message = (boost::format(" (%lu block(s) and %s to unlock)") % blocks_to_unlock % get_human_readable_timespan(time_to_unlock)).str();
|
||||
else if (blocks_to_unlock > 0)
|
||||
unlock_time_message = (boost::format(" (%lu block(s) to unlock)") % blocks_to_unlock).str();
|
||||
else if (time_to_unlock > 0)
|
||||
unlock_time_message = (boost::format(" (%s to unlock)") % get_human_readable_timespan(time_to_unlock)).str();
|
||||
success_msg_writer() << tr("Balance: ") << print_money(m_wallet->balance(m_current_subaddress_account, false)) << ", "
|
||||
<< tr("unlocked balance: ") << print_money(unlocked_balance) << unlock_time_message << extra;
|
||||
std::map<uint32_t, uint64_t> balance_per_subaddress = m_wallet->balance_per_subaddress(m_current_subaddress_account, false);
|
||||
std::map<uint32_t, std::pair<uint64_t, uint64_t>> unlocked_balance_per_subaddress = m_wallet->unlocked_balance_per_subaddress(m_current_subaddress_account, false);
|
||||
std::map<uint32_t, std::pair<uint64_t, std::pair<uint64_t, uint64_t>>> unlocked_balance_per_subaddress = m_wallet->unlocked_balance_per_subaddress(m_current_subaddress_account, false);
|
||||
if (!detailed || balance_per_subaddress.empty())
|
||||
return true;
|
||||
success_msg_writer() << tr("Balance per address:");
|
||||
|
@ -8233,6 +8238,11 @@ static std::string get_human_readable_timespan(std::chrono::seconds seconds)
|
|||
return sw::tr("a long time");
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
static std::string get_human_readable_timespan(uint64_t seconds)
|
||||
{
|
||||
return get_human_readable_timespan(std::chrono::seconds(seconds));
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// mutates local_args as it parses and consumes arguments
|
||||
bool simple_wallet::get_transfers(std::vector<std::string>& local_args, std::vector<transfer_view>& transfers)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue