Skip to content

Commit 4049459

Browse files
committed
qt: prevent recall of send commands from history
1 parent 7cf90fe commit 4049459

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/qt/rpcconsole.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,14 @@ const QStringList historyFilter = QStringList()
8383

8484
}
8585

86+
// List of commands that may cause unintended effects if accidentally re-executed from history
87+
const QStringList sensitiveFilter = QStringList()
88+
<< "send"
89+
<< "sendall"
90+
<< "sendmany"
91+
<< "sendtoaddress"
92+
;
93+
8694
/* Object for executing console RPC commands in a separate thread.
8795
*/
8896
class RPCExecutor : public QObject
@@ -364,6 +372,16 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
364372

365373
bool is_sensitive = !filter_ranges.empty();
366374

375+
if (!is_sensitive) {
376+
const QString strcmd = QString::fromStdString(*pstrFilteredOut);
377+
for (const QString& val : sensitiveFilter) {
378+
if (strcmd.contains(val, Qt::CaseInsensitive)) {
379+
is_sensitive = true;
380+
break;
381+
}
382+
}
383+
}
384+
367385
// Prefix "!" to mark sensitive commands as non-executable when recalled from history
368386
if (is_sensitive) {
369387
pstrFilteredOut->insert(0, 1, '!');

0 commit comments

Comments
 (0)