mirror of
https://github.com/monero-project/monero.git
synced 2025-12-26 04:42:01 -08:00
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.
This commit is contained in:
@@ -37,9 +37,10 @@ namespace tools
|
||||
|
||||
static const std::chrono::seconds rpc_timeout = std::chrono::minutes(3) + std::chrono::seconds(30);
|
||||
|
||||
NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::mutex &mutex)
|
||||
NodeRPCProxy::NodeRPCProxy(epee::net_utils::http::http_simple_client &http_client, boost::recursive_mutex &mutex)
|
||||
: m_http_client(http_client)
|
||||
, m_daemon_rpc_mutex(mutex)
|
||||
, m_offline(false)
|
||||
{
|
||||
invalidate();
|
||||
}
|
||||
@@ -61,6 +62,8 @@ void NodeRPCProxy::invalidate()
|
||||
|
||||
boost::optional<std::string> NodeRPCProxy::get_rpc_version(uint32_t &rpc_version) const
|
||||
{
|
||||
if (m_offline)
|
||||
return boost::optional<std::string>("offline");
|
||||
if (m_rpc_version == 0)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_GET_VERSION::request req_t = AUTO_VAL_INIT(req_t);
|
||||
@@ -84,6 +87,8 @@ void NodeRPCProxy::set_height(uint64_t h)
|
||||
|
||||
boost::optional<std::string> NodeRPCProxy::get_info() const
|
||||
{
|
||||
if (m_offline)
|
||||
return boost::optional<std::string>("offline");
|
||||
const time_t now = time(NULL);
|
||||
if (now >= m_get_info_time + 30) // re-cache every 30 seconds
|
||||
{
|
||||
@@ -134,6 +139,8 @@ boost::optional<std::string> NodeRPCProxy::get_block_weight_limit(uint64_t &bloc
|
||||
|
||||
boost::optional<std::string> NodeRPCProxy::get_earliest_height(uint8_t version, uint64_t &earliest_height) const
|
||||
{
|
||||
if (m_offline)
|
||||
return boost::optional<std::string>("offline");
|
||||
if (m_earliest_height[version] == 0)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_HARD_FORK_INFO::request req_t = AUTO_VAL_INIT(req_t);
|
||||
@@ -161,6 +168,8 @@ boost::optional<std::string> NodeRPCProxy::get_dynamic_base_fee_estimate(uint64_
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_offline)
|
||||
return boost::optional<std::string>("offline");
|
||||
if (m_dynamic_base_fee_estimate_cached_height != height || m_dynamic_base_fee_estimate_grace_blocks != grace_blocks)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request req_t = AUTO_VAL_INIT(req_t);
|
||||
@@ -191,6 +200,8 @@ boost::optional<std::string> NodeRPCProxy::get_fee_quantization_mask(uint64_t &f
|
||||
if (result)
|
||||
return result;
|
||||
|
||||
if (m_offline)
|
||||
return boost::optional<std::string>("offline");
|
||||
if (m_dynamic_base_fee_estimate_cached_height != height)
|
||||
{
|
||||
cryptonote::COMMAND_RPC_GET_BASE_FEE_ESTIMATE::request req_t = AUTO_VAL_INIT(req_t);
|
||||
|
||||
Reference in New Issue
Block a user