From b18f0b10513b0455723518a634595b2f36d5ea25 Mon Sep 17 00:00:00 2001 From: moneromooo-monero Date: Sat, 13 Apr 2019 09:19:38 +0000 Subject: 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. --- src/wallet/wallet2.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/wallet/wallet2.h') 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 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 lock(m_daemon_rpc_mutex); + if (m_offline) return false; + boost::lock_guard lock(m_daemon_rpc_mutex); return epee::net_utils::invoke_http_json(uri, req, res, m_http_client, timeout, http_method); } template 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 lock(m_daemon_rpc_mutex); + if (m_offline) return false; + boost::lock_guard lock(m_daemon_rpc_mutex); return epee::net_utils::invoke_http_bin(uri, req, res, m_http_client, timeout, http_method); } template 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 lock(m_daemon_rpc_mutex); + if (m_offline) return false; + boost::lock_guard 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 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 m_tx_device; -- cgit v1.2.3