bitcoin-rpc-client
bitcoin-rpc-client copied to clipboard
Error on BitcoinJSONRPCClient.getDifficulty()
Sometimes it throws the following exception:
Exception in thread "main" java.lang.ClassCastException: java.lang.Long cannot be cast to java.math.BigDecimal
at wf.bitcoin.javabitcoindrpcclient.BitcoinJSONRPCClient.getDifficulty(BitcoinJSONRPCClient.java:1005)
It occurs because bitcoin core not always return a decimal number from "getdifficulty" operation and the response parser delivers the number as a Long in this case, but BitcoinJSONRPCClient.getDifficult tries to convert it to BigDecimal