@@ -361,6 +361,13 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes
361361 for (auto i = filter_ranges.rbegin (); i != filter_ranges.rend (); ++i) {
362362 pstrFilteredOut->replace (i->first , i->second - i->first , " (…)" );
363363 }
364+
365+ bool is_sensitive = !filter_ranges.empty ();
366+
367+ // Prefix "!" to mark sensitive commands as non-executable when recalled from history
368+ if (is_sensitive) {
369+ pstrFilteredOut->insert (0 , 1 , ' !' );
370+ }
364371 }
365372 switch (state) // final state
366373 {
@@ -405,7 +412,11 @@ void RPCExecutor::request(const QString &command, const QString& wallet_name)
405412 " example: getblock(getblockhash(0) 1)[tx]\n\n "
406413
407414 " Results without keys can be queried with an integer in brackets using the parenthesized syntax.\n "
408- " example: getblock(getblockhash(0),1)[tx][0]\n\n " )));
415+ " example: getblock(getblockhash(0),1)[tx][0]\n\n "
416+
417+ " Commands starting with a leading '!' are blocked from execution.\n "
418+ " These entries are shown for reference only. Remove the '!' or retype to run them.\n "
419+ " example: !walletpassphrase(...)\n\n " )));
409420 return ;
410421 }
411422 if (!RPCConsole::RPCExecuteCommandLine (m_node, result, executableCommand, nullptr , wallet_name)) {
@@ -994,6 +1005,16 @@ void RPCConsole::on_lineEdit_returnPressed()
9941005 return ;
9951006 }
9961007
1008+ // Prevent parsing and execution of commands prefixed with '!'
1009+ if (cmd.startsWith (' !' )) {
1010+ QMessageBox::information (this , tr (" Command not executed" ), tr (
1011+ " Commands prefixed with '!' are blocked.\n "
1012+ " Remove the '!' or retype to run again."
1013+
1014+ ));
1015+ return ;
1016+ }
1017+
9971018 std::string strFilteredCmd;
9981019 try {
9991020 std::string dummy;
0 commit comments