diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index ae3f9aa686d..222d42f27d9 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -16,7 +16,9 @@ #include #include #include +#ifdef ENABLE_WALLET #include +#endif // ENABLE_WALLET #include #include #include @@ -90,7 +92,11 @@ class RPCExecutor : public QObject explicit RPCExecutor(interfaces::Node& node) : m_node(node) {} public Q_SLOTS: +#ifdef ENABLE_WALLET void request(const QString &command, const WalletModel* wallet_model); +#else + void request(const QString &command); +#endif // ENABLE_WALLET Q_SIGNALS: void reply(int category, const QString &command); @@ -167,7 +173,11 @@ class PeerIdViewDelegate : public QStyledItemDelegate * @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data */ +#ifdef ENABLE_WALLET bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut, const WalletModel* wallet_model) +#else +bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute, std::string * const pstrFilteredOut) +#endif // ENABLE_WALLET { std::vector< std::vector > stack; stack.emplace_back(); @@ -409,7 +419,11 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes } } +#ifdef ENABLE_WALLET void RPCExecutor::request(const QString &command, const WalletModel* wallet_model) +#else +void RPCExecutor::request(const QString &command) +#endif // ENABLE_WALLET { try { @@ -439,7 +453,11 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode " example: getblock(getblockhash(0),1)[tx][0]\n\n"))); return; } +#ifdef ENABLE_WALLET if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, wallet_model)) { +#else + if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr)) { +#endif // ENABLE_WALLET Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \"")); return; } @@ -1058,8 +1076,8 @@ void RPCConsole::on_lineEdit_returnPressed() ui->lineEdit->clear(); - WalletModel* wallet_model{nullptr}; #ifdef ENABLE_WALLET + WalletModel* wallet_model{nullptr}; wallet_model = ui->WalletSelector->currentData().value(); if (m_last_wallet_model != wallet_model) { @@ -1077,9 +1095,15 @@ void RPCConsole::on_lineEdit_returnPressed() message(CMD_REPLY, tr("Executing…")); m_is_executing = true; +#ifdef ENABLE_WALLET QMetaObject::invokeMethod(m_executor, [this, cmd, wallet_model] { m_executor->request(cmd, wallet_model); }); +#else + QMetaObject::invokeMethod(m_executor, [this, cmd] { + m_executor->request(cmd); + }); +#endif // ENABLE_WALLET cmd = QString::fromStdString(strFilteredCmd); diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index 4747e611d00..f330081a264 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -21,7 +21,9 @@ class PlatformStyle; class RPCExecutor; class RPCTimerInterface; +#ifdef ENABLE_WALLET class WalletModel; +#endif // ENABLE_WALLET namespace interfaces { class Node; @@ -46,10 +48,17 @@ class RPCConsole: public QWidget explicit RPCConsole(interfaces::Node& node, const PlatformStyle *platformStyle, QWidget *parent); ~RPCConsole(); +#ifdef ENABLE_WALLET static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr, const WalletModel* wallet_model = nullptr); static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr, const WalletModel* wallet_model = nullptr) { return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut, wallet_model); } +#else + static bool RPCParseCommandLine(interfaces::Node* node, std::string &strResult, const std::string &strCommand, bool fExecute, std::string * const pstrFilteredOut = nullptr); + static bool RPCExecuteCommandLine(interfaces::Node& node, std::string &strResult, const std::string &strCommand, std::string * const pstrFilteredOut = nullptr) { + return RPCParseCommandLine(&node, strResult, strCommand, true, pstrFilteredOut); + } +#endif // ENABLE_WALLET void setClientModel(ClientModel *model = nullptr, int bestblock_height = 0, int64_t bestblock_date = 0, double verification_progress = 0.0); @@ -173,7 +182,9 @@ public Q_SLOTS: QCompleter *autoCompleter = nullptr; QThread thread; RPCExecutor* m_executor{nullptr}; +#ifdef ENABLE_WALLET WalletModel* m_last_wallet_model{nullptr}; +#endif // ENABLE_WALLET bool m_is_executing{false}; QByteArray m_peer_widget_header_state; QByteArray m_banlist_widget_header_state;