aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.h
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-13 09:19:38 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-15 09:14:12 +0000
commitb18f0b10513b0455723518a634595b2f36d5ea25 (patch)
tree23e2ff63654667f8524d35a229e4d9f437d3bf77 /src/wallet/wallet2.h
parentMerge pull request #5440 (diff)
downloadmonero-b18f0b10513b0455723518a634595b2f36d5ea25.tar.xz
wallet: new --offline option
It will avoid connecting to a daemon (so useful for cold signing using a RPC wallet), and not perform DNS queries.
Diffstat (limited to 'src/wallet/wallet2.h')
-rw-r--r--src/wallet/wallet2.h13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 39380c9df..094346293 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -1232,19 +1232,22 @@ namespace tools
template<class t_request, class t_response>
inline bool invoke_http_json(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET")
{
- boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
+ if (m_offline) return false;
+ boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
return epee::net_utils::invoke_http_json(uri, req, res, m_http_client, timeout, http_method);
}
template<class t_request, class t_response>
inline bool invoke_http_bin(const boost::string_ref uri, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET")
{
- boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
+ if (m_offline) return false;
+ boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
return epee::net_utils::invoke_http_bin(uri, req, res, m_http_client, timeout, http_method);
}
template<class t_request, class t_response>
inline bool invoke_http_json_rpc(const boost::string_ref uri, const std::string& method_name, const t_request& req, t_response& res, std::chrono::milliseconds timeout = std::chrono::seconds(15), const boost::string_ref http_method = "GET", const std::string& req_id = "0")
{
- boost::lock_guard<boost::mutex> lock(m_daemon_rpc_mutex);
+ if (m_offline) return false;
+ boost::lock_guard<boost::recursive_mutex> lock(m_daemon_rpc_mutex);
return epee::net_utils::invoke_http_json_rpc(uri, method_name, req, res, m_http_client, timeout, http_method, req_id);
}
@@ -1291,6 +1294,7 @@ namespace tools
uint64_t hash_m_transfers(int64_t transfer_height, crypto::hash &hash) const;
void finish_rescan_bc_keep_key_images(uint64_t transfer_height, const crypto::hash &hash);
void enable_dns(bool enable) { m_use_dns = enable; }
+ void set_offline(bool offline = true);
private:
/*!
@@ -1422,7 +1426,7 @@ namespace tools
std::atomic<bool> m_run;
- boost::mutex m_daemon_rpc_mutex;
+ boost::recursive_mutex m_daemon_rpc_mutex;
bool m_trusted_daemon;
i_wallet2_callback* m_callback;
@@ -1474,6 +1478,7 @@ namespace tools
std::string m_device_derivation_path;
uint64_t m_device_last_key_image_sync;
bool m_use_dns;
+ bool m_offline;
// Aux transaction data from device
std::unordered_map<crypto::hash, std::string> m_tx_device;