aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet_rpc_server.cpp
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-03-18 11:45:31 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2019-04-01 16:03:25 +0000
commit67aa4adcfcd8ce06d2dbd9605df6af3d2a67e0da (patch)
tree2fe7c4c611c8ecc6d4e2e6c197d944fc09edd0dd /src/wallet/wallet_rpc_server.cpp
parentwallet2: init some variables to default values if loading old wallets (diff)
downloadmonero-67aa4adcfcd8ce06d2dbd9605df6af3d2a67e0da.tar.xz
wallet_rpc_server: add a set_daemon RPC
Diffstat (limited to 'src/wallet/wallet_rpc_server.cpp')
-rw-r--r--src/wallet/wallet_rpc_server.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/wallet/wallet_rpc_server.cpp b/src/wallet/wallet_rpc_server.cpp
index a9bb63e2b..e0a77e34c 100644
--- a/src/wallet/wallet_rpc_server.cpp
+++ b/src/wallet/wallet_rpc_server.cpp
@@ -4033,6 +4033,40 @@ namespace tools
return false;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool wallet_rpc_server::on_set_daemon(const wallet_rpc::COMMAND_RPC_SET_DAEMON::request& req, wallet_rpc::COMMAND_RPC_SET_DAEMON::response& res, epee::json_rpc::error& er, const connection_context *ctx)
+ {
+ if (!m_wallet) return not_open(er);
+ if (m_restricted)
+ {
+ er.code = WALLET_RPC_ERROR_CODE_DENIED;
+ er.message = "Command unavailable in restricted mode.";
+ return false;
+ }
+ epee::net_utils::ssl_support_t ssl_support;
+ if (!epee::net_utils::ssl_support_from_string(ssl_support, req.ssl_support))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
+ er.message = std::string("Invalid ssl support mode");
+ return false;
+ }
+ std::vector<std::vector<uint8_t>> ssl_allowed_fingerprints;
+ ssl_allowed_fingerprints.reserve(req.ssl_allowed_fingerprints.size());
+ for (const std::string &fp: req.ssl_allowed_fingerprints)
+ {
+ ssl_allowed_fingerprints.push_back({});
+ std::vector<uint8_t> &v = ssl_allowed_fingerprints.back();
+ for (auto c: fp)
+ v.push_back(c);
+ }
+ if (!m_wallet->set_daemon(req.address, boost::none, req.trusted, ssl_support, std::make_pair(req.ssl_private_key_path, req.ssl_certificate_path), req.ssl_allowed_certificates, ssl_allowed_fingerprints, req.ssl_allow_any_cert))
+ {
+ er.code = WALLET_RPC_ERROR_CODE_NO_DAEMON_CONNECTION;
+ er.message = std::string("Unable to set daemon");
+ return false;
+ }
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool wallet_rpc_server::on_get_version(const wallet_rpc::COMMAND_RPC_GET_VERSION::request& req, wallet_rpc::COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& er, const connection_context *ctx)
{
res.version = WALLET_RPC_VERSION;