Bitcoin Forum
May 04, 2024, 04:13:20 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can't connect to Bitcoin wallet with JSON-RPC  (Read 849 times)
devnikor (OP)
Newbie
*
Offline Offline

Activity: 13
Merit: 0


View Profile
March 02, 2014, 03:59:52 PM
 #1

I'm trying to connect to Bitcoin wallet from Java. But i get network exception: Server redirected too many times. I would be very glad if someone helps me understand. Here's my code:
Code:
public static void SetupRPC() {
    CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
    Authenticator.setDefault(new Authenticator() {
        protected PasswordAuthentication getPasswordAuthentication() {
            return new PasswordAuthentication ("admin", "admin".toCharArray());
        }
    });

    URL serverURL = null;
    try {
        serverURL = new URL("http://127.0.0.1:44843");
    } catch (MalformedURLException e) {
        System.err.println(e.getMessage());
    }

    JSONRPC2Session mySession = new JSONRPC2Session(serverURL);
    String method = "getinfo";
    int requestID = 0;
    JSONRPC2Request request = new JSONRPC2Request(method, requestID);

    // Send request
    JSONRPC2Response response = null;

    try {
        response = mySession.send(request);
    } catch (JSONRPC2SessionException e) {
        System.err.println(e.getMessage());
    }

    if (response.indicatesSuccess())
        System.out.println(response.getResult());
    else
        System.out.println(response.getError().getMessage());
}

And .conf file:
Code:
rpcuser="admin"
rpcpassword="admin"
rpcallowip=*
rpcport=44843
server=1
daemon=1
listen=1
rpcconnect=127.0.0.1
1714796000
Hero Member
*
Offline Offline

Posts: 1714796000

View Profile Personal Message (Offline)

Ignore
1714796000
Reply with quote  #2

1714796000
Report to moderator
1714796000
Hero Member
*
Offline Offline

Posts: 1714796000

View Profile Personal Message (Offline)

Ignore
1714796000
Reply with quote  #2

1714796000
Report to moderator
Whoever mines the block which ends up containing your transaction will get its fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714796000
Hero Member
*
Offline Offline

Posts: 1714796000

View Profile Personal Message (Offline)

Ignore
1714796000
Reply with quote  #2

1714796000
Report to moderator
Voltage2
Newbie
*
Offline Offline

Activity: 11
Merit: 0


View Profile
March 03, 2014, 03:24:57 AM
 #2

I have already posted this on Stackoverflow, but if other forum members have problems with this, here is the link
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!