Add separate bitcoin-rpc client #3082

pull laanwj wants to merge 1 commits into bitcoin:master from laanwj:2013_10_rpccli3 changing 8 files +229 −75
  1. laanwj commented at 9:14 PM on October 11, 2013: member

    Rework of #3072. This just adds the new executable. I gave up on the code movements to remove the dependency on leveldb/BDB as things are just too entangled, see #3072 for details. Hopefully this will also make the pull tester happier. And this is easier to review, too.

    This adds an executable bitcoin-rpc that only serves as a Bitcoin RPC client. The commit does not remove RPC functionality from the bitcoind yet, this functionality should be deprecated but is left for a later version to give users some time to switch.

  2. sipa commented at 5:13 PM on October 12, 2013: member

    Some comments on the help output:

    Usage:
      bitcoin-rpc [options] <command> [params]  Send command to -server or bitcoind
    

    Not sure if it was introduced by this commit, but I have no idea what "sending to -server" would mean.

      -rpcport=<port>        Listen for JSON-RPC connections on <port> (default: 8332 or testnet: 18332)
    

    For bitcoin-rpc, that should probably read "Connect to" instead of "Listen for"

      -rpcsslcertificatechainfile=<file.cert>  Server certificate file (default: server.cert)
      -rpcsslprivatekeyfile=<file.pem>         Server private key (default: server.pem)
      -rpcsslciphers=<ciphers>                 Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)
    

    These aren't relevant for RPC clients.

  3. in src/init.h:None in 6e8ba08016 outdated
      13 | @@ -14,6 +14,15 @@
      14 |  bool ShutdownRequested();
      15 |  void Shutdown();
      16 |  bool AppInit2(boost::thread_group& threadGroup);
      17 | -std::string HelpMessage();
      18 | +
      19 | +/* The help message mode determines what help message to show */
    


    sipa commented at 5:17 PM on October 12, 2013:

    Nit: I'm not sure that init should have knowledge about what type of clients it could be built into. How about using bit-position flags for each of the classes instead (HMM_RPC_CLIENT, HMM_OPTIONAL_RPC_SERVER, HMM_NODE, ...), and passing the combination to it?


    laanwj commented at 10:07 PM on October 12, 2013:

    That's possible. It shouldn't be in init.cpp either. Init contains all kinds of stuff that is unnecessary for the RPC client.

    Using a bitfield still implies knowledge of the type of clients, just in another format. It does need to know about the GUI so it can disable -daemon, for example. I'm not sure this is important enough to warrant a lot of thinking/planning though. Having a parameter is already lots better than a global variable!

  4. laanwj commented at 10:15 PM on October 12, 2013: member
    Not sure if it was introduced by this commit, but I have no idea what "sending to -server" would mean.
    

    That was not introduced in this commit. It is also in bitcoind, I literally took that over. I suppose it means "a bitcoin-qt started with -server".

    Agree on the rpcport having different meaning for the client than for the server, and indeed the SSL server settings can go.

  5. laanwj commented at 12:20 PM on October 13, 2013: member

    Updated the help message accordingly, and added mention in bitcoind help message that using it as client is deprecated.

  6. in src/init.cpp:None in 32a3233eba outdated
     310 | -
     311 | -    strUsage += "\n" + _("Block creation options:") + "\n";
     312 | -    strUsage += "  -blockminsize=<n>      "   + _("Set minimum block size in bytes (default: 0)") + "\n";
     313 | -    strUsage += "  -blockmaxsize=<n>      "   + _("Set maximum block size in bytes (default: 250000)") + "\n";
     314 | -    strUsage += "  -blockprioritysize=<n> "   + _("Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)") + "\n";
     315 | +    if (hmm == HMM_BITCOIND || hmm == HMM_BITCOIN_RPC)
    


    sipa commented at 2:10 PM on October 13, 2013:

    Shouldn't this be HMM_BITCOIND || HMM_BITCOIN_QT?


    laanwj commented at 2:28 PM on October 13, 2013:

    Yes, you're right.

  7. sipa commented at 3:08 PM on October 13, 2013: member

    ACK.

    One nit: -rpcsslciphers isn't used by the RPC client either.

  8. super3 commented at 11:08 PM on October 13, 2013: contributor

    Good work. Any stats on the performance over Bitcoind?

    Any idea on the time period for deprecation and drop of RPC from Bitcoind? A fair amount of codebase in based on Bitcoind, so that might cause some breakage even if it is deprecated for a while.

  9. sipa commented at 11:16 PM on October 13, 2013: member

    I expect performance to be exactly identical to bitcoind for now.

    Once we can create a stripped-down version with less dependencies, startup time may be reduced a bit. But really, it's just thin wrapper to expose an interface intended for computers to humans. If performance matters to you, you should be sending JSON-RPC directly instead of exec()ing a binary for every call.

  10. super3 commented at 3:48 AM on October 14, 2013: contributor

    Just curious. Thanks for clarifying.

    On Sun, Oct 13, 2013 at 7:17 PM, Pieter Wuille notifications@github.comwrote:

    I expect performance to be exactly identical to bitcoind for now.

    Once we can create a stripped-down version with less dependencies, startup time may be reduced a bit. But really, it's just thin wrapper to expose an interface intended for computers to humans. If performance matters to you, you should be sending JSON-RPC directly instead of exec()ing a binary for every call.

    — Reply to this email directly or view it on GitHubhttps://github.com/bitcoin/bitcoin/pull/3082#issuecomment-26229504 .

    Shawn Wilkinson Student, Morehouse College Bitcoin Developer/Entrepreneur/Enthusiast (1P4QkLsujBPBZyUwDezikL4fUSs7JvFhPv) me@super3.org http://super3.org

  11. laanwj commented at 7:19 AM on October 14, 2013: member

    Performance wasn't the concern here, just sanity. Why would you need bitcoind on a system that only does requests? And good luck browsing through the bitcoind help message to find options that concern the client. Even as bitcoin developer I needed three reworks to get those right. There is just no excuse in the world to merge the client and server into one executable.

    IMO the deprecation time period should be 0.9 to 0.10 or 0.11. Looking at the large time window between major releases, and the carefulness that merchants already have to switch to new major releases, that's enough. In any case that decision is for later, we don't need to make it now. @sipa shouldn't the ciphers be used for the client as well? As I understand it, with SSL both the client and server have their say in what cipher is used? Or is that only with SSH?

  12. laanwj commented at 10:50 AM on October 15, 2013: member

    Ok I've hidden -rpcsslciphers for the client. I still think it would be useful to have it in the client as well (SSL_CTX_set_cipher_list isn't even called in the client), but that is off-topic for this pull.

  13. laanwj commented at 10:08 AM on October 20, 2013: member

    In case we agree with adding a seperate RPC client, can we please merge this soon? Every change to the help message results in an ugly merge in init.cpp.

  14. sipa commented at 11:32 AM on October 20, 2013: member

    @gavinandresen @jgarzik @gmaxwell Any general opinion about this?

    IMHO, the fact that bitcoind is both a client and a server is confusing, and that alone warrants separating them (though certainly not instantly, too much legacy code relies on bitcoind for now).

  15. laanwj commented at 12:08 PM on October 20, 2013: member

    Right, a lot of code relies on bitcoind being a client, that's why this doesn't disable or change the functionality in bitcoind, it just adds a new executable with only the RPC functionality. Removing is completely separate and should be left to a further future release when people had the chance to switch over.

  16. sipa commented at 1:52 PM on October 20, 2013: member

    @laanwj If we ever choose to actually separate the code, there is always the option to make bitcoind exec() bitcoin-cli in case some command is provided still.

  17. jgarzik commented at 2:22 PM on October 20, 2013: contributor

    ACK, with optional, feel-free-to-merge-without-this comments,

    1. I would name it "bitcoin-cli" or "bitcoin-remote" mirroring some existing practices.

    2. Remove, rather than deprecate, "bitcoind <command>" usage. Will break some scripts, but so what. I'm more willing to break stuff like this, as 1.0 approaches.

  18. luke-jr commented at 2:29 PM on October 20, 2013: member

    Is there any reason this should be Bitcoin-specific? Couldn't a generic-JSON-RPC CLI client (perhaps written in Python?) work just as well, without complicating the codebase unnecessarily?

  19. laanwj commented at 2:43 PM on October 20, 2013: member

    @jgarzik Bitcoin-cli/remote is fine with me, I don't have any opinion on the name. I still prefer a two-step deprecation process though. @luke-jr How is this complicating the codebase? If anything, this is the beginning of a clean-up. I did some code movements in the original commit to separate different concerns into different files, which I've left out here for easier review, but they can still be done later.

    It needs to be bitcoin specific because of the argument parsing. Only a bitcoin-specific client knows to parse argument 2 of sendtoaddress as a double (for example). Sure, it could be done in a Python script, but that complicates usage on windows or other systems that don't come with Python interpreter by default. And we have the C++ code already...

  20. super3 commented at 4:26 PM on October 20, 2013: contributor

    @sipa I like the idea backward compatibility using exec() to call bitcoin-cli. I assume care of course must be taken to prevent malicious injection via Bitcoind. @jgarzik I agree that it needs to removed, but I'd rather devs have at least one release cycle to use bitcoin-cli and change their core code to match. Then you can remove on ~1.0. Deprecation give devs a fair warning. Removing is just kinda ripping the Bitcoind rug out from under them.

  21. luke-jr commented at 4:42 PM on October 20, 2013: member

    Complication, for example see all the different conditionals in strUsage now.

    Argument parsing might be an issue, I suppose - are there any cases where a Number might be confused with a String or vice-versa? JSON doesn't have doubles or integers, just Numbers - a client or server that makes a distinction is a bug.

    As long as we're modularising the code, it makes the most sense to actually modularise it IMO. Separate git repository and all.

  22. laanwj commented at 7:59 PM on October 20, 2013: member

    @luke-jr yes, the helpmessage function is complicated somewhat by this, but that's the only one. To make it more readable it could be formatted as a table with a bitfield per option (which client kinds it applies to), if anyone cares enough to do that.

    A seperate git repository sounds pointless. It's useful to be able to build everything at once. A different directory within src/ would make sense tho.

  23. sipa commented at 8:37 PM on October 20, 2013: member

    Well I guess actual separate repositories is one potential future, but I doubt we'll get to the point with the current codebase where that makes sense.

    I am in favor of a nice and shiny python RPC client, which supports things like tab completion, and inline help, and batch processing, and pipelines of queries. and unicorns. As long as nobody creates one, I think this will do just fine. If someone ever does create a better RPC client in Python (or another language), I'm sure we can replace the bitcoin-cli/remote binary with a self-contained executable compiled from it in distribution packages.

  24. super3 commented at 8:47 PM on October 20, 2013: contributor

    @sipa That kinda sounds like a fun project for me, after I do a few more documentation sweeps. I can add unicorns as long as you don't mind them being green.

  25. laanwj commented at 8:51 PM on October 20, 2013: member

    Wouldn't tab completion ideally be something in the shell instead of in the executable itself? Ie, bash has extensible command completion.

  26. sipa commented at 8:53 PM on October 20, 2013: member

    Fair enough- I wasn't entirely serious of course. I just mean that a featureful RPC client sounds useful, and Python (or any script language) sounds more appropriate for developing that than C++ - and easier to review.

  27. wtogami commented at 9:08 PM on October 20, 2013: contributor

    A python RPC client would definitely have benefits except for ease of cross platform distribution. For example, it appears that py2exe can't be cross-compiled from a Linux host and also relies upon Microsoft DLL's.

  28. super3 commented at 9:41 PM on October 20, 2013: contributor

    @sipa Which is why I said it would be a fun project. One or two of those features would be really easy to hack together using existing libs. @wtogami Hmmm. Didn't know that py2exe had that limitation. Perhaps an alternative might provide the needed cross platform distribution. A quick google search reveals cx_freeze as a possibility.

  29. luke-jr commented at 4:09 AM on October 21, 2013: member

    FWIW: At least my Python install (on Linux) has a bunch of exes for building Windows stuff with.

  30. jgarzik commented at 4:17 AM on October 21, 2013: contributor

    Any sort of python clientage is outside the scope of this pull request. This PR is fine right now, even if a future decision replaces the C++ client with something else down the road.

  31. laanwj commented at 6:30 AM on October 21, 2013: member

    @sipa I now understand, you're thinking of some kind of interactive client, not so much the rpc client it is now that is used from the shell or shell script. Sure, that'd be a useful project. I played with that idea while making the debug console, but it stayed at that as we don't want a scripting language (js, python) in the main client :-) Let's open a new issue for that.

    It'd be a complement to this and not a replacement. For lightweight interaction from shell scripts, a small executable (yes, we'll make it small eventually...) would still be preferable to a py2exe wrapped "monster".

    Rebased and renamed to bitcoin-cli.

  32. Add separate bitcoin-rpc client
    This adds an executable `bitcoin-rpc` that only serves as a Bitcoin RPC
    client.
    The commit does not remove RPC functionality from the `bitcoind` yet,
    this functionality should be deprecated but is left for a later version
    to give users some time to switch.
    2a03a39020
  33. BitcoinPullTester commented at 7:40 AM on October 21, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/2a03a39020da5ae38f05c38a5bf92c023acdeb90 for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  34. laanwj referenced this in commit b3dd90c122 on Oct 22, 2013
  35. laanwj merged this on Oct 22, 2013
  36. laanwj closed this on Oct 22, 2013

  37. laanwj deleted the branch on Apr 9, 2014
  38. Bushstar referenced this in commit 6b5b70fab8 on Apr 8, 2020
  39. DrahtBot locked this on Sep 8, 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:16 UTC

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