aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authorIlya Kitaev <mbg033@gmail.com>2016-09-26 21:35:00 +0300
committerIlya Kitaev <mbg033@gmail.com>2016-09-26 23:19:25 +0300
commit7b4a85b309aa0fb864d63a2fd6f1ae062aaa71dd (patch)
treebd7c073734e9de7b2326ded18bfda73557aaa9eb /src/wallet/wallet2.cpp
parentlibwallet_api: Wallet::blockChainHeight, WalletListener::newBlock (diff)
downloadmonero-7b4a85b309aa0fb864d63a2fd6f1ae062aaa71dd.tar.xz
wallet2_api: added Wallet::daemonBlockChainHeight()
Diffstat (limited to '')
-rw-r--r--src/wallet/wallet2.cpp30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 3d4f93aff..07b305b4c 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -4050,7 +4050,35 @@ std::string wallet2::get_keys_file() const
std::string wallet2::get_daemon_address() const
{
- return m_daemon_address;
+ return m_daemon_address;
+}
+
+uint64_t wallet2::get_daemon_blockchain_height(string &err)
+{
+ // XXX: DRY violation. copy-pasted from simplewallet.cpp:get_daemon_blockchain_height()
+ // consider to move it from simplewallet to wallet2 ?
+ COMMAND_RPC_GET_HEIGHT::request req;
+ COMMAND_RPC_GET_HEIGHT::response res = boost::value_initialized<COMMAND_RPC_GET_HEIGHT::response>();
+ m_daemon_rpc_mutex.lock();
+ bool ok = net_utils::invoke_http_json_remote_command2(m_daemon_address + "/getheight", req, res, m_http_client);
+ m_daemon_rpc_mutex.unlock();
+ // XXX: DRY violation. copy-pasted from simplewallet.cpp:interpret_rpc_response()
+ if (ok)
+ {
+ if (res.status == CORE_RPC_STATUS_BUSY)
+ {
+ err = "daemon is busy. Please try again later.";
+ }
+ else if (res.status != CORE_RPC_STATUS_OK)
+ {
+ err = res.status;
+ }
+ }
+ else
+ {
+ err = "possibly lost connection to daemon";
+ }
+ return res.height;
}
void wallet2::set_tx_note(const crypto::hash &txid, const std::string &note)