-
Notifications
You must be signed in to change notification settings - Fork 326
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
Conversation
42464cc to
7e04b09
Compare
7e04b09 to
d2379e5
Compare
|
Now using |
Line 99 in 564e1ab
|
|
This is an alternative approach for the GUI change in bitcoin/bitcoin#16439 |
| try | ||
| { | ||
| command.replace(QRegExp("@best"), "getbestblockhash()"); | ||
| command.replace(QRegExp("@([\\d]+)"), "getblockhash(\\1)"); |
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.
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?
hebasto
left a comment
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.
Approach ACK d2379e5.
Only help-console message provides a user with info about new aliases. The help messages of the affected RPC's still lack these updates, but I think it is OK for the GUI console.
This PR seems preferable than the 2f9f2d66cbada9134238f25aa12691876bdeff6b commit from bitcoin/bitcoin#16439.
| " 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." |
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.
| "Aliases for block hash can be used." | |
| "Aliases for block hash can be used.\n" |
| command.replace(QRegExp("@best"), "getbestblockhash()"); | ||
| command.replace(QRegExp("@([\\d]+)"), "getblockhash(\\1)"); |
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.
The opening word boundary doesn't work with a "word" that starts with the @ character. But the closing word boundary indeed improves behavior and error handling:
| command.replace(QRegExp("@best"), "getbestblockhash()"); | |
| command.replace(QRegExp("@([\\d]+)"), "getblockhash(\\1)"); | |
| command.replace(QRegExp("@best\\b"), "getbestblockhash()"); | |
| command.replace(QRegExp("@([\\d]+)\\b"), "getblockhash(\\1)"); |
| #include <QKeyEvent> | ||
| #include <QMenu> | ||
| #include <QMessageBox> | ||
| #include <QRegExp> |
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 QRegExp to the project
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.
We already have it. Maybe you are thinking of QRegularExpression?
| command.replace(QRegExp("@best"), "getbestblockhash()"); | ||
| command.replace(QRegExp("@([\\d]+)"), "getblockhash(\\1)"); |
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 think RPCParseCommandLine would be the proper place to do this.
|
@promag Any update on this? :) |
|
@hebasto I'm not convinced this is a good change. Closing for now and leaving it up for grabs. |
Add support to use @best or @height instead of block hash in the
RPC console. The approach used is to simply replace those expressions
with the relevant RPC method.