Think I found a bug

+1 vote
Using getinfo via rpc api returns difficulty correctly for a non-test server (e.g. "difficulty" : 0.000223370) but when tried on a testnet it returns a wrong number: "difficulty" : 1.526000000000000e-05 (should be .0001526).

'multichain-cli <name> getinfo' from command line returns the correct value however.
asked Dec 18, 2015 by cyb0rg
Hello, I'm trying to connect via rpc api.
I tried to use bitcoin-json-rpc-client API, but not found a way/method to connect with the Multichain.

Can you explain me how you managed to connect?

My topic with this doubt
http://www.multichain.com/qa/714/trying-to-connect-via-java-client

Thank you!

1 Answer

0 votes

If it works from the command line, the problem is almost definitely a consequence of your JSON-RPC library rather than something in MultiChain, because multichain-cli is just a wrapper for the JSON-RPC interface.

Your JSON-RPC library appears to format small numbers using exponential notation, or perhaps whatever process you are using to print out those numbers. You can probably understand the exact problem by printing the number at various stages of the code, from JSON-RPC request to how you output it.

answered Dec 19, 2015 by MultiChain
The strange part is I am using the exact same code and a clone of the the exact same multichain, the only difference is the testnet flag. I am printing the result from the getInfo api call like this: cout << result.toStyledString() << endl;

Using cout << result["difficulty"].asDouble() << endl; result in the same behavior: 1.526e-05
 

Like I said the non-testnet result is fine, the testnet result is not.
It's not the testnet flag that is causing a difference, but rather the output value being below a certain threshold.
So the threshold is somewhere between  0.000223370 (on my non-testnet) and  0.0001526?
I guess so, it depends on the toStyledString() function.
...