simplewallet: add optional trusted/untrusted argument to set_daemon
Otherwise the previous daemon's trustedness would carry over. If not specified, the local address check is performed again.
This commit is contained in:
parent
233a1ead22
commit
85d2ae4ad7
|
@ -2028,7 +2028,7 @@ simple_wallet::simple_wallet()
|
||||||
tr("Stop mining in the daemon."));
|
tr("Stop mining in the daemon."));
|
||||||
m_cmd_binder.set_handler("set_daemon",
|
m_cmd_binder.set_handler("set_daemon",
|
||||||
boost::bind(&simple_wallet::set_daemon, this, _1),
|
boost::bind(&simple_wallet::set_daemon, this, _1),
|
||||||
tr("set_daemon <host>[:<port>]"),
|
tr("set_daemon <host>[:<port>] [trusted|untrusted]"),
|
||||||
tr("Set another daemon to connect to."));
|
tr("Set another daemon to connect to."));
|
||||||
m_cmd_binder.set_handler("save_bc",
|
m_cmd_binder.set_handler("save_bc",
|
||||||
boost::bind(&simple_wallet::save_bc, this, _1),
|
boost::bind(&simple_wallet::save_bc, this, _1),
|
||||||
|
@ -3767,6 +3767,33 @@ bool simple_wallet::set_daemon(const std::vector<std::string>& args)
|
||||||
}
|
}
|
||||||
LOCK_IDLE_SCOPE();
|
LOCK_IDLE_SCOPE();
|
||||||
m_wallet->init(daemon_url);
|
m_wallet->init(daemon_url);
|
||||||
|
|
||||||
|
if (args.size() == 2)
|
||||||
|
{
|
||||||
|
if (args[1] == "trusted")
|
||||||
|
m_trusted_daemon = true;
|
||||||
|
else if (args[1] == "untrusted")
|
||||||
|
m_trusted_daemon = false;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fail_msg_writer() << tr("Expected trusted or untrusted, got ") << args[1] << ": assuming untrusted";
|
||||||
|
m_trusted_daemon = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_trusted_daemon = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (tools::is_local_address(m_wallet->get_daemon_address()))
|
||||||
|
{
|
||||||
|
MINFO(tr("Daemon is local, assuming trusted"));
|
||||||
|
m_trusted_daemon = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (const std::exception &e) { }
|
||||||
|
}
|
||||||
|
success_msg_writer() << boost::format("Daemon set to %s, %s") % daemon_url % (*m_trusted_daemon ? tr("trusted") : tr("untrusted"));
|
||||||
} else {
|
} else {
|
||||||
fail_msg_writer() << tr("This does not seem to be a valid daemon URL.");
|
fail_msg_writer() << tr("This does not seem to be a valid daemon URL.");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue