@@ -92,7 +92,7 @@ class RPCExecutor : public QObject
92
92
explicit RPCExecutor (interfaces::Node& node) : m_node(node) {}
93
93
94
94
public Q_SLOTS:
95
- void request (const QString &command, const WalletModel* wallet_model );
95
+ void request (const QString &command, const QString& wallet_name );
96
96
97
97
Q_SIGNALS:
98
98
void reply (int category, const QString &command);
@@ -169,7 +169,7 @@ class PeerIdViewDelegate : public QStyledItemDelegate
169
169
* @param[out] pstrFilteredOut Command line, filtered to remove any sensitive data
170
170
*/
171
171
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 )
173
173
{
174
174
std::vector< std::vector<std::string> > stack;
175
175
stack.emplace_back ();
@@ -328,12 +328,10 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
328
328
UniValue params = RPCConvertValues (stack.back ()[0 ], std::vector<std::string>(stack.back ().begin () + 1 , stack.back ().end ()));
329
329
std::string method = stack.back ()[0 ];
330
330
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);
334
333
uri = " /wallet/" +std::string (encodedName.constData (), encodedName.length ());
335
334
}
336
- #endif
337
335
assert (node);
338
336
lastResult = node->executeRpc (method, params, uri);
339
337
}
@@ -411,7 +409,7 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
411
409
}
412
410
}
413
411
414
- void RPCExecutor::request (const QString &command, const WalletModel* wallet_model )
412
+ void RPCExecutor::request (const QString &command, const QString& wallet_name )
415
413
{
416
414
try
417
415
{
@@ -441,7 +439,7 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode
441
439
" example: getblock(getblockhash(0),1)[tx][0]\n\n " )));
442
440
return ;
443
441
}
444
- if (!RPCConsole::RPCExecuteCommandLine (m_node, result, executableCommand, nullptr , wallet_model )) {
442
+ if (!RPCConsole::RPCExecuteCommandLine (m_node, result, executableCommand, nullptr , wallet_name )) {
445
443
Q_EMIT reply (RPCConsole::CMD_ERROR, QString (" Parse error: unbalanced ' or \" " ));
446
444
return ;
447
445
}
@@ -1060,10 +1058,10 @@ void RPCConsole::on_lineEdit_returnPressed()
1060
1058
1061
1059
ui->lineEdit ->clear ();
1062
1060
1063
- WalletModel* wallet_model{ nullptr } ;
1061
+ QString in_use_wallet_name ;
1064
1062
#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 ();
1067
1065
if (m_last_wallet_model != wallet_model) {
1068
1066
if (wallet_model) {
1069
1067
message (CMD_REQUEST, tr (" Executing command using \" %1\" wallet" ).arg (wallet_model->getWalletName ()));
@@ -1079,8 +1077,8 @@ void RPCConsole::on_lineEdit_returnPressed()
1079
1077
message (CMD_REPLY, tr (" Executing…" ));
1080
1078
m_is_executing = true ;
1081
1079
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 );
1084
1082
});
1085
1083
1086
1084
cmd = QString::fromStdString (strFilteredCmd);
0 commit comments