Skip to content

Commit c3055bb

Browse files
committed
Add help-console command to Qt debug console
- Added `help-console` to the list of autocompletion strings - Implemented requested changes to help message: - Added an example that uses access-by-index `getblock(getblockhash(0) true)[tx][0]` - Replace "bracketed syntax" to "parenthesized syntax" where applicable - Replace "separate" with "delimit" - Removed `<br>` and `<b>help/help-console</b>` from translation strings, since these parts don't change between languages - Changed examples to be based off `getblock 0` so they will work even with pruned/no blockchain and `disablewallet` if copied and pasted - Clarified syntax for queries of named/unnamed result objects.
1 parent f0c1f8a commit c3055bb

File tree

1 file changed

+31
-3
lines changed

1 file changed

+31
-3
lines changed

src/qt/rpcconsole.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,37 @@ void RPCExecutor::request(const QString &command)
392392
{
393393
std::string result;
394394
std::string executableCommand = command.toStdString() + "\n";
395+
396+
// Catch the console-only-help command before RPC call is executed and reply with help text as-if a RPC reply.
397+
if(executableCommand == "help-console\n")
398+
{
399+
Q_EMIT reply(RPCConsole::CMD_REPLY, QString(("\n"
400+
"This console accepts RPC commands using the standard syntax.\n"
401+
" example: getblockhash 0\n\n"
402+
403+
"This console can also accept RPC commands using parenthesized syntax.\n"
404+
" example: getblockhash(0)\n\n"
405+
406+
"Commands may be nested when specified with the parenthesized syntax.\n"
407+
" example: getblock(getblockhash(0) 1)\n\n"
408+
409+
"A space or a comma can be used to delimit arguments for either syntax.\n"
410+
" example: getblockhash 0\n"
411+
" getblockhash,0\n\n"
412+
413+
"Named results can be queried with a non-quoted key string in brackets.\n"
414+
" example: getblock(getblockhash(0) true)[tx]\n\n"
415+
416+
"Results without keys can be queried using an integer in brackets.\n"
417+
" example: getblock(getblockhash(0),true)[tx][0]\n\n")));
418+
return;
419+
}
395420
if(!RPCConsole::RPCExecuteCommandLine(result, executableCommand))
396421
{
397422
Q_EMIT reply(RPCConsole::CMD_ERROR, QString("Parse error: unbalanced ' or \""));
398423
return;
399424
}
425+
400426
Q_EMIT reply(RPCConsole::CMD_REPLY, QString::fromStdString(result));
401427
}
402428
catch (UniValue& objError)
@@ -645,6 +671,7 @@ void RPCConsole::setClientModel(ClientModel *model)
645671
wordList << ("help " + commandList[i]).c_str();
646672
}
647673

674+
wordList << "help-console";
648675
wordList.sort();
649676
autoCompleter = new QCompleter(wordList, this);
650677
autoCompleter->setModelSorting(QCompleter::CaseSensitivelySortedModel);
@@ -750,10 +777,11 @@ void RPCConsole::clear(bool clearHistory)
750777

751778
message(CMD_REPLY, (tr("Welcome to the %1 RPC console.").arg(tr(PACKAGE_NAME)) + "<br>" +
752779
tr("Use up and down arrows to navigate history, and %1 to clear screen.").arg("<b>"+clsKey+"</b>") + "<br>" +
753-
tr("Type <b>help</b> for an overview of available commands.")) +
754-
"<br><span class=\"secwarning\">" +
780+
tr("Type %1 for an overview of available commands.").arg("<b>help</b>") + "<br>" +
781+
tr("For more information on using this console type %1.").arg("<b>help-console</b>") +
782+
"<br><span class=\"secwarning\"><br>" +
755783
tr("WARNING: Scammers have been active, telling users to type commands here, stealing their wallet contents. Do not use this console without fully understanding the ramifications of a command.") +
756-
"</span>",
784+
"</span>"),
757785
true);
758786
}
759787

0 commit comments

Comments
 (0)