-
Notifications
You must be signed in to change notification settings - Fork 327
Support block hash alias in console #88
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -32,6 +32,7 @@ | |||||||||
| #include <QKeyEvent> | ||||||||||
| #include <QMenu> | ||||||||||
| #include <QMessageBox> | ||||||||||
| #include <QRegExp> | ||||||||||
| #include <QScreen> | ||||||||||
| #include <QScrollBar> | ||||||||||
| #include <QSettings> | ||||||||||
|
|
@@ -81,7 +82,7 @@ class RPCExecutor : public QObject | |||||||||
| explicit RPCExecutor(interfaces::Node& node) : m_node(node) {} | ||||||||||
|
|
||||||||||
| public Q_SLOTS: | ||||||||||
| void request(const QString &command, const WalletModel* wallet_model); | ||||||||||
| void request(QString command, const WalletModel* wallet_model); | ||||||||||
|
|
||||||||||
| Q_SIGNALS: | ||||||||||
| void reply(int category, const QString &command); | ||||||||||
|
|
@@ -383,10 +384,13 @@ bool RPCConsole::RPCParseCommandLine(interfaces::Node* node, std::string &strRes | |||||||||
| } | ||||||||||
| } | ||||||||||
|
|
||||||||||
| void RPCExecutor::request(const QString &command, const WalletModel* wallet_model) | ||||||||||
| void RPCExecutor::request(QString command, const WalletModel* wallet_model) | ||||||||||
| { | ||||||||||
| try | ||||||||||
| { | ||||||||||
| command.replace(QRegExp("@best"), "getbestblockhash()"); | ||||||||||
| command.replace(QRegExp("@([\\d]+)"), "getblockhash(\\1)"); | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be better to have "\b@best\b" (and likewise for digits) so you don't replace "[email protected]" in a label or similar?
Comment on lines
+391
to
+392
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The opening word boundary doesn't work with a "word" that starts with the
Suggested change
Comment on lines
+391
to
+392
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think |
||||||||||
|
|
||||||||||
| std::string result; | ||||||||||
| std::string executableCommand = command.toStdString() + "\n"; | ||||||||||
|
|
||||||||||
|
|
@@ -410,7 +414,11 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode | |||||||||
| " example: getblock(getblockhash(0) 1)[tx]\n\n" | ||||||||||
|
|
||||||||||
| "Results without keys can be queried with an integer in brackets using the parenthesized syntax.\n" | ||||||||||
| " example: getblock(getblockhash(0),1)[tx][0]\n\n"))); | ||||||||||
| " example: getblock(getblockhash(0),1)[tx][0]\n\n" | ||||||||||
|
|
||||||||||
| "Aliases for block hash can be used." | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
| " example: getblockheader @best\n" | ||||||||||
| " getblockheader @123\n\n"))); | ||||||||||
| return; | ||||||||||
| } | ||||||||||
| if (!RPCConsole::RPCExecuteCommandLine(m_node, result, executableCommand, nullptr, wallet_model)) { | ||||||||||
|
|
||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this warrants adding
QRegExpto the projectThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have it. Maybe you are thinking of
QRegularExpression?