Commit Graph

70 Commits

Author SHA1 Message Date
Wladimir J. van der Laan afd64f76ea
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
2017-03-24 09:03:59 +13:00
zkbot a7cf698873 Auto merge of #2100 - str4d:2074-rpc, r=arcalinea
Bitcoin 0.12 RPC PRs 1

Cherry-picked from the following upstream PRs:

- bitcoin/bitcoin#6266
- bitcoin/bitcoin#6257
- bitcoin/bitcoin#6271
- bitcoin/bitcoin#6158
- bitcoin/bitcoin#6307
- bitcoin/bitcoin#6290
- bitcoin/bitcoin#6262
- bitcoin/bitcoin#6088
- bitcoin/bitcoin#6339
- bitcoin/bitcoin#6299 (partial, remainder in #2099)
- bitcoin/bitcoin#6350
- bitcoin/bitcoin#6247
- bitcoin/bitcoin#6362
- bitcoin/bitcoin#5486
- bitcoin/bitcoin#6417
- bitcoin/bitcoin#6398 (partial, remainder was included in #1950)
- bitcoin/bitcoin#6444
- bitcoin/bitcoin#6456 (partial, remainder was included in #2082)
- bitcoin/bitcoin#6380
- bitcoin/bitcoin#6970

Part of #2074.
2017-03-04 02:57:46 +00:00
Philip Kaufmann db954a65ac
use const references where appropriate 2017-03-03 10:57:05 -08:00
Peter Todd d3d5483eef
Add getblockheader RPC call
Alternative to getblock that works even when the block itself has been
pruned, returning all available information.
2017-03-02 13:23:03 -08:00
Matt Corallo 3d8013a01b
Add fundrawtransaction RPC method 2017-03-02 13:23:03 -08:00
Jonas Schnelli fcc8920f36
setban: rewrite to UniValue, allow absolute bantime 2017-03-02 13:23:03 -08:00
Jonas Schnelli ed3f13a057
[RPC] add setban/listbanned/clearbanned RPC commands 2017-03-02 13:23:03 -08:00
Alex van der Peet 94ee48c42a
New RPC command disconnectnode 2017-03-02 13:23:03 -08:00
Jonas Schnelli a10a6e2a0e
[Univalue] add univalue over subtree
similar to secp256k1 include and compile univalue over a subtree
2017-02-10 02:18:51 +00:00
Jonas Schnelli d014114d67
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
2017-02-10 00:35:24 +00:00
Jonas Schnelli 851f58f94e
remove JSON Spirit UniValue wrapper 2017-02-10 00:35:24 +00:00
Jeff Garzik ed21d5bd4b
Convert tree to using univalue. Eliminate all json_spirit uses. 2017-02-10 00:35:24 +00:00
Jack Grigg 000499ae64
Add getlocalsolps and getnetworksolps RPC calls, show them in getmininginfo 2016-11-16 22:02:49 +13:00
Simon 4e16a7249c Closes #1746. Add rpc call z_validateaddress to validate zaddrs. 2016-10-31 20:05:48 -07:00
Simon 6c41028f7c Add z_listreceivedbyaddress RPC call 2016-09-08 21:46:15 -07:00
Simon a0a3334c4d Add z_getbalance and z_gettotalbalance RPC calls to close #1201. 2016-09-08 21:46:14 -07:00
Simon c1eae2806c Closes #1293 by adding z_getoperationresult and making z_getoperationstatus idempotent. 2016-09-08 21:46:13 -07:00
Simon 34f0001ccc Implement RPC call z_listoperationids and update z_getoperationstatus to take a list parameter. 2016-09-08 21:46:13 -07:00
Simon fc72c078be Add async RPC queue and operation classes.
Add z_getoperationstatus RPC command.
Add z_sendmany RPC command (dummy implementation, does not send actual
coins).
2016-09-08 21:46:13 -07:00
Jack Grigg 695a7a8826 Separate concepts of block difficulty and network difficulty in RPC
"Block difficulty" is the difficulty listed in a block's header, which in the
testnet can sometimes be min-difficulty (if time-since-last-block is too large).

"Network difficulty" is the difficulty that the network was trying to satisfy
at a particular block height. In mainnet this is always equal to the difficulty
of the solved block for that height, but in testnet the network difficulty is
derived from the last non-min-difficulty block difficulty.

This commit fixes the RPC APIs that are intended to show network difficulty, so
that on testnet they don't sometimes drop to 1.0, confusing users.

Closes #1181
2016-09-01 15:13:05 +12:00
Simon e709997ff2 Implemented z_listaddresses to return all the zaddr in the wallet. 2016-08-24 11:19:33 -07:00
Simon 92444edc00 Add z_importwallet and z_exportwallet to handle keys for both
taddr and zaddr.  Restore behaviour of dumpwallet and importwallet
to only handle taddr.
2016-08-24 11:19:33 -07:00
Simon c1c4594371 Implemented RPC calls z_importkey, z_exportkey, z_getnewaddress.
Modified RPC calls dumpwallet and importwallet to include spending keys.
2016-08-24 11:19:33 -07:00
Sean Bowe 1737627c4e Introduce `zcsamplejoinsplit` for creating a raw joinsplit description, and use it to construct the joinsplit for the performance tests that verify joinsplits. 2016-07-19 15:49:11 -06:00
Sean Bowe b7e4abd6f7 Rename some usage of 'pour'. 2016-07-18 10:06:18 -06:00
Simon 1b114e54c4 Add getblocksubsidy RPC command to return the block reward for a given
block, taking into account the mining slow start.
2016-06-27 13:04:33 -07:00
Taylor Hornby 6962bb3df0 Add automated performance measurement system. 2016-04-11 08:15:25 -06:00
Sean Bowe a8ac403db0 Added mapAnchors consensus rules, finished zcrawpour/zcrawreceive.
Some specifics on consensus changes:
* Transactions must be anchored to a real anchor in the chain.
* Anchors are pushed and popped during ConnectBlock/DisconnectBlock as appropriate.
* DisconnectTip triggers evictions, under some circumstances, of transactions in the
  mempool which are anchored to roots that are no longer valid.
