aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2016-10-04 04:17:27 +0000
committerLuke Dashjr <luke-jr+git@utopios.org>2016-12-29 11:43:29 +0000
commitafde12f265bbc4742b329c6adecc853cb68a7155 (patch)
tree8af667745e8c8d747cc10a7e9230d2b66aa84311 /src
parentde8980df9d3a1fc0b257139cef10a0e6ba29a8bd (diff)
Qt/RPCConsole: Refactor command_may_contain_sensitive_data function out of RPCConsole::on_lineEdit_returnPressed
Diffstat (limited to 'src')
-rw-r--r--src/qt/rpcconsole.cpp26
-rw-r--r--src/qt/rpcconsole.h1
2 files changed, 16 insertions, 11 deletions
diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp
index 8aa3d10eb5..23a4a25078 100644
--- a/src/qt/rpcconsole.cpp
+++ b/src/qt/rpcconsole.cpp
@@ -63,14 +63,28 @@ const struct {
{NULL, NULL}
};
+namespace {
+
// don't add private key handling cmd's to the history
-const QStringList RPCConsole::historyFilter = QStringList()
+const QStringList historyFilter = QStringList()
<< "importprivkey"
<< "signrawtransaction"
<< "walletpassphrase"
<< "walletpassphrasechange"
<< "encryptwallet";
+bool command_may_contain_sensitive_data(const QString cmd)
+{
+ Q_FOREACH(QString unallowedCmd, historyFilter) {
+ if (cmd.trimmed().startsWith(unallowedCmd)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+}
+
/* Object for executing console RPC commands in a separate thread.
*/
class RPCExecutor : public QObject
@@ -764,15 +778,7 @@ void RPCConsole::on_lineEdit_returnPressed()
message(CMD_REQUEST, cmd);
Q_EMIT cmdRequest(cmd);
- bool storeHistory = true;
- Q_FOREACH(QString unallowedCmd, historyFilter)
- {
- if (cmd.trimmed().startsWith(unallowedCmd))
- {
- storeHistory = false;
- break;
- }
- }
+ bool storeHistory = !command_may_contain_sensitive_data(cmd);
if (storeHistory)
{
diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h
index 4841ea825e..e1698711da 100644
--- a/src/qt/rpcconsole.h
+++ b/src/qt/rpcconsole.h
@@ -140,7 +140,6 @@ private:
ClientModel *clientModel;
QStringList history;
int historyPtr;
- const static QStringList historyFilter;
QString cmdBeforeBrowsing;
QList<NodeId> cachedNodeids;
const PlatformStyle *platformStyle;