RPC: Introduce getblockstats to plot things
Summary:
It returns per block statistics about several things. It should be easy to add more if people think of other things to add or remove some if I went too far (but once written, why not keep it? EDIT: answer: not to test or maintain them). The currently available options are: minfee,maxfee,totalfee,minfeerate,maxfeerate,avgfee,avgfeerate,txs,ins,outs (EDIT: see updated list in the rpc call documentation) For the x axis, one can use height or block.nTime (I guess I could add mediantime if there's interest [EDIT: nobody showed interest but I implemented mediantime nonetheless, in fact there's no distinction between x or y axis anymore, that's for the caller to judge]). To calculate fees, -txindex is required.
Partial backport of core PR10757 (commits 35e77a0, 4cbfb6a and 41d0476)
https://github.com/bitcoin/bitcoin/pull/10757/files
Depends on D3755.
The behavior of the getblockstats RPC has been changed from the PR:
- It does not include segwit related statistics
- The amounts are expressed in BCH instead of Satoshis. This make it consistent with other RPCs.
Test Plan:
make check ./src/bitcoin-cli help getblockstats ./test/functional/test_runner.py rpc_getblockstats --gen-test-data ./test/functional/test_runner.py rpc_getblockstats
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D3756