How to use JSON-RPC in C++ in Linux?

1

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?

Saku

Posted 2016-05-01T09:57:40.597

Reputation: 51

Like popen()? Or system()?KJ O 2016-05-02T19:46:50.537

1

Possible duplicate of How to interact with bitcoind using C++?

JBaczuk 2018-08-16T21:45:15.823

Answers

1

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

Geremia

Posted 2016-05-01T09:57:40.597

Reputation: 3 665

1

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

Albert s

Posted 2016-05-01T09:57:40.597

Reputation: 1 344

0

How to use RPC of bitcoind or bitcoin-cli?

  1. bitcoind - bitcoin deamon = core value of the software (bitcoind -printtoconsole -debug=1)
  2. 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)

onepix

Posted 2016-05-01T09:57:40.597

Reputation: 240

0

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!

Behrad Khodayar

Posted 2016-05-01T09:57:40.597

Reputation: 213