aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-10-04 12:15:02 +0200
committerRiccardo Spagni <ric@spagni.net>2016-10-04 12:15:02 +0200
commit2723cd12e15defadbf98123ae6791fedc8172814 (patch)
treeae9a65a0ddc141371d8eb7ef03e1de80efbb6107 /src/wallet/wallet2.cpp
parentMerge pull request #1165 (diff)
parentwallet2_api: added Wallet::daemonBlockChainTargetHeight() (diff)
downloadmonero-2723cd12e15defadbf98123ae6791fedc8172814.tar.xz
Merge pull request #1173
65ea836 wallet2_api: added Wallet::daemonBlockChainTargetHeight() libwallet_api: Wallet::blockChainTargetHeight (Jacob Brydolf)
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index be55427fe..e3736bc3d 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -4266,6 +4266,38 @@ uint64_t wallet2::get_daemon_blockchain_height(string &err)
return res.height;
}
+uint64_t wallet2::get_daemon_blockchain_target_height(string &err)
+{
+ epee::json_rpc::request<cryptonote::COMMAND_RPC_GET_INFO::request> req_t = AUTO_VAL_INIT(req_t);
+ epee::json_rpc::response<cryptonote::COMMAND_RPC_GET_INFO::response, std::string> resp_t = AUTO_VAL_INIT(resp_t);
+ m_daemon_rpc_mutex.lock();
+ req_t.jsonrpc = "2.0";
+ req_t.id = epee::serialization::storage_entry(0);
+ req_t.method = "get_info";
+ bool ok = net_utils::invoke_http_json_remote_command2(m_daemon_address + "/json_rpc", req_t, resp_t, m_http_client);
+ m_daemon_rpc_mutex.unlock();
+ if (ok)
+ {
+ if (resp_t.result.status == CORE_RPC_STATUS_BUSY)
+ {
+ err = "daemon is busy. Please try again later.";
+ }
+ else if (resp_t.result.status != CORE_RPC_STATUS_OK)
+ {
+ err = resp_t.result.status;
+ }
+ else // success, cleaning up error message
+ {
+ err = "";
+ }
+ }
+ else
+ {
+ err = "possibly lost connection to daemon";
+ }
+ return resp_t.result.target_height;
+}
+
void wallet2::set_tx_note(const crypto::hash &txid, const std::string &note)
{
m_tx_notes[txid] = note;