Support block hash alias in console #88

pull promag wants to merge 1 commits into bitcoin-core:master from promag:2020-09-block-alias-console changing 1 files +11 −3
  1. promag commented at 8:56 am on September 11, 2020: contributor
    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.
  2. promag requested review from hebasto on Sep 11, 2020
  3. promag force-pushed on Sep 11, 2020
  4. promag added the label Feature on Sep 11, 2020
  5. promag closed this on Sep 11, 2020

  6. promag reopened this on Sep 11, 2020

  7. gui: Support block hash alias in console
    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.
    d2379e5c8f
  8. promag force-pushed on Sep 11, 2020
  9. promag commented at 1:21 pm on September 11, 2020: contributor
    Now using QRegExp, not sure why it fails to build with QRegularExpression since it’s (supposedly) available since Qt 5.0.
  10. hebasto commented at 1:23 pm on September 11, 2020: member

    Now using QRegExp, not sure why it fails to build with QRegularExpression since it’s (supposedly) available since Qt 5.0.

    https://github.com/bitcoin-core/gui/blob/564e1ab0f3dc573bd3ea60a80f6649c361243df9/depends/packages/qt.mk#L99

  11. promag commented at 9:38 pm on September 11, 2020: contributor
    This is an alternative approach for the GUI change in https://github.com/bitcoin/bitcoin/pull/16439
  12. in src/qt/rpcconsole.cpp:392 in d2379e5c8f
    388+void RPCExecutor::request(QString command, const WalletModel* wallet_model)
    389 {
    390     try
    391     {
    392+        command.replace(QRegExp("@best"), "getbestblockhash()");
    393+        command.replace(QRegExp("@([\\d]+)"), "getblockhash(\\1)");
    


    ajtowns commented at 4:55 am on September 14, 2020:
    Would it be better to have “\b@best\b” (and likewise for digits) so you don’t replace “bob@bestdomainever.com” in a label or similar?

    hebasto commented at 7:35 pm on September 14, 2020:

    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:

    0        command.replace(QRegExp("@best\\b"), "getbestblockhash()");
    1        command.replace(QRegExp("@([\\d]+)\\b"), "getblockhash(\\1)");
    

    luke-jr commented at 8:04 pm on October 24, 2020:
    I think RPCParseCommandLine would be the proper place to do this.
  13. in src/qt/rpcconsole.cpp:419 in d2379e5c8f
    413@@ -410,7 +414,11 @@ void RPCExecutor::request(const QString &command, const WalletModel* wallet_mode
    414                 "   example:    getblock(getblockhash(0) 1)[tx]\n\n"
    415 
    416                 "Results without keys can be queried with an integer in brackets using the parenthesized syntax.\n"
    417-                "   example:    getblock(getblockhash(0),1)[tx][0]\n\n")));
    418+                "   example:    getblock(getblockhash(0),1)[tx][0]\n\n"
    419+
    420+                "Aliases for block hash can be used."
    


    hebasto commented at 6:27 pm on September 14, 2020:
    0                "Aliases for block hash can be used.\n"
    
  14. hebasto changes_requested
  15. hebasto commented at 7:45 pm on September 14, 2020: member

    Approach ACK d2379e5c8f831abc244616069b6382626d6a6382.

    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 https://github.com/bitcoin/bitcoin/pull/16439.

  16. MarcoFalke renamed this:
    gui: Support block hash alias in console
    Support block hash alias in console
    on Sep 20, 2020
  17. in src/qt/rpcconsole.cpp:35 in d2379e5c8f
    31@@ -32,6 +32,7 @@
    32 #include <QKeyEvent>
    33 #include <QMenu>
    34 #include <QMessageBox>
    35+#include <QRegExp>
    


    luke-jr commented at 8:02 pm on October 24, 2020:
    I don’t think this warrants adding QRegExp to the project

    promag commented at 12:12 pm on October 28, 2020:
    We already have it. Maybe you are thinking of QRegularExpression?
  18. luke-jr changes_requested
  19. hebasto commented at 0:36 am on March 24, 2021: member
    @promag Any update on this? :)
  20. hebasto added the label UX on May 29, 2021
  21. hebasto added the label Waiting for author on May 29, 2021
  22. promag commented at 1:37 pm on June 6, 2021: contributor
    @hebasto I’m not convinced this is a good change. Closing for now and leaving it up for grabs.
  23. promag closed this on Jun 6, 2021

  24. promag deleted the branch on Jun 6, 2021
  25. bitcoin-core locked this on Aug 16, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-23 07:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me