Commit graph

73 commits

Author SHA1 Message Date
Ross Nicoll 148a2aca05 Introduce basic Dogecoin branding 2019-03-25 05:36:11 +00:00
Wladimir J. van der Laan 481f289765 rpc: Named argument support for bitcoin-cli
Usage e.g.:

    $ src/bitcoin-cli -testnet -named echo arg0="dfdf"
    [
    "dfdf"
    ]

Argument conversion also works, for arguments thus flagged in the table in
`src/rpc/client.cpp`.

    $ src/bitcoin-cli -testnet -named echojson arg0="[1,2,3]"
    [
      [
        1,
        2,
        3
      ]
    ]

Unknown parameter (detected server-side):

    $ src/bitcoin-cli -testnet -named getinfo arg0="dfdf"
    error code: -8
    error message:
    Unknown named parameter arg0
2017-01-10 12:04:54 +01:00
Wladimir J. van der Laan cfe41d7a60
Merge #9387: [Refactor] RAII of libevent stuff using unique ptrs with deleters
05a55a6 Added EVENT_CFLAGS to test makefile to explicitly include libevent headers. (Karl-Johan Alm)
280a559 Added some simple tests for the RAII-style events. (Karl-Johan Alm)
7f7f102 Switched bitcoin-cli.cpp to use RAII unique pointers with deleters. (Karl-Johan Alm)
e5534d2 Added std::unique_ptr<> wrappers with deleters for libevent modules. (Karl-Johan Alm)
2017-01-05 11:11:17 +01:00
isle2983 27765b6403 Increment MIT Licence copyright header year on files modified in 2016
Edited via:

