diff options
| author | Riccardo Spagni <ric@spagni.net> | 2016-06-21 09:31:50 +0200 |
|---|---|---|
| committer | Riccardo Spagni <ric@spagni.net> | 2016-06-21 09:31:50 +0200 |
| commit | 8c34cca0f0d0eba32808d28785d65787f32d271b (patch) | |
| tree | bf6a36c954dc979ea91ab9f5b861b1dd697b0dc9 /src/simplewallet/simplewallet.cpp | |
| parent | 03477063ba55232af62f66e5fada4006469a9a22 (diff) | |
| parent | f0b85c1631ebf7f16360575edaa270d141a25ee4 (diff) | |
| download | monzero-core-8c34cca0f0d0eba32808d28785d65787f32d271b.tar.gz monzero-core-8c34cca0f0d0eba32808d28785d65787f32d271b.tar.xz monzero-core-8c34cca0f0d0eba32808d28785d65787f32d271b.zip | |
Merge pull request #867
f0b85c1 simplewallet: add a status command (moneromooo-monero)
Diffstat (limited to 'src/simplewallet/simplewallet.cpp')
| -rw-r--r-- | src/simplewallet/simplewallet.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp index 7d28de9c0..51f4109a8 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")); } //---------------------------------------------------------------------------------------------------- @@ -3261,6 +3262,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); |
