aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
authorRiccardo Spagni <ric@spagni.net>2016-09-29 22:13:49 +0200
committerRiccardo Spagni <ric@spagni.net>2016-09-29 22:13:49 +0200
commitf195a447ccf1a26eba8aaf7560e6bfc902db6f77 (patch)
treeee36fd1a595b1d0df170f805e2a0b6a4d2d90019 /src/wallet/wallet2.cpp
parentMerge pull request #1137 (diff)
parentwallet2: wallet2::get_daemon_blockchain_height() clean error message on (diff)
downloadmonero-f195a447ccf1a26eba8aaf7560e6bfc902db6f77.tar.xz
Merge pull request #1136
2dacb19 wallet2: wallet2::get_daemon_blockchain_height() clean error message on success (Ilya Kitaev) 25e5efc libwallet_api: Wallet::setAutoRefreshInterval sanity check (Ilya Kitaev) a668820 libwallet_api: explicitly return 0 in Wallet::daemonBlockChainHeight() on error (Ilya Kitaev) aef92f2 libwallet_api: tests: fixed WalletCallbackReceived test (Ilya Kitaev) 15c0882 libwallet_api: tests: test fixed according implementation (Ilya Kitaev) a7882da libwallet_api: tests: compilation errors fixed (Ilya Kitaev) cda4cb9 formatting: 2-spaces indentation (Ilya Kitaev) 545a48f formatting: 2-spaces indentation (Ilya Kitaev) 3079c57 wallet2_api: milliseconds resolution for auto-refresh interval (Ilya Kitaev) 7b4a85b wallet2_api: added Wallet::daemonBlockChainHeight() (Ilya Kitaev) 9de3ec3 libwallet_api: Wallet::blockChainHeight, WalletListener::newBlock (Ilya Kitaev)
Diffstat (limited to '')
-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 3d4f93aff..ed4ab93de 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -4053,6 +4053,38 @@ std::string wallet2::get_daemon_address() const
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 // success, cleaning up error message
+ {
+ err = "";
+ }
+ }
+ else
+ {
+ err = "possibly lost connection to daemon";
+ }
+ return res.height;
+}
+
void wallet2::set_tx_note(const crypto::hash &txid, const std::string &note)
{
m_tx_notes[txid] = note;