This PR introduces histunspent RPC. It calculates an histogram for the current unspent transaction output amounts.
This allows to have a better perspective of how the total balance is distributed. This also avoids transmitting the whole UTXO to create the histogram on client side, specially when it has thousands of unspents.
For the moment, the histogram bins are defined with an array of amounts. Later there can be other constructors to define the bins.
Example:
./bitcoin-cli -regtest listunspent | grep amount
"amount": 50.00000000,
"amount": 50.00000000,
"amount": 4.00000000,
"amount": 45.99996160,
"amount": 50.00000000,
"amount": 50.00000000,
"amount": 36.99996160,
"amount": 13.00000000,
"amount": 50.00000000,
./bitcoin-cli -regtest histunspent '[0,1,5,10,15,100]'
{
"bins": [
0,
1,
0,
1,
7
],
"ranges": [
0.00000000,
1.00000000,
5.00000000,
10.00000000,
15.00000000,
100.00000000
]
}
Note for reviewers, WIP and missing tests.