Skip to content

Commit afde12f

Browse files
committed
Qt/RPCConsole: Refactor command_may_contain_sensitive_data function out of RPCConsole::on_lineEdit_returnPressed
1 parent de8980d commit afde12f

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/qt/rpcconsole.cpp

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,28 @@ const struct {
6363
{NULL, NULL}
6464
};
6565

66+
namespace {
67+
6668
// don't add private key handling cmd's to the history
67-
const QStringList RPCConsole::historyFilter = QStringList()
69+
const QStringList historyFilter = QStringList()
6870
<< "importprivkey"
6971
<< "signrawtransaction"
7072
<< "walletpassphrase"
7173
<< "walletpassphrasechange"
7274
<< "encryptwallet";
7375

76+
bool command_may_contain_sensitive_data(const QString cmd)
77+
{
78+
Q_FOREACH(QString unallowedCmd, historyFilter) {
79+
if (cmd.trimmed().startsWith(unallowedCmd)) {
80+
return true;
81+
}
82+
}
83+
return false;
84+
}
85+
86+
}
87+
7488
/* Object for executing console RPC commands in a separate thread.
7589
*/
7690
class RPCExecutor : public QObject
@@ -764,15 +778,7 @@ void RPCConsole::on_lineEdit_returnPressed()
764778
message(CMD_REQUEST, cmd);
765779
Q_EMIT cmdRequest(cmd);
766780

767-
bool storeHistory = true;
768-
Q_FOREACH(QString unallowedCmd, historyFilter)
769-
{
770-
if (cmd.trimmed().startsWith(unallowedCmd))
771-
{
772-
storeHistory = false;
773-
break;
774-
}
775-
}
781+
bool storeHistory = !command_may_contain_sensitive_data(cmd);
776782

777783
if (storeHistory)
778784
{

src/qt/rpcconsole.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,6 @@ public Q_SLOTS:
140140
ClientModel *clientModel;
141141
QStringList history;
142142
int historyPtr;
143-
const static QStringList historyFilter;
144143
QString cmdBeforeBrowsing;
145144
QList<NodeId> cachedNodeids;
146145
const PlatformStyle *platformStyle;

0 commit comments

Comments
 (0)