$ contrib/devtools/copyright_header.py update .
2016-12-31 11:01:21 -07:00
Matt Corallo 4cd373aea8 Un-expose mapArgs from utils.h 2016-12-24 11:29:33 -05:00
Matt Corallo 0cf86a6678 Introduce (and use) an IsArgSet accessor method 2016-12-23 21:30:16 -05:00
Matt Corallo c8042a48f0 Remove arguments to ParseConfigFile 2016-12-23 21:30:15 -05:00
Karl-Johan Alm 7f7f102b8d Switched bitcoin-cli.cpp to use RAII unique pointers with deleters. 2016-12-20 20:48:55 +09:00
Wladimir J. van der Laan fe37fbe606 bitcoin-cli: Make error message less confusing
Sorry for the churn on this, but the current message (introduced in #9073)
isn't acceptable:

    $ src/bitcoin-cli getinfo
    rpc: couldn't connect to server
    (make sure server is running and you are connecting to the correct RPC port: -1 unknown)

Putting the error code after the words "RPC port" made me wonder whether
there was a port configuration issue.

This changes it to:

    $ src/bitcoin-cli getinfo
    error: couldn't connect to server: unknown (code -1)
    (make sure server is running and you are connecting to the correct RPC port)
2016-12-02 08:55:18 +01:00
Karl-Johan Alm 2f2625a0bb Removed using namespace std from bitcoin-cli/-tx and added std:: in appropriate places. 2016-11-25 17:17:57 +09:00
Wladimir J. van der Laan f53023dbb8
Merge #9067: Fix exit codes
4441018 Every main()/exit() should return/use one of EXIT_ codes instead of magic numbers (UdjinM6)
bd0de13 Fix exit codes: - `--help`, `--version` etc should exit with `0` i.e. no error ("not enough args" case should still trigger an error) - error reading config file should exit with `1` (UdjinM6)
2016-11-08 10:55:03 +01:00
UdjinM6 bd0de1386e Fix exit codes:
- `--help`, `--version` etc should exit with `0` i.e. no error ("not enough args" case should still trigger an error)
- error reading config file should exit with `1`

Slightly refactor AppInitRPC/AppInitRawTx to return standard exit codes (EXIT_FAILURE/EXIT_SUCCESS) or CONTINUE_EXECUTION (-1)
2016-11-04 18:40:33 +03:00
instagibbs 8f329f991b Add common failure cases for rpc server connection failure 2016-11-03 12:09:38 -04:00
Wladimir J. van der Laan 23c32a9694
rpc: Change JSONRPCRequest to JSONRPCRequestObj
This is more consistent with `JSONRPCReplyObj`.
2016-10-19 14:30:14 +02:00
Jorge Timón 3450c18a12
Globals: Decouple GetConfigFile and ReadConfigFile from global mapArgs 2016-10-01 08:12:19 +02:00
Wladimir J. van der Laan 381826dfee bitcoin-cli: More detailed error reporting
Register a evhttp error handler to get a more detailed error message
if the HTTP request fails.
2016-09-21 14:02:42 +02:00
Puru 9a8a7d0115 bitcoin-cli.cpp: Use symbolic constant for exit code 2016-05-02 22:33:04 +05:45
Wladimir J. van der Laan 92bcca37ab rpc: Input-from-stdin mode for bitcoin-cli
Implements #7442 by adding an option `-stdin` which reads
additional arguments from stdin, one per line.

For example

```bash
echo -e "mysecretcode\n120" | src/bitcoin-cli -stdin walletpassphrase
echo -e "walletpassphrase\nmysecretcode\n120" | src/bitcoin-cli -stdin
```
2016-02-24 10:12:25 +01:00
Luke Dashjr a68bb9f5e7 Merge branch 'master' into single_prodname 2016-02-03 05:41:13 +00:00
Daniel Cousens a0eaff8a1d move rpc* to rpc/ 2016-01-21 08:36:55 +11:00
Luke Dashjr d5f46832de Unify package name to as few places as possible without major changes 2015-12-14 02:11:10 +00:00
MarcoFalke fa24439ff3 Bump copyright headers to 2015 2015-12-13 18:08:39 +01:00
Luke Dashjr 02354c93be Constrain rpcport default values to a single location in code 2015-12-01 10:18:18 +00:00
Luke Dashjr b966aa836a Constrain constant values to a single location in code 2015-11-28 18:47:29 +01:00
Philip Kaufmann ad5aae15b4 constify missing catch cases
- ensure all missing catch cases are constant where possible
2015-10-27 17:39:42 +01:00
Wladimir J. van der Laan 2cd020d054
Merge pull request #6846
3cb56f3 *: alias -h for --help (Daniel Cousens)
2015-10-22 17:53:07 +02:00
Daniel Cousens 3cb56f3778 *: alias -h for --help 2015-10-22 00:07:30 +11:00
Wladimir J. van der Laan e26a3f6713
Merge pull request #6235
55a8975 Chainparams: Translations: DRY: options and error strings (Jorge Timón)
f3525e2 Chainparams: Replace CBaseChainParams::Network enum with string constants (suggested by Wladimir) (Jorge Timón)
2015-10-20 17:06:28 +02:00
Jorge Timón 55a89751fa Chainparams: Translations: DRY: options and error strings
Also remove SelectBaseParamsFromCommandLine and SelectParamsFromCommandLine
2015-10-20 14:28:43 +02:00
Jonas Schnelli 9623e93473 [Univalue] add univalue over subtree
similar to secp256k1 include and compile univalue over a subtree
2015-10-01 10:49:57 +02:00
Wladimir J. van der Laan 2190ea6c4e rpc: Split option -rpctimeout into -rpcservertimeout and -rpcclienttimeout
The two timeouts for the server and client, are essentially different:

- In the case of the server it should be a lower value to avoid clients
clogging up connection slots

- In the case of the client it should be a high value to accomedate slow
  responses from the server, for example for slow queries or when the
  lock is contended

Split the options into `-rpcservertimeout` and `-rpcclienttimeout` with
respective defaults of 30 and 900.
2015-09-21 17:15:36 +02:00
Wladimir J. van der Laan 26c9b83677 Move windows socket init to utility function 2015-09-03 10:59:19 +02:00
Wladimir J. van der Laan 40b556d374 evhttpd implementation
- *Replace usage of boost::asio with [libevent2](http://libevent.org/)*.
boost::asio is not part of C++11, so unlike other boost there is no
forwards-compatibility reason to stick with it. Together with #4738 (convert
json_spirit to UniValue), this rids Bitcoin Core of the worst offenders with
regard to compile-time slowness.

- *Replace spit-and-duct-tape http server with evhttp*. Front-end http handling
is handled by libevent, a work queue (with configurable depth and parallelism)
is used to handle application requests.

- *Wrap HTTP request in C++ class*; this makes the application code mostly
HTTP-server-neutral

- *Refactor RPC to move all http-specific code to a separate file*.
Theoreticaly this can allow building without HTTP server but with another RPC
backend, e.g. Qt's debug console (currently not implemented) or future RPC
mechanisms people may want to use.

- *HTTP dispatch mechanism*; services (e.g., RPC, REST) register which URL
paths they want to handle.

By using a proven, high-performance asynchronous networking library (also used
by Tor) and HTTP server, problems such as #5674, #5655, #344 should be avoided.

What works? bitcoind, bitcoin-cli, bitcoin-qt. Unit tests and RPC/REST tests
pass. The aim for now is everything but SSL support.

Configuration options:

- `-rpcthreads`: repurposed as "number of  work handler threads". Still
defaults to 4.

- `-rpcworkqueue`: maximum depth of work queue. When this is reached, new
requests will return a 500 Internal Error.

- `-rpctimeout`: inactivity time, in seconds, after which to disconnect a
client.

- `-debug=http`: low-level http activity logging
2015-09-03 10:59:18 +02:00
Wladimir J. van der Laan 71cbeaad9a rpc: Implement random-cookie based authentication
When no `-rpcpassword` is specified, use a special 'cookie' file for
authentication. This file is generated with random content when the
daemon starts, and deleted when it exits. Read access to this file
controls who can access through RPC. By default this file is stored in
the data directory but it be overriden with `-rpccookiefile`.

This is similar to Tor CookieAuthentication: see
https://www.torproject.org/docs/tor-manual.html.en

Alternative to #6258. Like that pull, this allows running bitcoind
without any manual configuration. However, daemons should ideally never write to
their configuration files, so I prefer this solution.
2015-07-13 13:11:41 +02:00
Jonas Schnelli 65ce0215a4 [bitcoin-cli] improve error output 2015-07-07 17:25:56 +02:00
Jonas Schnelli 9a8897f4ac Remove JSON Spirit wrapper, remove JSON Spirit leftovers
- implement find_value() function for UniValue
- replace all Array/Value/Object types with UniValues, remove JSON Spirit to UniValue wrapper
- remove JSON Spirit sources
2015-06-04 09:16:21 +02:00
Jonas Schnelli 3df0411ad9 remove JSON Spirit UniValue wrapper 2015-06-04 09:16:06 +02:00
Jonas Schnelli 53b4671a9d extend conversion to UniValue 2015-06-04 09:16:05 +02:00
Jeff Garzik 15982a8b69 Convert tree to using univalue. Eliminate all json_spirit uses. 2015-06-04 09:16:05 +02:00
Jorge Timón b74dcb3b4a Separate CTranslationInterface from CClientUIInterface 2015-04-16 19:58:48 +02:00
Luca Venturini 1fdb9fa3f9 Help messages correctly formatted (79 chars)
Help messages are formatted programmatically with FormatParagraph
in order not to break existing strings in Transifex.

The new format works even if the translation of the strings
modifies the lenght of the message.

Sqashed 6 commits in a single one.
Help messages correctly formatted for SVGA text mode (132 chars)

Help messages are formatted programmatically with FormatParagraph
in order not to break existing strings in Transifex.

The new format should work even if the translation of the strings
modifies the lenght of the message.

Fix - syntax error

Correct formatting for 79 chars

Correctly based on C++ functions

Removed spare spaces from option strings

Fix - syntax error
2015-03-10 22:07:17 -07:00
Cory Fields a3241998e1 namespace: remove boost namespace pollution 2015-01-02 15:12:03 -05:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Wladimir J. van der Laan 111a7d45f1
Merge pull request #5470
78253fc Remove references to X11 licence (Michael Ford)
2014-12-19 19:23:23 +01:00
Philip Kaufmann 27df4123c4 make all catch() arguments const
- I saw this on http://en.cppreference.com/w/cpp/language/try_catch and
  thought it would be a good idea
- also unify used format to better be able to search for exception
  uses in our codebase
2014-12-17 09:39:24 +01:00
Michael Ford 78253fcbad Remove references to X11 licence 2014-12-16 15:56:50 +08:00
Gregory Maxwell 683dc4009b Disable SSLv3 (in favor of TLS) for the RPC client and server.
TLS is subject to downgrade attacks when SSLv3 is available, and
 SSLv3 has vulnerabilities.

The popular solution is to disable SSLv3. On the web this breaks
 some tiny number of very old clients. While Bitcoin RPC shouldn't
 be exposed to the open Internet, it also shouldn't be exposed to
 really old SSL implementations, so it shouldn't be a major issue
 for us to disable SSLv3.

There is more information on the downgrade attacks and disabling
 SSLv3 at https://disablessl3.com/ .
2014-12-06 07:08:02 -08:00
Pavel Janík 3d0a1ce193 Process help and version arguments before datadir. 2014-11-22 20:46:11 +01:00
Pieter Wuille 93a6022400 Reduce bitcoin-cli dependencies 2014-11-05 12:47:33 -08:00
Daniel Kraft af82884ab7 Add "warmup mode" for RPC server.
Start the RPC server before doing all the (expensive) startup
initialisations like loading the block index.  Until the node is ready,
return all calls immediately with a new error signalling "in warmup"
with an appropriate status message (similar to the init message).

This is useful for RPC clients to know that the server is there (e. g.,
they don't have to start it) but not yet available.  It is used in
Namecoin and Huntercoin already for some time, and there exists a UI
hooked onto the RPC interface that actively uses this to its advantage.
2014-11-04 16:01:09 +01:00