Merge pull request #6299
9c1f970b
wallet2: remember daemon address overrides when loading a new wallet (moneromooo-monero)
This commit is contained in:
commit
72262b348a
@ -150,6 +150,9 @@ static const std::string MULTISIG_EXTRA_INFO_MAGIC = "MultisigxV1";
|
|||||||
|
|
||||||
static const std::string ASCII_OUTPUT_MAGIC = "MoneroAsciiDataV1";
|
static const std::string ASCII_OUTPUT_MAGIC = "MoneroAsciiDataV1";
|
||||||
|
|
||||||
|
boost::mutex tools::wallet2::default_daemon_address_lock;
|
||||||
|
std::string tools::wallet2::default_daemon_address = "";
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::string get_default_ringdb_path()
|
std::string get_default_ringdb_path()
|
||||||
@ -413,6 +416,15 @@ std::unique_ptr<tools::wallet2> make_basic(const boost::program_options::variabl
|
|||||||
daemon_port = get_config(nettype).RPC_DEFAULT_PORT;
|
daemon_port = get_config(nettype).RPC_DEFAULT_PORT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no daemon settings are given and we have a previous one, reuse that one
|
||||||
|
if (command_line::is_arg_defaulted(vm, opts.daemon_host) && command_line::is_arg_defaulted(vm, opts.daemon_port) && command_line::is_arg_defaulted(vm, opts.daemon_address))
|
||||||
|
{
|
||||||
|
// not a bug: taking a const ref to a temporary in this way is actually ok in a recent C++ standard
|
||||||
|
const std::string &def = tools::wallet2::get_default_daemon_address();
|
||||||
|
if (!def.empty())
|
||||||
|
daemon_address = def;
|
||||||
|
}
|
||||||
|
|
||||||
if (daemon_address.empty())
|
if (daemon_address.empty())
|
||||||
daemon_address = std::string("http://") + daemon_host + ":" + std::to_string(daemon_port);
|
daemon_address = std::string("http://") + daemon_host + ":" + std::to_string(daemon_port);
|
||||||
|
|
||||||
@ -1318,8 +1330,15 @@ bool wallet2::set_daemon(std::string daemon_address, boost::optional<epee::net_u
|
|||||||
m_node_rpc_proxy.invalidate();
|
m_node_rpc_proxy.invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
MINFO("setting daemon to " << get_daemon_address());
|
const std::string address = get_daemon_address();
|
||||||
return m_http_client.set_server(get_daemon_address(), get_daemon_login(), std::move(ssl_options));
|
MINFO("setting daemon to " << address);
|
||||||
|
bool ret = m_http_client.set_server(address, get_daemon_login(), std::move(ssl_options));
|
||||||
|
if (ret)
|
||||||
|
{
|
||||||
|
CRITICAL_REGION_LOCAL(default_daemon_address_lock);
|
||||||
|
default_daemon_address = address;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------------------------
|
||||||
bool wallet2::init(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, boost::asio::ip::tcp::endpoint proxy, uint64_t upper_transaction_weight_limit, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options)
|
bool wallet2::init(std::string daemon_address, boost::optional<epee::net_utils::http::login> daemon_login, boost::asio::ip::tcp::endpoint proxy, uint64_t upper_transaction_weight_limit, bool trusted_daemon, epee::net_utils::ssl_options_t ssl_options)
|
||||||
|
@ -1389,6 +1389,8 @@ private:
|
|||||||
uint64_t credits() const { return m_rpc_payment_state.credits; }
|
uint64_t credits() const { return m_rpc_payment_state.credits; }
|
||||||
void credit_report(uint64_t &expected_spent, uint64_t &discrepancy) const { expected_spent = m_rpc_payment_state.expected_spent; discrepancy = m_rpc_payment_state.discrepancy; }
|
void credit_report(uint64_t &expected_spent, uint64_t &discrepancy) const { expected_spent = m_rpc_payment_state.expected_spent; discrepancy = m_rpc_payment_state.discrepancy; }
|
||||||
|
|
||||||
|
static std::string get_default_daemon_address() { CRITICAL_REGION_LOCAL(default_daemon_address_lock); return default_daemon_address; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*!
|
/*!
|
||||||
* \brief Stores wallet information to wallet file.
|
* \brief Stores wallet information to wallet file.
|
||||||
@ -1629,6 +1631,9 @@ private:
|
|||||||
std::unique_ptr<wallet_device_callback> m_device_callback;
|
std::unique_ptr<wallet_device_callback> m_device_callback;
|
||||||
|
|
||||||
ExportFormat m_export_format;
|
ExportFormat m_export_format;
|
||||||
|
|
||||||
|
static boost::mutex default_daemon_address_lock;
|
||||||
|
static std::string default_daemon_address;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
BOOST_CLASS_VERSION(tools::wallet2, 29)
|
BOOST_CLASS_VERSION(tools::wallet2, 29)
|
||||||
|
Loading…
Reference in New Issue
Block a user