Iguana RPC - docs.supernet.org

jl777

Active Member
Feb 26, 2016
279
345
Now that the parallel sync is looking pretty solid and it even verifies all the data (other than the actual sigs), I activated the backward compatible RPC.

That means if "services":1 is set when a coin is added, it will bind to that coin's RPC port and you can make the same calls as to bitcoind (or BitcoinDarkd)

curl --url "http://127.0.0.1:8334" --data "{\"method\":\"getblockhash\",\"params\":[100]}"

00000000fd7dddb1722cf353c2a5d10142b7bb815fc2a6c0c6d9df8a3817b40

Now since iguana supports more than one coin, and maybe you are running with the existing bitcoind, I also support making queries through the iguana's RPC port 7778

curl --url "http://127.0.0.1:7778" --data "{\"method\":\"getblockhash\",\"params\":[100]}"

however, you need to make sure iguana knows what coin you are asking about, either with a "coin" field in the posted data or with a call to bitcoinrpc, which sets the default coin to use.

http://127.0.0.1:7778/api/SuperNET/bitcoinrpc?setcoin=BTC
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"SuperNET\",\"method\":\"bitcoinrpc\",\"setcoin\":\"BTC\"}"

both of the above achieve the same result, and you can get the exact syntax for all the API from the help API call at http://127.0.0.1:7778

At the SuperNET API level, which is called internally by the bitcoin RPC layer, the "params" array is not used, rather each field is specifically set. The RPC layer automatically does this conversion, but if you can send in a request without the "params" array to the iguana's port 7778:
curl --url "http://127.0.0.1:7778" --data "{\"method\":\"getblockhash\",\"height\":100}"

I am using the site: https://chainquery.com/bitcoin-api for the exact syntax of fieldnames as it seems to be a pretty up to date one and ultimately most all of the bitcoin RPC will be available fully locally from the parallel sync iguana dataset.

iguana uses the incoming port to set the coin being used, but if you specifically add it to the curl post:
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"getblockhash\",\"params\":[100]}"

As you can see, things get quite a bit complicated to support all the various modes, so it is quite possible for there to be bugs. Please let me know if you run into any issues.

The SuperNET API that is parsing {\"agent\":\"agentname\",\"method\":\"methodname\",...} is at the lowest level and all the other paths eventually end up there.

The RPC layer converts the incoming request with or without specified coin and untyped params array into a specific set of typed fields.

The URL layer converts the incoming request into either a POST for the bitcoinrpc layer above or to the SuperNET API layer.

http://docs.supernet.org/ is automatically generated website with the output of the help API, but it can use a lot more human generated text. it combines templates from the help directory into the API test page on port 7778, the docs.supernet.org and also internally makes the C function declarations
 
  • Like
Reactions: ntto and Bloomie

jl777

Active Member
Feb 26, 2016
279
345
make sure to have the smallest bit of the services field set to enable the backward compatible RPC port, in the addcoin call \"services\":1

curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"iguana\",\"method\":\"addcoin\",\"newcoin\":\"BTCD\",\"services\":1}"

there are sample scripts that just do a curl call to start the parallel sync:
genbtc and btcd in the iguana directory.