aboutsummaryrefslogtreecommitdiff
path: root/src/simplewallet/simplewallet.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
-rw-r--r--src/simplewallet/simplewallet.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 7d28de9c0..0581d9de9 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -595,6 +595,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("rescan_bc", boost::bind(&simple_wallet::rescan_blockchain, this, _1), tr("Rescan blockchain from scratch"));
m_cmd_binder.set_handler("set_tx_note", boost::bind(&simple_wallet::set_tx_note, this, _1), tr("Set an arbitrary string note for a txid"));
m_cmd_binder.set_handler("get_tx_note", boost::bind(&simple_wallet::get_tx_note, this, _1), tr("Get a string note for a txid"));
+ m_cmd_binder.set_handler("status", boost::bind(&simple_wallet::status, this, _1), tr("Show wallet status information"));
m_cmd_binder.set_handler("help", boost::bind(&simple_wallet::help, this, _1), tr("Show this help"));
}
//----------------------------------------------------------------------------------------------------
@@ -2968,13 +2969,17 @@ static std::string get_human_readable_timestamp(uint64_t ts)
return "<unknown>";
time_t tt = ts;
struct tm tm;
+#ifdef WIN32
+ gmtime_s(&tm, &tt);
+#else
gmtime_r(&tt, &tm);
+#endif
uint64_t now = time(NULL);
uint64_t diff = ts > now ? ts - now : now - ts;
if (diff > 24*3600)
- strftime(buffer, sizeof(buffer), "%F", &tm);
+ strftime(buffer, sizeof(buffer), "%Y-%m-%d", &tm);
else
- strftime(buffer, sizeof(buffer), "%r", &tm);
+ strftime(buffer, sizeof(buffer), "%I:%M:%S %p", &tm);
return std::string(buffer);
}
//----------------------------------------------------------------------------------------------------
@@ -2994,7 +2999,7 @@ bool simple_wallet::show_transfers(const std::vector<std::string> &args_)
}
LOCK_REFRESH_THREAD_SCOPE();
-
+
// optional in/out selector
if (local_args.size() > 0) {
if (local_args[0] == "in" || local_args[0] == "incoming") {
@@ -3261,6 +3266,29 @@ bool simple_wallet::get_tx_note(const std::vector<std::string> &args)
return true;
}
//----------------------------------------------------------------------------------------------------
+bool simple_wallet::status(const std::vector<std::string> &args)
+{
+ uint64_t local_height = m_wallet->get_blockchain_current_height();
+ if (!m_wallet->check_connection())
+ {
+ success_msg_writer() << "Refreshed " << local_height << "/?, no daemon connected";
+ return true;
+ }
+
+ std::string err;
+ uint64_t bc_height = get_daemon_blockchain_height(err);
+ if (err.empty())
+ {
+ bool synced = local_height == bc_height;
+ success_msg_writer() << "Refreshed " << local_height << "/" << bc_height << ", " << (synced ? "synced" : "syncing");
+ }
+ else
+ {
+ fail_msg_writer() << "Refreshed " << local_height << "/?, daemon connection error";
+ }
+ return true;
+}
+//----------------------------------------------------------------------------------------------------
bool simple_wallet::process_command(const std::vector<std::string> &args)
{
return m_cmd_binder.process_command_vec(args);