@@ -92,7 +92,7 @@ class RPCExecutor : public QObject
9292 explicit RPCExecutor (interfaces::Node& node) : m_node(node) {}
9393
9494public Q_SLOTS:
95- void request (const QString &command, const WalletModel* wallet_model );
95+ void request (const QString &command, const QString& wallet_name );
9696
9797Q_SIGNALS:
9898 void reply (int category, const QString &command);
@@ -169,7 +169,7 @@ class PeerIdViewDelegate : public QStyledItemDelegate
169169 * @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
170170 */
171171
172- bool RPCConsole::RPCParseCommandLine (interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute , std::string * const pstrFilteredOut, const WalletModel* wallet_model )
172+ bool RPCConsole::RPCParseCommandLine (interfaces::Node* node, std::string &strResult, const std::string &strCommand, const bool fExecute , std::string * const pstrFilteredOut, const QString& wallet_name )
173173{
174174 std::vector< std::vector<std::string> > stack;
175175 stack.emplace_back ();
@@ -328,12 +328,10 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
328328 UniValue params = RPCConvertValues (stack.back ()[0 ], std::vector<std::string>(stack.back ().begin () + 1 , stack.back ().end ()));
329329 std::string method = stack.back ()[0 ];
330330 std::string uri;
331- #ifdef ENABLE_WALLET
332- if (wallet_model) {
333- QByteArray encodedName = QUrl::toPercentEncoding (wallet_model->getWalletName ());
331+ if (!wallet_name.isEmpty ()) {
332+ QByteArray encodedName = QUrl::toPercentEncoding (wallet_name);
334333 uri = " /wallet/" +std::string (encodedName.constData (), encodedName.length ());
335334 }
336- #endif
337335 assert (node);
338336 lastResult = node->executeRpc (method, params, uri);
339337 }
@@ -411,7 +409,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
411409 }
412410}
413411
414- void RPCExecutor::request (const QString &command, const WalletModel* wallet_model )
412+ void RPCExecutor::request (const QString &command, const QString& wallet_name )
415413{
416414 try
417415 {
@@ -441,7 +439,7 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode
441439 " example: getblock(getblockhash(0),1)[tx][0]\n\n " )));
442440 return ;
443441 }
444- if (!RPCConsole::RPCExecuteCommandLine (m_node, result, executableCommand, nullptr , wallet_model )) {
442+ if (!RPCConsole::RPCExecuteCommandLine (m_node, result, executableCommand, nullptr , wallet_name )) {
445443 Q_EMIT reply (RPCConsole::CMD_ERROR, QString (" Parse error: unbalanced ' or \" " ));
446444 return ;
447445 }
@@ -1060,10 +1058,10 @@ void RPCConsole::on_lineEdit_returnPressed()
10601058
10611059 ui->lineEdit ->clear ();
10621060
1063- WalletModel* wallet_model{ nullptr } ;
1061+ QString in_use_wallet_name ;
10641062#ifdef ENABLE_WALLET
1065- wallet_model = ui->WalletSelector ->currentData ().value <WalletModel*>();
1066-
1063+ WalletModel* wallet_model = ui->WalletSelector ->currentData ().value <WalletModel*>();
1064+ in_use_wallet_name = wallet_model ? wallet_model-> getWalletName () : QString ();
10671065 if (m_last_wallet_model != wallet_model) {
10681066 if (wallet_model) {
10691067 message (CMD_REQUEST, tr (" Executing command using \" %1\" wallet" ).arg (wallet_model->getWalletName ()));
@@ -1079,8 +1077,8 @@ void RPCConsole::on_lineEdit_returnPressed()
10791077 message (CMD_REPLY, tr (" Executing…" ));
10801078 m_is_executing = true ;
10811079
1082- QMetaObject::invokeMethod (m_executor, [this , cmd, wallet_model ] {
1083- m_executor->request (cmd, wallet_model );
1080+ QMetaObject::invokeMethod (m_executor, [this , cmd, &in_use_wallet_name ] {
1081+ m_executor->request (cmd, in_use_wallet_name );
10841082 });
10851083
10861084 cmd = QString::fromStdString (strFilteredCmd);
0 commit comments