Daemon-specific proxy for the wallet-rpc.

1. Daemon-specific proxy is exclusive with global proxy (--proxy).
2. If you set global proxy (--proxy) you cannot set daemon-specific proxy.
3. If you don't set global proxy, you can set proxy (or not set) proxy for
each daemon connection with the proxy field in jsonrpc to the wallet-rpc.
This commit is contained in:
0xFFFC0000 2024-02-18 18:36:52 +00:00 committed by woodser
parent 58a1d54a4f
commit cd1c06038c
4 changed files with 30 additions and 4 deletions

View file

@ -4438,6 +4438,13 @@ namespace tools
er.message = "Command unavailable in restricted mode.";
return false;
}
if (m_wallet->has_proxy_option() && !req.proxy.empty())
{
er.code = WALLET_RPC_ERROR_CODE_PROXY_ALREADY_DEFINED;
er.message = "It is not possible to set daemon specific proxy when --proxy is defined.";
return false;
}
std::vector<std::vector<uint8_t>> ssl_allowed_fingerprints;
ssl_allowed_fingerprints.reserve(req.ssl_allowed_fingerprints.size());
@ -4481,7 +4488,7 @@ namespace tools
if (!req.username.empty() || !req.password.empty())
daemon_login.emplace(req.username, req.password);
if (!m_wallet->set_daemon(req.address, daemon_login, req.trusted, std::move(ssl_options)))
if (!m_wallet->set_daemon(req.address, daemon_login, req.trusted, std::move(ssl_options), req.proxy))
{
er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
er.message = std::string("Unable to set daemon");