Search code examples
phpbindbitcoinbitcoind

Access Bitcoin Daemon from Another Server


I have built Catcoind (a fork of the Bitcoin / project) and I can access the commands in my terminal by doing this from root:

cd catcoin/src 
./catcoind -daemon

That will start Catcoind, open the port, and allow me to type commands like './catcoind getdifficulty', but I want to access them from a PHP JSON-RPC client running on another server. The code I currently have there is:

<?php

require_once 'jsonRPCClient.php'; 

$catcoin = new jsonRPCClient('http://RPCUSER:RPCPASS@IP:PORT'); 

print_r($catcoin->getinfo()); 
echo $catcoin->getdifficulty();

My config file for the Catcoind build on Ubuntu is:

server=1

rpcuser=USER

rpcpassword=PASS

rpcssl=0

rpcallowip=*

bind=IP:PORT

externalip=IP

proxy=IP:PORT

port=PORT

rpcconnect=IP

When I run the code, it says that it failed to open the stream / connection refused. The config for Catcoind is at location ~/.catcoin/catcoin.conf. Any ideas? I know this is confusing, but I have really everything done but allowing external IPs to access the API. Thanks! :D


Solution

  • You don't need all these things to be written in conf file just use following

    server=1
    daemon=1
    rpcuser=<user_namer>
    rpcpassword=<password>
    rpctimeout=30
    

    if connecting from remote host do add following line

    rpcallowip=<remote_ip_address>
    

    save and exit from conf file and restart daemon by first stopping it catecoind stop and then catcoind start