Which library I must use for JSON? Where is RPC call example ? How to use RPC of bitcoind or bitcoin-cli? or better Electrum API to get all new (maybe pending) transactions which appears in Bitcoin net?
4 Answers
How to use RPC of bitcoind or bitcoin-cli?
- bitcoind - bitcoin deamon = core value of the software (bitcoind -printtoconsole -debug=1)
- bitcoin-cli - bitcoin command line interface = allow you to "query' the blockchain that you had download previously with bitcoind. (bitcoin-cli getinfo)
So bitcoind provide the RPC "interface" in which you can query with bitcoin-cli
(or a library in c++ you will find...).
You must run bitcoind before using bitcoin-cli.
Basically bitcoin-cli communicate with your node bitcoind so in other word your current blockchain state.
bitcoin-qt - Graphical bitcoin software = bitcoind + graphical interface
(You can find a graphical console embedded in which you will use bitcoin-cli command)
Even though it is a C library, you could use Jansson in C++ apps, too. See: https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)#C
I am not sure why you chose C++
If you are going to build something where you need the speed of C++ then understandably stick with it.
Otherwise to simply perform some RPC calls use something simpler like python or PHP.
Here is a tutorial on how to do RPC calls via python:
Bitcoin & Blockchain Programming #007 – RPCs via Python
And via PHP:
Bitcoin & Blockchain Programming #005 – RPCs via PHP
Your direct question is about a fine JSON-RPC library in C++, and the direct answer to it is:
But if I wanna target your intention, there is a well-developed wrapper for Bitcoind-json/rpc interface here. It will save you massive time!