diff --git a/CMakeLists.txt b/CMakeLists.txt index 915705c74..28b486e00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -215,9 +215,30 @@ set(CRYPTONOTE_SOURCES cryptonote/src/CryptoNoteProtocol/CryptoNoteProtocolHandler.cpp cryptonote/src/InProcessNode/InProcessNode.cpp cryptonote/src/InProcessNode/InProcessNodeErrors.cpp + cryptonote/src/HTTP/httplib.h + cryptonote/src/HTTP/HttpRequest.cpp + cryptonote/src/HTTP/HttpParser.cpp + cryptonote/src/HTTP/HttpParserErrorCodes.cpp + cryptonote/src/HTTP/HttpResponse.cpp + cryptonote/src/Logging/ILogger.cpp + cryptonote/src/Logging/LoggerGroup.cpp + cryptonote/src/Logging/CommonLogger.cpp + cryptonote/src/Logging/LoggerManager.cpp + cryptonote/src/Logging/FileLogger.cpp + cryptonote/src/Logging/StreamLogger.cpp + cryptonote/src/Logging/ConsoleLogger.cpp + cryptonote/src/Logging/LoggerMessage.cpp + cryptonote/src/Logging/LoggerRef.cpp cryptonote/src/NodeRpcProxy/NodeErrors.cpp cryptonote/src/NodeRpcProxy/NodeRpcProxy.cpp + cryptonote/src/P2p/LevinProtocol.cpp + cryptonote/src/P2p/NetNodeConfig.cpp + cryptonote/src/P2p/NetNode.cpp cryptonote/src/P2p/NetNodeConfig.cpp + cryptonote/src/P2p/PeerListManager.cpp + cryptonote/src/Rpc/JsonRpc.cpp + cryptonote/src/Rpc/RpcServer.cpp + cryptonote/src/Rpc/RpcServerConfig.cpp cryptonote/src/Serialization/BinaryInputStreamSerializer.cpp cryptonote/src/Serialization/BinaryOutputStreamSerializer.cpp cryptonote/src/Serialization/JsonInputValueSerializer.cpp @@ -226,6 +247,13 @@ set(CRYPTONOTE_SOURCES cryptonote/src/Serialization/KVBinaryOutputStreamSerializer.cpp cryptonote/src/Serialization/BlockchainExplorerDataSerialization.cpp cryptonote/src/Serialization/SerializationOverloads.cpp + cryptonote/src/System/ContextGroup.cpp + cryptonote/src/System/Event.cpp + cryptonote/src/System/EventLock.cpp + cryptonote/src/System/InterruptedException.cpp + cryptonote/src/System/Ipv4Address.cpp + cryptonote/src/System/SocketStream.cpp + cryptonote/src/System/TcpStream.cpp cryptonote/src/Transfers/BlockchainSynchronizer.cpp cryptonote/src/Transfers/SynchronizationState.cpp cryptonote/src/Transfers/TransfersConsumer.cpp @@ -246,32 +274,6 @@ set(CRYPTONOTE_SOURCES cryptonote/src/WalletLegacy/WalletTransactionSender.cpp cryptonote/src/WalletLegacy/WalletUnconfirmedTransactions.cpp cryptonote/src/WalletLegacy/WalletUserTransactionsCache.cpp - cryptonote/src/System/ContextGroup.cpp - cryptonote/src/System/Event.cpp - cryptonote/src/System/EventLock.cpp - cryptonote/src/System/InterruptedException.cpp - cryptonote/src/System/Ipv4Address.cpp - cryptonote/src/System/SocketStream.cpp - cryptonote/src/System/TcpStream.cpp - cryptonote/src/HTTP/HttpRequest.cpp - cryptonote/src/HTTP/HttpParser.cpp - cryptonote/src/HTTP/HttpParserErrorCodes.cpp - cryptonote/src/HTTP/HttpResponse.cpp - cryptonote/src/Rpc/HttpClient.cpp - cryptonote/src/Rpc/JsonRpc.cpp - cryptonote/src/P2p/NetNode.cpp - cryptonote/src/P2p/LevinProtocol.cpp - cryptonote/src/P2p/NetNodeConfig.cpp - cryptonote/src/P2p/PeerListManager.cpp - cryptonote/src/Logging/ILogger.cpp - cryptonote/src/Logging/LoggerGroup.cpp - cryptonote/src/Logging/CommonLogger.cpp - cryptonote/src/Logging/LoggerManager.cpp - cryptonote/src/Logging/FileLogger.cpp - cryptonote/src/Logging/StreamLogger.cpp - cryptonote/src/Logging/ConsoleLogger.cpp - cryptonote/src/Logging/LoggerMessage.cpp - cryptonote/src/Logging/LoggerRef.cpp cryptonote/src/BlockchainExplorer/BlockchainExplorer.cpp cryptonote/src/BlockchainExplorer/BlockchainExplorerDataBuilder.cpp cryptonote/src/BlockchainExplorer/BlockchainExplorerErrors.cpp @@ -506,6 +508,7 @@ if (WIN32) endif () if (OPENSSL_FOUND) + add_definitions(-DCPPHTTPLIB_OPENSSL_SUPPORT) target_link_libraries(${PROJECT_NAME} ${OPENSSL_LIBRARIES}) if (MSVC) target_link_libraries(${PROJECT_NAME} Rpcrt4 ws2_32 advapi32 crypt32 gdi32 user32) diff --git a/cryptonote b/cryptonote index 5e0566b46..71b6268c1 160000 --- a/cryptonote +++ b/cryptonote @@ -1 +1 @@ -Subproject commit 5e0566b4669352d2dfb951b091f3180dedb8e77d +Subproject commit 71b6268c1bf10d305a5200b4422ea36d315f0b07 diff --git a/src/CommandLineParser.cpp b/src/CommandLineParser.cpp index 4fcfed33a..2abc8efb1 100644 --- a/src/CommandLineParser.cpp +++ b/src/CommandLineParser.cpp @@ -17,6 +17,10 @@ CommandLineParser::CommandLineParser(QObject* _parent) : QObject(_parent), m_par m_withoutCheckpointsOption("without-checkpoints", tr("Do not load checkpoints for full blocks validation")), m_p2pBindIpOption("p2p-bind-ip", tr("Interface for p2p network protocol"), tr("ip"), "0.0.0.0"), m_p2pBindPortOption("p2p-bind-port", tr("Port for p2p network protocol"), tr("port"), QString::number(CryptoNote::P2P_DEFAULT_PORT)), + m_rpcBindIpOption("rpc-bind-ip", tr("Interface for RPC server"), tr("ip"), "127.0.0.1"), + m_rpcBindPortOption("rpc-bind-port", tr("Port for RPC server"), tr("port"), QString::number(CryptoNote::RPC_DEFAULT_PORT)), + m_rpcOption("rpc-server", tr("Run RPC server")), + m_restrictedRpcOption("restricted-rpc", tr("Disallow some RPC server queries")), m_p2pExternalOption("p2p-external-port", tr("External port for p2p network protocol (if port forwarding used with NAT)"), tr("port"), 0), m_allowLocalIpOption("allow-local-ip", tr("Allow local ip add to peer list, mostly in debug purposes")), @@ -39,6 +43,10 @@ CommandLineParser::CommandLineParser(QObject* _parent) : QObject(_parent), m_par m_parser.addOption(m_withoutCheckpointsOption); m_parser.addOption(m_p2pBindIpOption); m_parser.addOption(m_p2pBindPortOption); + m_parser.addOption(m_rpcBindIpOption); + m_parser.addOption(m_rpcBindPortOption); + m_parser.addOption(m_rpcOption); + m_parser.addOption(m_restrictedRpcOption); m_parser.addOption(m_p2pExternalOption); m_parser.addOption(m_allowLocalIpOption); m_parser.addOption(m_addPeerOption); @@ -117,6 +125,22 @@ quint16 CommandLineParser::getP2pBindPort() const { return m_parser.value(m_p2pBindPortOption).toUShort(); } +QString CommandLineParser::getRpcBindIp() const { + return m_parser.value(m_rpcBindIpOption); +} + +quint16 CommandLineParser::getRpcBindPort() const { + return m_parser.value(m_rpcBindPortOption).toUShort(); +} + +bool CommandLineParser::hasRpcOption() const { + return m_parser.isSet(m_rpcOption); +} + +bool CommandLineParser::hasRestrictedRpcOption() const { + return m_parser.isSet(m_restrictedRpcOption); +} + quint16 CommandLineParser::getP2pExternalPort() const { return m_parser.value(m_p2pExternalOption).toUShort(); } diff --git a/src/CommandLineParser.h b/src/CommandLineParser.h index 9d1dd7f09..ed4aef707 100644 --- a/src/CommandLineParser.h +++ b/src/CommandLineParser.h @@ -29,10 +29,14 @@ class CommandLineParser : public QObject { bool hasHideMyPortOption() const; bool hasPortableOption() const; bool hasAllowReorgOption() const; + bool hasRpcOption() const; + bool hasRestrictedRpcOption() const; QString getErrorText() const; QString getHelpText() const; QString getP2pBindIp() const; quint16 getP2pBindPort() const; + QString getRpcBindIp() const; + quint16 getRpcBindPort() const; quint16 getP2pExternalPort() const; QStringList getPeers() const; QStringList getPiorityNodes() const; @@ -49,6 +53,10 @@ class CommandLineParser : public QObject { QCommandLineOption m_withoutCheckpointsOption; QCommandLineOption m_p2pBindIpOption; QCommandLineOption m_p2pBindPortOption; + QCommandLineOption m_rpcBindIpOption; + QCommandLineOption m_rpcBindPortOption; + QCommandLineOption m_rpcOption; + QCommandLineOption m_restrictedRpcOption; QCommandLineOption m_p2pExternalOption; QCommandLineOption m_allowLocalIpOption; QCommandLineOption m_addPeerOption; diff --git a/src/CryptoNoteWrapper.cpp b/src/CryptoNoteWrapper.cpp index 7f5a2b304..cd6a6a990 100644 --- a/src/CryptoNoteWrapper.cpp +++ b/src/CryptoNoteWrapper.cpp @@ -20,8 +20,10 @@ #include "CryptoNoteCore/Miner.h" #include "CryptoNoteCore/MinerConfig.h" #include "CryptoNoteCore/TransactionExtra.h" +#include "HTTP/httplib.h" #include "Rpc/CoreRpcServerCommandsDefinitions.h" -#include "Rpc/HttpClient.h" +#include "Rpc/RpcServer.h" +#include "Rpc/JsonRpc.h" #include "CryptoNoteProtocol/CryptoNoteProtocolHandler.h" #include "InProcessNode/InProcessNode.h" #include "P2p/NetNode.h" @@ -214,8 +216,8 @@ class RpcNode : public CryptoNote::INodeObserver, public CryptoNote::INodeRpcPro CryptoNote::COMMAND_RPC_GETBLOCKTEMPLATE::response rsp = AUTO_VAL_INIT(rsp); req.miner_spend_key = Common::podToHex(acc.spendSecretKey); req.miner_view_key = Common::podToHex(acc.viewSecretKey); - CryptoNote::HttpClient httpClient(m_dispatcher, m_node.m_nodeHost, m_node.m_nodePort, false); - CryptoNote::invokeJsonRpcCommand(httpClient, "getblocktemplate", req, rsp); + httplib::Client httpClient (m_node.m_nodeHost, m_node.m_nodePort); + CryptoNote::JsonRpc::invokeJsonRpcCommand(httpClient, "getblocktemplate", req, rsp); std::string err = interpret_rpc_response(true, rsp.status); if (err.empty()) { if (!CryptoNote::fromBinaryArray(b, Common::fromHex(rsp.blocktemplate_blob))) { @@ -231,10 +233,6 @@ class RpcNode : public CryptoNote::INodeObserver, public CryptoNote::INodeRpcPro m_logger(Logging::INFO) << "Failed to invoke request: " << err; } } - catch (const CryptoNote::ConnectException&) { - m_logger(Logging::INFO) << "Wallet failed to connect to daemon."; - return false; - } catch (const std::exception& e) { m_logger(Logging::INFO) << "Failed to invoke RPC method: " << e.what(); return false; @@ -248,8 +246,8 @@ class RpcNode : public CryptoNote::INodeObserver, public CryptoNote::INodeRpcPro CryptoNote::COMMAND_RPC_SUBMITBLOCK::request req; req.emplace_back(Common::toHex(CryptoNote::toBinaryArray(b))); CryptoNote::COMMAND_RPC_SUBMITBLOCK::response res; - CryptoNote::HttpClient httpClient(m_dispatcher, m_node.m_nodeHost, m_node.m_nodePort, false); - CryptoNote::invokeJsonRpcCommand(httpClient, "submitblock", req, res); + httplib::Client httpClient(m_node.m_nodeHost, m_node.m_nodePort); + CryptoNote::JsonRpc::invokeJsonRpcCommand(httpClient, "submitblock", req, res); std::string err = interpret_rpc_response(true, res.status); if (err.empty()) { return true; @@ -258,10 +256,6 @@ class RpcNode : public CryptoNote::INodeObserver, public CryptoNote::INodeRpcPro m_logger(Logging::INFO) << "Failed to invoke request: " << err; } } - catch (const CryptoNote::ConnectException&) { - m_logger(Logging::INFO) << "Wallet failed to connect to daemon."; - return false; - } catch (const std::exception& e) { m_logger(Logging::INFO) << "Failed to invoke RPC method: " << e.what(); return false; @@ -337,15 +331,16 @@ class InprocessNode : public CryptoNote::INodeObserver, public Node { public: Logging::LoggerManager& m_logManager; InprocessNode(const CryptoNote::Currency& currency, Logging::LoggerManager& logManager, const CryptoNote::CoreConfig& coreConfig, - const CryptoNote::NetNodeConfig& netNodeConfig, INodeCallback& callback) : + const CryptoNote::NetNodeConfig& netNodeConfig, const CryptoNote::RpcServerConfig& rpcServerConfig, INodeCallback& callback) : m_currency(currency), m_dispatcher(), m_callback(callback), m_logManager(logManager), m_logger(m_logManager, "InprocessNode"), m_coreConfig(coreConfig), m_netNodeConfig(netNodeConfig), + m_rpcServerConfig(rpcServerConfig), m_protocolHandler(currency, m_dispatcher, m_core, nullptr, logManager), - m_core(currency, &m_protocolHandler, logManager, m_dispatcher, true), + m_core(currency, &m_protocolHandler, logManager, m_dispatcher, true, false, false), m_nodeServer(m_dispatcher, m_protocolHandler, logManager), m_node(m_core, m_protocolHandler) { @@ -393,6 +388,14 @@ class InprocessNode : public CryptoNote::INodeObserver, public Node { callback(make_error_code(CryptoNote::error::NOT_INITIALIZED)); return; } + + if (Settings::instance().hasRunRpc()) { + m_logger(Logging::INFO) << "Starting core rpc server..."; + m_rpcServer = new CryptoNote::RpcServer(m_rpcServerConfig, m_dispatcher, m_logManager, m_core, m_nodeServer, m_protocolHandler); + m_rpcServer->start(); + m_logger(Logging::INFO) << "Core rpc server started ok"; + } + } catch (std::runtime_error& _err) { callback(make_error_code(CryptoNote::error::NOT_INITIALIZED)); return; @@ -405,6 +408,7 @@ class InprocessNode : public CryptoNote::INodeObserver, public Node { m_nodeServer.run(); m_nodeServer.deinit(); + m_rpcServer->stop(); m_core.deinit(); m_node.shutdown(); } @@ -548,12 +552,14 @@ class InprocessNode : public CryptoNote::INodeObserver, public Node { System::Dispatcher m_dispatcher; CryptoNote::CoreConfig m_coreConfig; CryptoNote::NetNodeConfig m_netNodeConfig; + CryptoNote::RpcServerConfig m_rpcServerConfig; CryptoNote::Core m_core; CryptoNote::CryptoNoteProtocolHandler m_protocolHandler; CryptoNote::NodeServer m_nodeServer; CryptoNote::InProcessNode m_node; std::future m_nodeServerFuture; Logging::LoggerRef m_logger; + CryptoNote::RpcServer* m_rpcServer; void peerCountUpdated(size_t count) override { m_callback.peerCountUpdated(*this, count); @@ -578,8 +584,8 @@ Node* createRpcNode(const CryptoNote::Currency& currency, INodeCallback& callbac } Node* createInprocessNode(const CryptoNote::Currency& currency, Logging::LoggerManager& logManager, - const CryptoNote::CoreConfig& coreConfig, const CryptoNote::NetNodeConfig& netNodeConfig, INodeCallback& callback) { - return new InprocessNode(currency, logManager, coreConfig, netNodeConfig, callback); + const CryptoNote::CoreConfig& coreConfig, const CryptoNote::NetNodeConfig& netNodeConfig, const CryptoNote::RpcServerConfig& rpcServerConfig, INodeCallback& callback) { + return new InprocessNode(currency, logManager, coreConfig, netNodeConfig, rpcServerConfig, callback); } } diff --git a/src/CryptoNoteWrapper.h b/src/CryptoNoteWrapper.h index be37516c2..af3a734ce 100644 --- a/src/CryptoNoteWrapper.h +++ b/src/CryptoNoteWrapper.h @@ -11,6 +11,7 @@ #include #include #include +#include namespace CryptoNote { @@ -19,6 +20,7 @@ class IWalletLegacy; class Currency; class CoreConfig; class NetNodeConfig; +class RpcServerConfig; } @@ -80,6 +82,6 @@ class INodeCallback { Node* createRpcNode(const CryptoNote::Currency& currency, INodeCallback& callback, Logging::LoggerManager& logManager, const std::string& nodeHost, unsigned short nodePort, bool enableSSL); Node* createInprocessNode(const CryptoNote::Currency& currency, Logging::LoggerManager& logManager, - const CryptoNote::CoreConfig& coreConfig, const CryptoNote::NetNodeConfig& netNodeConfig, INodeCallback& callback); + const CryptoNote::CoreConfig& coreConfig, const CryptoNote::NetNodeConfig& netNodeConfig, const CryptoNote::RpcServerConfig& rpcServerConfig, INodeCallback& callback); } diff --git a/src/NodeAdapter.cpp b/src/NodeAdapter.cpp index 37bbc3ac7..2036a3613 100644 --- a/src/NodeAdapter.cpp +++ b/src/NodeAdapter.cpp @@ -9,15 +9,17 @@ #include #include -#include -#include -#include +#include +#include +#include "CryptoNoteCore/CoreConfig.h" #include "CurrencyAdapter.h" #include "LoggerAdapter.h" #include "NodeAdapter.h" +#include "P2p/NetNodeConfig.h" +#include "Rpc/RpcServerConfig.h" #include "Settings.h" -#include +#include "Wallet/WalletErrors.h" namespace WalletGui { @@ -51,8 +53,8 @@ class InProcessNodeInitializer : public QObject { } void start(Node** _node, const CryptoNote::Currency* currency, INodeCallback* _callback, Logging::LoggerManager* _loggerManager, - const CryptoNote::CoreConfig& _coreConfig, const CryptoNote::NetNodeConfig& _netNodeConfig) { - (*_node) = createInprocessNode(*currency, *_loggerManager, _coreConfig, _netNodeConfig, *_callback); + const CryptoNote::CoreConfig& _coreConfig, const CryptoNote::NetNodeConfig& _netNodeConfig, const CryptoNote::RpcServerConfig& _rpcServerConfig) { + (*_node) = createInprocessNode(*currency, *_loggerManager, _coreConfig, _netNodeConfig, _rpcServerConfig, *_callback); try { (*_node)->init([this](std::error_code _err) { if (_err) { @@ -91,6 +93,7 @@ NodeAdapter::NodeAdapter() : QObject(), m_node(nullptr), m_nodeInitializerThread qRegisterMetaType("CryptoNote::CoreConfig"); qRegisterMetaType("CryptoNote::NetNodeConfig"); + qRegisterMetaType("CryptoNote::RpcServerConfig"); connect(m_nodeInitializer, &InProcessNodeInitializer::nodeInitCompletedSignal, this, &NodeAdapter::nodeInitCompletedSignal, Qt::QueuedConnection); connect(this, &NodeAdapter::initNodeSignal, m_nodeInitializer, &InProcessNodeInitializer::start, Qt::QueuedConnection); @@ -354,7 +357,8 @@ bool NodeAdapter::initInProcessNode() { m_nodeInitializerThread.start(); CryptoNote::CoreConfig coreConfig = makeCoreConfig(); CryptoNote::NetNodeConfig netNodeConfig = makeNetNodeConfig(); - Q_EMIT initNodeSignal(&m_node, &CurrencyAdapter::instance().getCurrency(), this, &LoggerAdapter::instance().getLoggerManager(), coreConfig, netNodeConfig); + CryptoNote::RpcServerConfig rpcServerConfig = makeRpcServerConfig(); + Q_EMIT initNodeSignal(&m_node, &CurrencyAdapter::instance().getCurrency(), this, &LoggerAdapter::instance().getLoggerManager(), coreConfig, netNodeConfig, rpcServerConfig); QEventLoop waitLoop; connect(m_nodeInitializer, &InProcessNodeInitializer::nodeInitCompletedSignal, &waitLoop, &QEventLoop::quit); connect(m_nodeInitializer, &InProcessNodeInitializer::nodeInitFailedSignal, &waitLoop, &QEventLoop::exit); @@ -441,6 +445,39 @@ CryptoNote::NetNodeConfig NodeAdapter::makeNetNodeConfig() const { return config; } +CryptoNote::RpcServerConfig NodeAdapter::makeRpcServerConfig() const { + CryptoNote::RpcServerConfig config; + boost::filesystem::path dataDir = std::string(Settings::instance().getDataDir().absolutePath().toLocal8Bit().data()); + config.setDataDir(dataDir.string()); + boost::program_options::variables_map options; + boost::any rpcBindIp = Settings::instance().getRpcBindIp().toStdString(); + boost::any rpcBindPort = static_cast(Settings::instance().getRpcBindPort()); + + options.insert(std::make_pair("rpc-bind-ip", boost::program_options::variable_value(rpcBindIp, false))); + options.insert(std::make_pair("rpc-bind-port", boost::program_options::variable_value(rpcBindPort, false))); + + // dummy defaults + std::string dummy = "", cors = "*"; + uint16_t sslport = CryptoNote::RPC_DEFAULT_SSL_PORT; + bool no = false; + options.insert(std::make_pair("rpc-bind-ssl-port", boost::program_options::variable_value(sslport, false))); + options.insert(std::make_pair("rpc-bind-ssl-enable", boost::program_options::variable_value(no, false))); + options.insert(std::make_pair("rpc-chain-file", boost::program_options::variable_value(dummy, false))); + options.insert(std::make_pair("rpc-key-file", boost::program_options::variable_value(dummy, false))); + options.insert(std::make_pair("rpc-bind-ssl-enable", boost::program_options::variable_value(dummy, false))); + options.insert(std::make_pair("enable-cors", boost::program_options::variable_value(cors, false))); + options.insert(std::make_pair("contact", boost::program_options::variable_value(dummy, false))); + options.insert(std::make_pair("fee-address", boost::program_options::variable_value(dummy, false))); + options.insert(std::make_pair("fee-amount", boost::program_options::variable_value(dummy, false))); + options.insert(std::make_pair("view-key", boost::program_options::variable_value(dummy, false))); + + options.insert(std::make_pair("restricted-rpc", boost::program_options::variable_value(Settings::instance().hasRestrictedRpc(), false))); + + config.init(options); + + return config; +} + bool NodeAdapter::isOffline() { return getConnectionsCount() == 0; } diff --git a/src/NodeAdapter.h b/src/NodeAdapter.h index ec171c2db..7a50ed9fe 100644 --- a/src/NodeAdapter.h +++ b/src/NodeAdapter.h @@ -11,6 +11,7 @@ #include #include #include "CryptoNoteWrapper.h" +#include "Rpc/RpcServerConfig.h" namespace CryptoNote { @@ -82,15 +83,16 @@ class NodeAdapter : public QObject, public INodeCallback { bool initInProcessNode(); CryptoNote::CoreConfig makeCoreConfig() const; CryptoNote::NetNodeConfig makeNetNodeConfig() const; + CryptoNote::RpcServerConfig makeRpcServerConfig() const; Q_SIGNALS: void localBlockchainUpdatedSignal(quint64 _height); void lastKnownBlockHeightUpdatedSignal(quint64 _height); void nodeInitCompletedSignal(); void peerCountUpdatedSignal(quintptr _count); - void initNodeSignal(Node** _node, const CryptoNote::Currency* currency, INodeCallback* _callback, Logging::LoggerManager* _loggerManager, - const CryptoNote::CoreConfig& _coreConfig, const CryptoNote::NetNodeConfig& _netNodeConfig); - void deinitNodeSignal(Node** _node); + void initNodeSignal(WalletGui::Node** _node, const CryptoNote::Currency* currency, INodeCallback* _callback, Logging::LoggerManager* _loggerManager, + const CryptoNote::CoreConfig& _coreConfig, const CryptoNote::NetNodeConfig& _netNodeConfig, const CryptoNote::RpcServerConfig& _rpcServerConfig); + void deinitNodeSignal(WalletGui::Node** _node); void connectionFailedSignal(); void connectionStatusUpdatedSignal(bool _connected); }; diff --git a/src/Settings.cpp b/src/Settings.cpp index 4db701b8b..94620b520 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -137,6 +137,26 @@ quint16 Settings::getP2pBindPort() const { return m_cmdLineParser->getP2pBindPort(); } +QString Settings::getRpcBindIp() const { + Q_ASSERT(m_cmdLineParser != nullptr); + return m_cmdLineParser->getRpcBindIp(); +} + +quint16 Settings::getRpcBindPort() const { + Q_ASSERT(m_cmdLineParser != nullptr); + return m_cmdLineParser->getRpcBindPort(); +} + +bool Settings::hasRunRpc() const { + Q_ASSERT(m_cmdLineParser != nullptr); + return m_cmdLineParser->hasRpcOption(); +} + +bool Settings::hasRestrictedRpc() const { + Q_ASSERT(m_cmdLineParser != nullptr); + return m_cmdLineParser->hasRestrictedRpcOption(); +} + quint16 Settings::getP2pExternalPort() const { Q_ASSERT(m_cmdLineParser != nullptr); return m_cmdLineParser->getP2pExternalPort(); diff --git a/src/Settings.h b/src/Settings.h index d72ffba2c..4fd744b94 100644 --- a/src/Settings.h +++ b/src/Settings.h @@ -38,11 +38,14 @@ class Settings : public QObject { bool isTestnet() const; bool withoutCheckpoints() const; bool alowReorg() const; + bool hasRunRpc() const; + bool hasRestrictedRpc() const; QDir getDataDir() const; QString getP2pBindIp() const; - quint16 getLocalRpcPort() const; quint16 getP2pBindPort() const; quint16 getP2pExternalPort() const; + QString getRpcBindIp() const; + quint16 getRpcBindPort() const; quint16 getConnectionsCount() const; QStringList getExclusiveNodes() const; QStringList getPeers() const;