Connect to a node using raw JSON-RPC in Java

+1 vote

Is there a way to use any JSON-RPC framework in Java to connect and pass commands to a node?

 

I have tried this and I get a connection reset even though it connects just fine using telnet (so there's definitely a process attached to the port):

 

Map<String, String> headers = new HashMap<>();
headers.put("Authorization", "Basic <My credentials in Base64 from multichain.conf>");
JsonRpcHttpClient client = new JsonRpcHttpClient(new URL("http://<my node>:9551"), headers);
client.invoke("getinfo", new Object[] { "chain_name", "chain1", "id", 1 });

 

I am using

<dependency>
        <groupId>com.github.briandilley.jsonrpc4j</groupId>
        <artifactId>jsonrpc4j</artifactId>
        <version>1.2.0</version>
</dependency>

as JSON-RPC client. What am I doing wrong?

asked Feb 18, 2016 by Daniel

1 Answer

+1 vote
Hi,

You need to send a data in JSON format. Very usefull site:

https://bitcoin.org/en/developer-reference

Alex
answered Feb 21, 2016 by alex
...