Use real HTTP bind address in curl RPC help #15259

pull domob1812 wants to merge 2 commits into bitcoin:master from domob1812:decoupled-rpchelp changing 6 files +80 −20
  1. domob1812 commented at 9:36 AM on January 25, 2019: contributor

    This change exposes the bind address (one of them if multiple) of the HTTP server. This allows us to use a real bind address in the curl example in RPC help texts.

    In particular, this now reports the correct port if it was either explicitly changed through -rpcport or is from a different chain than mainnet.

    This is a replacement for #15181, based on the feedback from @laanwj there.

  2. domob1812 commented at 9:38 AM on January 25, 2019: contributor

    This includes some trivial refactoring (static replaced by anonymous namespaces) in places that I changed anyway - I think this would not be worth doing in a separate PR. But of course I'm happy to either remove those changes or submit them in a separate commit / PR if you think that's better.

  3. fanquake added the label RPC/REST/ZMQ on Jan 25, 2019
  4. in src/httpserver.cpp:496 in 1d5aed474f outdated
     489 | @@ -478,6 +490,15 @@ void StopHTTPServer()
     490 |      LogPrint(BCLog::HTTP, "Stopped HTTP server\n");
     491 |  }
     492 |  
     493 | +bool GetHTTPBindAddress(std::string& address)
     494 | +{
     495 | +    if (bindAddress.empty()) {
     496 | +        return false;
    


    promag commented at 10:22 AM on January 25, 2019:
    address = bindAddress;
    return !address.empty();
    

    domob1812 commented at 12:18 PM on January 25, 2019:

    Yes, but that would overwrite the passed in address. While it doesn't matter in the current context, I found it cleaner to not affect it at all if false is returned.

  5. promag commented at 10:37 AM on January 25, 2019: member

    This has unnecessary/unrelated changes.

  6. domob1812 commented at 12:18 PM on January 25, 2019: contributor

    This has unnecessary/unrelated changes.

    See my comment above. I feel those changes are an improvement and too insignificant to do on their own, but I'm happy to either split them out or not do them at all.

  7. promag commented at 1:11 PM on January 25, 2019: member

    At least have in a separate commit. If they are an improvement and unrelated here then a separate PR makes more sense.

  8. Replace static with anonymous namespaces.
    Use anonymous namespaces in some places instead of the static keyword.
    Both result in internal linkage, but anonymous namespaces are a more
    modern way to do it.
    5093053677
  9. domob1812 force-pushed on Jan 25, 2019
  10. domob1812 commented at 2:16 PM on January 25, 2019: contributor

    At least have in a separate commit. If they are an improvement and unrelated here then a separate PR makes more sense.

    Agreed, I've split it into two commits for now. As I wrote above, I'm happy to drop the first one or submit in a separate PR if you think that makes more sense.

  11. MarcoFalke commented at 4:53 PM on January 25, 2019: member

    This is a lot of code for making an example more "real". Generally, I'd prefer if the example was static, since it ends up on static websites (https://bitcoincore.org/en/doc/0.16.0/rpc/rawtransactions/getrawtransaction/ or http://chainquery.com/bitcoin-api/getrawtransaction)

    Wouldn't it make more sense to include that information in the getrpcinfo command as suggested by @instagibbs #14982 (comment)?

  12. domob1812 commented at 5:03 PM on January 25, 2019: contributor

    This is a lot of code for making an example more "real". Generally, I'd prefer if the example was static, since it ends up on static websites (https://bitcoincore.org/en/doc/0.16.0/rpc/rawtransactions/getrawtransaction/ or http://chainquery.com/bitcoin-api/getrawtransaction)

    Wouldn't it make more sense to include that information in the getrpcinfo command as suggested by @instagibbs #14982 (comment)?

    I don't know. I just noticed that the port can be plain wrong in the static example, for instance if running in regtest mode. (Which is actually something that developers might do and where they might want to use the curl example to access their node!) @laanwj's last opinion was that he would be happy with that change in the form it is now, at least if I understood him correctly. But since he would also be happy not doing the fix and I don't care too strongly about it (especially with the amount of back and forth this is getting to), I'm happy to just drop this attempt finally.

  13. promag commented at 5:37 PM on January 25, 2019: member

    Agree with @MarcoFalke, the help text is an example.

  14. in test/functional/rpc_help.py:48 in 177a407822 outdated
      44 | @@ -43,6 +45,10 @@ def test_categories(self):
      45 |  
      46 |          assert_equal(titles, components)
      47 |  
      48 | +    def test_exampleBindAddress(self):
    


    practicalswift commented at 10:02 PM on January 27, 2019:

    Should be snake_case? :-)


    domob1812 commented at 9:27 AM on January 28, 2019:

    Fixed

  15. Use real HTTP bind address in curl RPC help.
    This change exposes the bind address (one of them if multiple) of the HTTP
    server.  This allows us to use a real bind address in the "curl" example
    in RPC help texts.
    
    In particular, this now reports the correct port if it was either
    explicitly changed through -rpcport or is from a different chain than
    mainnet.
    79eeaa48e8
  16. in test/functional/rpc_help.py:49 in 177a407822 outdated
      44 | @@ -43,6 +45,10 @@ def test_categories(self):
      45 |  
      46 |          assert_equal(titles, components)
      47 |  
      48 | +    def test_exampleBindAddress(self):
      49 | +        helpText = self.nodes[0].help('getblockchaininfo')
    


    practicalswift commented at 10:03 PM on January 27, 2019:

    Same here -- should be snake_case? :-)


    domob1812 commented at 9:27 AM on January 28, 2019:

    Fixed

  17. domob1812 force-pushed on Jan 28, 2019
  18. domob1812 commented at 9:28 AM on January 28, 2019: contributor

    I've fixed the two nits found by @practicalswift. But if the general opinion is that we should just not do this, then feel free to just close the PR.

  19. laanwj commented at 9:34 AM on January 28, 2019: member

    I've fixed the two nits found by @practicalswift. But if the general opinion is that we should just not do this, then feel free to just close the PR.

    Tend to agree. This just keeps dragging on.

    But it's better to do that yourself! (than you still have control over it)

  20. domob1812 commented at 2:14 PM on January 28, 2019: contributor

    I've fixed the two nits found by @practicalswift. But if the general opinion is that we should just not do this, then feel free to just close the PR.

    Tend to agree. This just keeps dragging on.

    But it's better to do that yourself! (than you still have control over it)

    Sounds good, then just let me close it. :)

  21. domob1812 closed this on Jan 28, 2019

  22. domob1812 deleted the branch on Feb 13, 2019
  23. DrahtBot locked this on Dec 16, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-13 15:15 UTC

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