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
parent 059028a30a
commit c50ade514f
No known key found for this signature in database
GPG key ID: 650F7C2B7BDA3819
5 changed files with 31 additions and 4 deletions

View file

@ -4406,6 +4406,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());
@ -4449,7 +4456,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");