0

I am running Bitcoin Network on local Ubuntu machine. The network consists of multiple nodes. I want to connect to the network from a java application running on the same machine via JSON RPC. I can connect to the Bitcoind server from command line using bitcoin-cli. However, i cannot connect to the Bitcoind server from the Java application using Bitcoinj Libraray. I suspect that the problem is related to RPC authentication. I specified rpc username and password in the bitcoin.conf file and I tried to use Java Authenticator in my Java code. However, it hasn't solved the problem.

  Authenticator.setDefault(new Authenticator() {
                protected PasswordAuthentication getPasswordAuthentication()
 { return new PasswordAuthentication (rpcuser, rpcpassword.toCharArray());
                }});

My bitcoin.conf file is as follows:

regtest=1
server=1
listen=1
rpcuser=user
rpcpassword=password
fallbackfee=0.0001
[regtest]
port=10000
rpcport=20000
bind=127.0.0.1
rpcbind=127.0.0.1
rpcallowip=127.0.0.1

This is the log message I see when i start the Bitcoind server: Server Log

  • List item

Server Log

And this is the error I am receiving on the application side: Application side error message

I am using Bitcoin core version 22 for the server and Bitcoinj library version 16.1 (https://bitcoinj.org/getting-started) to connect to the server

2
  • Are you trying to connect to regtest? If so, you've specified a custom rpcport, does your Java code try to connect to that port?
    – Andrew Chow
    Sep 2 at 20:28
  • @AndrewChow yes, i am trying to connect to a regtest network using the new rpcport I specified in the bitcoin.conf file.
    – J.A
    Sep 3 at 8:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.