* Commitments append to the tree at the current best root during ConnectBlock.
2016-01-19 14:36:04 -07:00
Sean Bowe 730790f7a4 Added primitive zcrawkeygen/zcrawpour implementations 2016-01-19 14:36:04 -07:00
Wladimir J. van der Laan 1fd2d39529
Merge pull request #5420
6b4feb8 [QA] rest.py RPC test: change setgenerate() to generate() (Jonas Schnelli)
97ee866 [REST] getutxos REST command (based on Bip64) (Jonas Schnelli)
2015-05-06 16:50:05 +02:00
Matt Corallo 59ed61b389 Add RPC call to generate and verify merkle blocks 2015-04-23 17:50:39 -07:00
Jonas Schnelli 97ee866549 [REST] getutxos REST command (based on Bip64)
has parts of @mhearn #4351
* allows querying the utxos over REST
* same binary input and outputs as mentioned in Bip64
* input format = output format
* various rpc/rest regtests
2015-04-21 20:26:49 +02:00
Jonas Schnelli b9fb692d04 Push down RPC reqWallet flag 2015-04-12 19:37:29 +02:00
Pieter Wuille 6b04508e37 Introduce separate 'generate' RPC call 2015-04-01 11:47:10 -07:00
Gavin Andresen 0f5954c434
Regression test for ResendWalletTransactions
Adds a regression test for the wallet's ResendWalletTransactions function, which uses a new, hidden RPC command "resendwallettransactions."

I refactored main's Broadcast signal so it is passed the best-block time, which let me remove a global variable shared between main.cpp and the wallet (nTimeBestReceived).

I also manually tested the "rebroadcast unconfirmed every half hour or so" functionality by:

1. Running bitcoind -connect=0.0.0.0:8333
2. Creating a couple of send-to-self transactions
3. Connect to a peer using -addnode
4. Waited a while, monitoring debug.log, until I see:
```2015-03-23 18:48:10 ResendWalletTransactions: rebroadcast 2 unconfirmed transactions```

One last change: don't bother putting ResendWalletTransactions messages in debug.log unless unconfirmed transactions were actually rebroadcast.
2015-03-24 15:29:20 -04:00
Wladimir J. van der Laan 5ebe0956b3 Trim RPC command table
- invalidateblock and reconsiderblock were defined doubly
- remove no-longer-used threadSafe, as locks have been pushed down
2015-01-28 07:41:54 +01:00
Eric Lombrozo 4401b2d7c5 Removed main.h dependency from rpcserver.cpp
Rebased by @laanwj:

- update for RPC methods added since 84d13ee: setmocktime,
  invalidateblock, reconsiderblock. Only the first, setmocktime, required a change,
  the other two are thread safe.
2015-01-28 07:41:54 +01:00
Wladimir J. van der Laan 40e96a3016
Merge pull request #5599
0cc0d8d Get rid of the internal miner's hashmeter (jtimon)
2015-01-24 16:00:40 +01:00
jtimon 0cc0d8d60b Get rid of the internal miner's hashmeter 2015-01-04 21:04:55 +01:00
sandakersmann f914f1a746
Added "Core" to copyright headers
Github-Pull: #5494
Rebased-From: 15de949bb9277e442302bdd8dee299a8d6deee60
2014-12-19 19:55:32 +01:00
Daniel Kraft 7c8e4c5cfb Make pass-by-ref arguments const.
Make some of the arguments in rest.cpp, that are passed by
reference but never modified, const to emphasise that.
2014-12-16 13:45:27 +01:00
Pieter Wuille 9b0a8d3152 Add 'invalidateblock' and 'reconsiderblock' RPC commands.
These can be used for testing reorganizations or for manual intervention in case of
chain forks.
2014-11-26 16:36:25 +01:00
Jonas Schnelli 78bdc8103f [REST] give an appropriate response in warmup phase 2014-11-26 13:51:02 +01:00
Michael Ford 72fb3d295a Update comments in src/rpc* to be doxygen compatible 2014-11-20 10:19:39 +08:00
Gavin Andresen fd3777b0b2
Merge pull request #5280
3c30f27 travis: disable rpc tests for windows until they're not so flaky (Cory Fields)
daf03e7 RPC tests: create initial chain with specific timestamps (Gavin Andresen)
a8b2ce5 regression test only setmocktime RPC call (Gavin Andresen)
2014-11-18 14:31:29 -05:00
Gavin Andresen a8b2ce557d
regression test only setmocktime RPC call 2014-11-17 10:33:49 -05:00
Jeff Garzik e2655e0ab1 Add unauthenticated HTTP REST interface to public blockchain data. 2014-11-11 04:52:43 -05: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
Pavel Janík 84738627ce Fix all header defines 2014-11-03 16:16:40 +01:00
Philip Kaufmann 771d500283 minor cleanup: include orders, end comments etc.
- no code changes
2014-10-31 09:41:15 +01:00